first commit
This commit is contained in:
96
build/node_modules/prepack/lib/partial-evaluators/BlockStatement.js
generated
vendored
Normal file
96
build/node_modules/prepack/lib/partial-evaluators/BlockStatement.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// ECMA262 13.2.13
|
||||
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
var oldEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// 2. Let blockEnv be NewDeclarativeEnvironment(oldEnv).
|
||||
var blockEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
|
||||
// 3. Perform BlockDeclarationInstantiation(StatementList, blockEnv).
|
||||
_singletons.Environment.BlockDeclarationInstantiation(realm, strictCode, ast.body, blockEnv);
|
||||
|
||||
// 4. Set the running execution context's LexicalEnvironment to blockEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = blockEnv;
|
||||
|
||||
try {
|
||||
// 5. Let blockValue be the result of evaluating StatementList.
|
||||
var blockValue = void 0;
|
||||
|
||||
if (ast.directives) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = ast.directives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var directive = _step.value;
|
||||
|
||||
blockValue = new _index.StringValue(realm, directive.value.value);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _Functions$PartiallyE = _singletons.Functions.PartiallyEvaluateStatements(ast.body, blockValue, strictCode, blockEnv, realm),
|
||||
_Functions$PartiallyE2 = _slicedToArray(_Functions$PartiallyE, 2),
|
||||
res = _Functions$PartiallyE2[0],
|
||||
bAst = _Functions$PartiallyE2[1];
|
||||
|
||||
(0, _invariant2.default)(bAst.length > 0 || res instanceof _index.EmptyValue);
|
||||
if (bAst.length === 0) return [res, t.emptyStatement(), []];
|
||||
var rAst = t.blockStatement(bAst, ast.directives);
|
||||
return [res, rAst, []];
|
||||
} finally {
|
||||
// 6. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
realm.onDestroyScope(blockEnv);
|
||||
}
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _babelTypes = require("babel-types");
|
||||
|
||||
var t = _interopRequireWildcard(_babelTypes);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=BlockStatement.js.map
|
||||
Reference in New Issue
Block a user