UNPKG

prepack

Version:

Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.

77 lines (65 loc) 2.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SteppingManager = undefined; var _babelTypes = require("babel-types"); var _invariant = require("./../common/invariant.js"); var _invariant2 = _interopRequireDefault(_invariant); var _Stepper = require("./Stepper.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } class SteppingManager { constructor(realm, keepOldSteppers) { this._realm = realm; this._steppers = []; this._keepOldSteppers = false; if (keepOldSteppers) this._keepOldSteppers = true; } processStepCommand(kind, currentNode) { if (kind === "in") { this._processStepIn(currentNode); } else if (kind === "over") { this._processStepOver(currentNode); } // TODO: implement stepOver and stepOut } _processStepIn(ast) { (0, _invariant2.default)(this._stepInto === undefined); (0, _invariant2.default)(ast.loc && ast.loc.source); if (!this._keepOldSteppers) { this._steppers = []; } this._steppers.push(new _Stepper.StepIntoStepper(ast.loc.source, ast.loc.start.line, ast.loc.start.column)); } _processStepOver(ast) { (0, _invariant2.default)(ast.loc && ast.loc.source); if (!this._keepOldSteppers) { this._steppers = []; } this._steppers.push(new _Stepper.StepOverStepper(ast.loc.source, ast.loc.start.line, ast.loc.start.column, this._realm.contextStack.length)); } getAndDeleteCompletedSteppers(ast) { (0, _invariant2.default)(ast.loc && ast.loc.source); let i = 0; let completedSteppers = []; while (i < this._steppers.length) { let stepper = this._steppers[i]; if (stepper.isComplete(ast, this._realm.contextStack.length)) { completedSteppers.push(stepper); this._steppers.splice(i, 1); } else { i++; } } return completedSteppers; } } exports.SteppingManager = SteppingManager; /** * Copyright (c) 2017-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ //# sourceMappingURL=SteppingManager.js.map