89 lines
7.2 KiB
JavaScript
89 lines
7.2 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.SteppingManager = undefined;
|
|
|
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
|
|
* 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.
|
|
*/
|
|
|
|
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 }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var SteppingManager = exports.SteppingManager = function () {
|
|
function SteppingManager(realm, keepOldSteppers) {
|
|
_classCallCheck(this, SteppingManager);
|
|
|
|
this._realm = realm;
|
|
this._steppers = [];
|
|
this._keepOldSteppers = false;
|
|
if (keepOldSteppers) this._keepOldSteppers = true;
|
|
}
|
|
|
|
_createClass(SteppingManager, [{
|
|
key: "processStepCommand",
|
|
value: function processStepCommand(kind, currentNode) {
|
|
if (kind === "in") {
|
|
this._processStepIn(currentNode);
|
|
} else if (kind === "over") {
|
|
this._processStepOver(currentNode);
|
|
}
|
|
// TODO: implement stepOver and stepOut
|
|
}
|
|
}, {
|
|
key: "_processStepIn",
|
|
value: function _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));
|
|
}
|
|
}, {
|
|
key: "_processStepOver",
|
|
value: function _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));
|
|
}
|
|
}, {
|
|
key: "getAndDeleteCompletedSteppers",
|
|
value: function getAndDeleteCompletedSteppers(ast) {
|
|
(0, _invariant2.default)(ast.loc && ast.loc.source);
|
|
var i = 0;
|
|
var completedSteppers = [];
|
|
while (i < this._steppers.length) {
|
|
var stepper = this._steppers[i];
|
|
if (stepper.isComplete(ast, this._realm.contextStack.length)) {
|
|
completedSteppers.push(stepper);
|
|
this._steppers.splice(i, 1);
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
return completedSteppers;
|
|
}
|
|
}]);
|
|
|
|
return SteppingManager;
|
|
}();
|
|
//# sourceMappingURL=SteppingManager.js.map
|