first commit
This commit is contained in:
97
build/node_modules/prepack/lib/evaluators/ArrayExpression.js
generated
vendored
Normal file
97
build/node_modules/prepack/lib/evaluators/ArrayExpression.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Let array be ArrayCreate(0).
|
||||
var array = _singletons.Create.ArrayCreate(realm, 0);
|
||||
|
||||
// 2. Let len be the result of performing ArrayAccumulation for ElementList with arguments array and 0.
|
||||
var elements = ast.elements || [];
|
||||
var len = elements.length;
|
||||
var nextIndex = 0;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var elem = elements[i];
|
||||
if (!elem) {
|
||||
nextIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ECMA262 12.2.5.2
|
||||
if (elem.type === "SpreadElement") {
|
||||
// 1. Let spreadRef be the result of evaluating AssignmentExpression.
|
||||
var spreadRef = env.evaluate(elem.argument, strictCode);
|
||||
|
||||
// 2. Let spreadObj be ? GetValue(spreadRef).
|
||||
var spreadObj = _singletons.Environment.GetValue(realm, spreadRef);
|
||||
|
||||
// 3. Let iterator be ? GetIterator(spreadObj).
|
||||
var iterator = (0, _index2.GetIterator)(realm, spreadObj);
|
||||
|
||||
// 4. Repeat
|
||||
while (true) {
|
||||
// a. Let next be ? IteratorStep(iterator).
|
||||
var next = (0, _iterator.IteratorStep)(realm, iterator);
|
||||
|
||||
// b. If next is false, return nextIndex.
|
||||
if (next === false) break;
|
||||
|
||||
// c. Let nextValue be ? IteratorValue(next).
|
||||
var nextValue = (0, _iterator.IteratorValue)(realm, next);
|
||||
|
||||
// d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), nextValue).
|
||||
var status = _singletons.Create.CreateDataProperty(realm, array, new _index.StringValue(realm, nextIndex++ + ""), nextValue);
|
||||
|
||||
// e. Assert: status is true.
|
||||
(0, _invariant2.default)(status === true);
|
||||
|
||||
// f. Let nextIndex be nextIndex + 1.
|
||||
}
|
||||
} else {
|
||||
// Redundant steps.
|
||||
// 1. Let postIndex be the result of performing ArrayAccumulation for ElementList with arguments array and nextIndex.
|
||||
// 2. ReturnIfAbrupt(postIndex).
|
||||
// 3. Let padding be the ElisionWidth of Elision; if Elision is not present, use the numeric value zero.
|
||||
|
||||
// 4. Let initResult be the result of evaluating AssignmentExpression.
|
||||
var initResult = env.evaluate(elem, strictCode);
|
||||
|
||||
// 5. Let initValue be ? GetValue(initResult).
|
||||
var initValue = _singletons.Environment.GetValue(realm, initResult);
|
||||
|
||||
// 6. Let created be CreateDataProperty(array, ToString(ToUint32(postIndex+padding)), initValue).
|
||||
var created = _singletons.Create.CreateDataProperty(realm, array, new _index.StringValue(realm, nextIndex++ + ""), initValue);
|
||||
|
||||
// 7. Assert: created is true.
|
||||
(0, _invariant2.default)(created === true, "expected data property creation");
|
||||
}
|
||||
}
|
||||
|
||||
// Not necessary since we propagate completions with exceptions.
|
||||
// 3. ReturnIfAbrupt(len).
|
||||
|
||||
// 4. Perform Set(array, "length", ToUint32(len), false).
|
||||
_singletons.Properties.Set(realm, array, "length", new _index.NumberValue(realm, nextIndex), false);
|
||||
|
||||
// 5. NOTE: The above Set cannot fail because of the nature of the object returned by ArrayCreate.
|
||||
|
||||
// 6. Return array.
|
||||
return array;
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _iterator = require("../methods/iterator.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=ArrayExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ArrayExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ArrayExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
45
build/node_modules/prepack/lib/evaluators/ArrowFunctionExpression.js
generated
vendored
Normal file
45
build/node_modules/prepack/lib/evaluators/ArrowFunctionExpression.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var ConciseBody = ast.body;
|
||||
if (ConciseBody.type !== "BlockStatement") {
|
||||
ConciseBody = t.blockStatement([t.returnStatement(ConciseBody)]);
|
||||
// Use original array function's location for the new concise body.
|
||||
ConciseBody.loc = ast.body.loc;
|
||||
}
|
||||
|
||||
// 1. If the function code for this ArrowFunction is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var strict = strictCode || (0, _strict2.default)(ast.body);
|
||||
|
||||
// 2. Let scope be the LexicalEnvironment of the running execution context.
|
||||
var scope = env;
|
||||
|
||||
// 3. Let parameters be CoveredFormalsList of ArrowParameters.
|
||||
var parameters = ast.params;
|
||||
|
||||
// 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict).
|
||||
var closure = _singletons.Functions.FunctionCreate(realm, "arrow", parameters, ConciseBody, scope, strict);
|
||||
closure.loc = ast.loc;
|
||||
|
||||
// 5. Return closure.
|
||||
return closure;
|
||||
};
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _strict = require("../utils/strict.js");
|
||||
|
||||
var _strict2 = _interopRequireDefault(_strict);
|
||||
|
||||
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=ArrowFunctionExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ArrowFunctionExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ArrowFunctionExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ArrowFunctionExpression.js"],"names":["ast","strictCode","env","realm","ConciseBody","body","type","t","blockStatement","returnStatement","loc","strict","scope","parameters","params","closure","FunctionCreate"],"mappings":";;;;;;kBAoBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,MAAIC,cAAcJ,IAAIK,IAAtB;AACA,MAAID,YAAYE,IAAZ,KAAqB,gBAAzB,EAA2C;AACzCF,kBAAcG,EAAEC,cAAF,CAAiB,CAACD,EAAEE,eAAF,CAAkBL,WAAlB,CAAD,CAAjB,CAAd;AACA;AACAA,gBAAYM,GAAZ,GAAkBV,IAAIK,IAAJ,CAASK,GAA3B;AACD;;AAED;AACA,MAAIC,SAASV,cAAc,sBAASD,IAAIK,IAAb,CAA3B;;AAEA;AACA,MAAIO,QAAQV,GAAZ;;AAEA;AACA,MAAIW,aAAab,IAAIc,MAArB;;AAEA;AACA,MAAIC,UAAU,sBAAUC,cAAV,CAAyBb,KAAzB,EAAgC,OAAhC,EAAyCU,UAAzC,EAAqDT,WAArD,EAAkEQ,KAAlE,EAAyED,MAAzE,CAAd;AACAI,UAAQL,GAAR,GAAcV,IAAIU,GAAlB;;AAEA;AACA,SAAOK,OAAP;AACD,C;;AAlCD;;AACA;;;;AACA;;IAAYR,C","file":"ArrowFunctionExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { Functions } from \"../singletons.js\";\nimport IsStrict from \"../utils/strict.js\";\nimport * as t from \"babel-types\";\nimport type { BabelNodeArrowFunctionExpression } from \"babel-types\";\n\n// ECMA262 14.2.16\nexport default function(\n ast: BabelNodeArrowFunctionExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n let ConciseBody = ast.body;\n if (ConciseBody.type !== \"BlockStatement\") {\n ConciseBody = t.blockStatement([t.returnStatement(ConciseBody)]);\n // Use original array function's location for the new concise body.\n ConciseBody.loc = ast.body.loc;\n }\n\n // 1. If the function code for this ArrowFunction is strict mode code, let strict be true. Otherwise let strict be false.\n let strict = strictCode || IsStrict(ast.body);\n\n // 2. Let scope be the LexicalEnvironment of the running execution context.\n let scope = env;\n\n // 3. Let parameters be CoveredFormalsList of ArrowParameters.\n let parameters = ast.params;\n\n // 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict).\n let closure = Functions.FunctionCreate(realm, \"arrow\", parameters, ConciseBody, scope, strict);\n closure.loc = ast.loc;\n\n // 5. Return closure.\n return closure;\n}\n"]}
|
||||
99
build/node_modules/prepack/lib/evaluators/AssignmentExpression.js
generated
vendored
Normal file
99
build/node_modules/prepack/lib/evaluators/AssignmentExpression.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
if (!ast.hasOwnProperty("operator") || ast.operator === null) throw Error("Unexpected AST form");
|
||||
|
||||
var LeftHandSideExpression = ast.left;
|
||||
var AssignmentExpression = ast.right;
|
||||
var AssignmentOperator = ast.operator;
|
||||
|
||||
// AssignmentExpression : LeftHandSideExpression = AssignmentExpression
|
||||
if (AssignmentOperator === "=") {
|
||||
// 1. If LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral, then
|
||||
//
|
||||
// The spec assumes we haven't yet distinguished between literals and
|
||||
// patterns, but our parser does that work for us. That means we check for
|
||||
// "*Pattern" instead of "*Literal" like the spec text suggests.
|
||||
if (LeftHandSideExpression.type !== "ObjectPattern" && LeftHandSideExpression.type !== "ArrayPattern") {
|
||||
// a. Let lref be the result of evaluating LeftHandSideExpression.
|
||||
var _lref = env.evaluate(LeftHandSideExpression, strictCode);
|
||||
// b. ReturnIfAbrupt(lref). -- Not neccessary
|
||||
// c. Let rref be the result of evaluating AssignmentExpression.
|
||||
var _rref2 = env.evaluate(AssignmentExpression, strictCode);
|
||||
// d. Let rval be ? GetValue(rref).
|
||||
var _rval2 = _singletons.Environment.GetValue(realm, _rref2);
|
||||
// e. If IsAnonymousFunctionDefinition(AssignmentExpression) and IsIdentifierRef of LeftHandSideExpression are both true, then
|
||||
if ((0, _index2.IsAnonymousFunctionDefinition)(realm, AssignmentExpression) && (0, _index2.IsIdentifierRef)(realm, LeftHandSideExpression)) {
|
||||
(0, _invariant2.default)(_rval2 instanceof _index.ObjectValue);
|
||||
// i. Let hasNameProperty be ? HasOwnProperty(rval, "name").
|
||||
var hasNameProperty = (0, _index2.HasOwnProperty)(realm, _rval2, "name");
|
||||
// ii. If hasNameProperty is false, perform SetFunctionName(rval, GetReferencedName(lref)).
|
||||
if (!hasNameProperty) {
|
||||
(0, _invariant2.default)(_lref instanceof _environment.Reference);
|
||||
_singletons.Functions.SetFunctionName(realm, _rval2, _singletons.Environment.GetReferencedName(realm, _lref));
|
||||
}
|
||||
}
|
||||
// f. Perform ? PutValue(lref, rval).
|
||||
_singletons.Properties.PutValue(realm, _lref, _rval2);
|
||||
// g. Return rval.
|
||||
return _rval2;
|
||||
}
|
||||
|
||||
// 2. Let assignmentPattern be the parse of the source text corresponding to LeftHandSideExpression using AssignmentPattern[?Yield] as the goal symbol.
|
||||
var assignmentPattern = LeftHandSideExpression;
|
||||
|
||||
// 3. Let rref be the result of evaluating AssignmentExpression.
|
||||
var _rref = env.evaluate(AssignmentExpression, strictCode);
|
||||
|
||||
// 4. Let rval be ? GetValue(rref).
|
||||
var _rval = _singletons.Environment.GetValue(realm, _rref);
|
||||
|
||||
// 5. Let status be the result of performing DestructuringAssignmentEvaluation of assignmentPattern using rval as the argument.
|
||||
(0, _index2.DestructuringAssignmentEvaluation)(realm, assignmentPattern, _rval, strictCode, env);
|
||||
|
||||
// 6. ReturnIfAbrupt(status).
|
||||
|
||||
// 7. Return rval.
|
||||
return _rval;
|
||||
}
|
||||
|
||||
// AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
|
||||
// 1. Let lref be the result of evaluating LeftHandSideExpression.
|
||||
var lref = env.evaluate(LeftHandSideExpression, strictCode);
|
||||
// 2. Let lval be ? GetValue(lref).
|
||||
var lval = _singletons.Environment.GetValue(realm, lref);
|
||||
// 3. Let rref be the result of evaluating AssignmentExpression.
|
||||
var rref = env.evaluate(AssignmentExpression, strictCode);
|
||||
// 4. Let rval be ? GetValue(rref).
|
||||
var rval = _singletons.Environment.GetValue(realm, rref);
|
||||
// 5. Let op be the @ where AssignmentOperator is @=.
|
||||
var op = AssignmentOperator.slice(0, -1);
|
||||
// 6. Let r be the result of applying op to lval and rval as if evaluating the expression lval op rval.
|
||||
var r = _singletons.Environment.GetValue(realm, (0, _BinaryExpression.computeBinary)(realm, op, lval, rval, ast.left.loc, ast.right.loc));
|
||||
// 7. Perform ? PutValue(lref, r).
|
||||
_singletons.Properties.PutValue(realm, lref, r);
|
||||
// 8. Return r.
|
||||
return r;
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _BinaryExpression = require("./BinaryExpression.js");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=AssignmentExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/AssignmentExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/AssignmentExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
build/node_modules/prepack/lib/evaluators/AwaitExpression.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/AwaitExpression.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
throw new _errors.FatalError("TODO #712: AwaitExpression");
|
||||
};
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
//# sourceMappingURL=AwaitExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/AwaitExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/AwaitExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/AwaitExpression.js"],"names":["ast","strictCode","env","realm"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,QAAM,uBAAe,4BAAf,CAAN;AACD,C;;AAXD","file":"AwaitExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { FatalError } from \"../errors.js\";\nimport type { Value } from \"../values/index.js\";\nimport type { BabelNodeAwaitExpression } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeAwaitExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n throw new FatalError(\"TODO #712: AwaitExpression\");\n}\n"]}
|
||||
137
build/node_modules/prepack/lib/evaluators/BinaryExpression.js
generated
vendored
Normal file
137
build/node_modules/prepack/lib/evaluators/BinaryExpression.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// evaluate left
|
||||
var lref = env.evaluate(ast.left, strictCode);
|
||||
var lval = _singletons.Environment.GetValue(realm, lref);
|
||||
|
||||
// evaluate right
|
||||
var rref = env.evaluate(ast.right, strictCode);
|
||||
var rval = _singletons.Environment.GetValue(realm, rref);
|
||||
|
||||
return computeBinary(realm, ast.operator, lval, rval, ast.left.loc, ast.right.loc, ast.loc);
|
||||
};
|
||||
|
||||
exports.getPureBinaryOperationResultType = getPureBinaryOperationResultType;
|
||||
exports.computeBinary = computeBinary;
|
||||
|
||||
var _index = require("../domains/index.js");
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _index2 = require("../values/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var unknownValueOfOrToString = "might be an object with an unknown valueOf or toString or Symbol.toPrimitive method";
|
||||
|
||||
// Returns result type if binary operation is pure (terminates, does not throw exception, does not read or write heap), otherwise undefined.
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function getPureBinaryOperationResultType(realm, op, lval, rval, lloc, rloc) {
|
||||
function reportErrorIfNotPure(purityTest, typeIfPure) {
|
||||
var leftPure = purityTest(realm, lval);
|
||||
var rightPure = purityTest(realm, rval);
|
||||
if (leftPure && rightPure) return typeIfPure;
|
||||
var loc = !leftPure ? lloc : rloc;
|
||||
var error = new _errors.CompilerDiagnostic(unknownValueOfOrToString, loc, "PP0002", "RecoverableError");
|
||||
if (realm.handleError(error) === "Recover") {
|
||||
// Assume that an unknown value is actually a primitive or otherwise a well behaved object.
|
||||
return typeIfPure;
|
||||
}
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
if (op === "+") {
|
||||
var ltype = _singletons.To.GetToPrimitivePureResultType(realm, lval);
|
||||
var rtype = _singletons.To.GetToPrimitivePureResultType(realm, rval);
|
||||
if (ltype === undefined || rtype === undefined) {
|
||||
var loc = ltype === undefined ? lloc : rloc;
|
||||
var error = new _errors.CompilerDiagnostic(unknownValueOfOrToString, loc, "PP0002", "RecoverableError");
|
||||
if (realm.handleError(error) === "Recover") {
|
||||
// Assume that the unknown value is actually a primitive or otherwise a well behaved object.
|
||||
ltype = lval.getType();
|
||||
rtype = rval.getType();
|
||||
if (ltype === _index2.StringValue || rtype === _index2.StringValue) return _index2.StringValue;
|
||||
if (ltype === _index2.NumberValue && rtype === _index2.NumberValue) return _index2.NumberValue;
|
||||
return _index2.Value;
|
||||
}
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
if (ltype === _index2.StringValue || rtype === _index2.StringValue) return _index2.StringValue;
|
||||
return _index2.NumberValue;
|
||||
} else if (op === "<" || op === ">" || op === ">=" || op === "<=") {
|
||||
return reportErrorIfNotPure(_singletons.To.IsToPrimitivePure.bind(_singletons.To), _index2.BooleanValue);
|
||||
} else if (op === "!=" || op === "==") {
|
||||
var _ltype = lval.getType();
|
||||
var _rtype = rval.getType();
|
||||
if (_ltype === _index2.NullValue || _ltype === _index2.UndefinedValue || _rtype === _index2.NullValue || _rtype === _index2.UndefinedValue) return _index2.BooleanValue;
|
||||
return reportErrorIfNotPure(_singletons.To.IsToPrimitivePure.bind(_singletons.To), _index2.BooleanValue);
|
||||
} else if (op === "===" || op === "!==") {
|
||||
return _index2.BooleanValue;
|
||||
} else if (op === ">>>" || op === "<<" || op === ">>" || op === "&" || op === "|" || op === "^" || op === "**" || op === "%" || op === "/" || op === "*" || op === "-") {
|
||||
return reportErrorIfNotPure(_singletons.To.IsToNumberPure.bind(_singletons.To), _index2.NumberValue);
|
||||
} else if (op === "in" || op === "instanceof") {
|
||||
if (rval.mightNotBeObject()) {
|
||||
var _error2 = new _errors.CompilerDiagnostic("might not be an object, hence the " + op + " operator might throw a TypeError", rloc, "PP0003", "RecoverableError");
|
||||
if (realm.handleError(_error2) === "Recover") {
|
||||
// Assume that the object is actually a well behaved object.
|
||||
return _index2.BooleanValue;
|
||||
}
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
if (!rval.mightNotBeObject()) {
|
||||
// Simple object won't throw here, aren't proxy objects or typed arrays and do not have @@hasInstance properties.
|
||||
if (rval.isSimpleObject()) return _index2.BooleanValue;
|
||||
}
|
||||
var _error = new _errors.CompilerDiagnostic("might be an object that behaves badly for the " + op + " operator", rloc, "PP0004", "RecoverableError");
|
||||
if (realm.handleError(_error) === "Recover") {
|
||||
// Assume that the object is actually a well behaved object.
|
||||
return _index2.BooleanValue;
|
||||
}
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
(0, _invariant2.default)(false, "unimplemented " + op);
|
||||
}
|
||||
|
||||
function computeBinary(realm, op, lval, rval, lloc, rloc, loc) {
|
||||
// partial evaluation shortcut for a particular pattern
|
||||
if (realm.useAbstractInterpretation && (op === "==" || op === "===" || op === "!=" || op === "!==")) {
|
||||
if (!lval.mightNotBeObject() && (rval instanceof _index2.NullValue || rval instanceof _index2.UndefinedValue) || (lval instanceof _index2.NullValue || lval instanceof _index2.UndefinedValue) && !rval.mightNotBeObject()) {
|
||||
return new _index2.BooleanValue(realm, op[0] !== "=");
|
||||
}
|
||||
}
|
||||
|
||||
if (lval instanceof _index2.AbstractValue || rval instanceof _index2.AbstractValue) {
|
||||
// generate error if binary operation might throw or have side effects
|
||||
getPureBinaryOperationResultType(realm, op, lval, rval, lloc, rloc);
|
||||
return _index2.AbstractValue.createFromBinaryOp(realm, op, lval, rval, loc);
|
||||
}
|
||||
|
||||
// ECMA262 12.10.3
|
||||
|
||||
// 5. If Type(rval) is not Object, throw a TypeError exception.
|
||||
if (op === "in" && !(rval instanceof _index2.ObjectValue)) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
|
||||
}
|
||||
(0, _invariant2.default)(lval instanceof _index2.ConcreteValue);
|
||||
(0, _invariant2.default)(rval instanceof _index2.ConcreteValue);
|
||||
return _index.ValuesDomain.computeBinary(realm, op, lval, rval);
|
||||
}
|
||||
//# sourceMappingURL=BinaryExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/BinaryExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/BinaryExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
62
build/node_modules/prepack/lib/evaluators/BlockStatement.js
generated
vendored
Normal file
62
build/node_modules/prepack/lib/evaluators/BlockStatement.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _singletons.Functions.EvaluateStatements(ast.body, blockValue, strictCode, blockEnv, realm);
|
||||
} finally {
|
||||
// 6. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
realm.onDestroyScope(blockEnv);
|
||||
}
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=BlockStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/BlockStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/BlockStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/BlockStatement.js"],"names":["ast","strictCode","env","realm","oldEnv","getRunningContext","lexicalEnvironment","blockEnv","NewDeclarativeEnvironment","BlockDeclarationInstantiation","body","blockValue","directives","directive","value","EvaluateStatements","onDestroyScope"],"mappings":";;;;;;kBAmBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP;AACA,MAAIC,SAASD,MAAME,iBAAN,GAA0BC,kBAAvC;;AAEA;AACA,MAAIC,WAAW,wBAAYC,yBAAZ,CAAsCL,KAAtC,EAA6CC,MAA7C,CAAf;;AAEA;AACA,0BAAYK,6BAAZ,CAA0CN,KAA1C,EAAiDF,UAAjD,EAA6DD,IAAIU,IAAjE,EAAuEH,QAAvE;;AAEA;AACAJ,QAAME,iBAAN,GAA0BC,kBAA1B,GAA+CC,QAA/C;;AAEA,MAAI;AACF;AACA,QAAII,mBAAJ;;AAEA,QAAIX,IAAIY,UAAR,EAAoB;AAAA;AAAA;AAAA;;AAAA;AAClB,6BAAsBZ,IAAIY,UAA1B,8HAAsC;AAAA,cAA7BC,SAA6B;;AACpCF,uBAAa,uBAAgBR,KAAhB,EAAuBU,UAAUC,KAAV,CAAgBA,KAAvC,CAAb;AACD;AAHiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAInB;;AAED,WAAO,sBAAUC,kBAAV,CAA6Bf,IAAIU,IAAjC,EAAuCC,UAAvC,EAAmDV,UAAnD,EAA+DM,QAA/D,EAAyEJ,KAAzE,CAAP;AACD,GAXD,SAWU;AACR;AACAA,UAAME,iBAAN,GAA0BC,kBAA1B,GAA+CF,MAA/C;AACAD,UAAMa,cAAN,CAAqBT,QAArB;AACD;AACF,C;;AAtCD;;AACA","file":"BlockStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { BabelNodeBlockStatement } from \"babel-types\";\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\n\nimport { StringValue, Value } from \"../values/index.js\";\nimport { Environment, Functions } from \"../singletons.js\";\n\n// ECMA262 13.2.13\nexport default function(\n ast: BabelNodeBlockStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // 1. Let oldEnv be the running execution context's LexicalEnvironment.\n let oldEnv = realm.getRunningContext().lexicalEnvironment;\n\n // 2. Let blockEnv be NewDeclarativeEnvironment(oldEnv).\n let blockEnv = Environment.NewDeclarativeEnvironment(realm, oldEnv);\n\n // 3. Perform BlockDeclarationInstantiation(StatementList, blockEnv).\n Environment.BlockDeclarationInstantiation(realm, strictCode, ast.body, blockEnv);\n\n // 4. Set the running execution context's LexicalEnvironment to blockEnv.\n realm.getRunningContext().lexicalEnvironment = blockEnv;\n\n try {\n // 5. Let blockValue be the result of evaluating StatementList.\n let blockValue: void | Value;\n\n if (ast.directives) {\n for (let directive of ast.directives) {\n blockValue = new StringValue(realm, directive.value.value);\n }\n }\n\n return Functions.EvaluateStatements(ast.body, blockValue, strictCode, blockEnv, realm);\n } finally {\n // 6. Set the running execution context's LexicalEnvironment to oldEnv.\n realm.getRunningContext().lexicalEnvironment = oldEnv;\n realm.onDestroyScope(blockEnv);\n }\n}\n"]}
|
||||
12
build/node_modules/prepack/lib/evaluators/BooleanLiteral.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/BooleanLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return new _index.BooleanValue(realm, ast.value);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
//# sourceMappingURL=BooleanLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/BooleanLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/BooleanLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/BooleanLiteral.js"],"names":["ast","strictCode","env","realm","value"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,SAAO,wBAAiBA,KAAjB,EAAwBH,IAAII,KAA5B,CAAP;AACD,C;;AAVD","file":"BooleanLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { BooleanValue } from \"../values/index.js\";\nimport type { BabelNodeBooleanLiteral } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeBooleanLiteral,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n return new BooleanValue(realm, ast.value);\n}\n"]}
|
||||
12
build/node_modules/prepack/lib/evaluators/BreakStatement.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/BreakStatement.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
throw new _completions.BreakCompletion(realm.intrinsics.empty, ast.loc, ast.label && ast.label.name);
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
//# sourceMappingURL=BreakStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/BreakStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/BreakStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/BreakStatement.js"],"names":["ast","strictCode","env","realm","intrinsics","empty","loc","label","name"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,QAAM,iCAAoBA,MAAMC,UAAN,CAAiBC,KAArC,EAA4CL,IAAIM,GAAhD,EAAqDN,IAAIO,KAAJ,IAAaP,IAAIO,KAAJ,CAAUC,IAA5E,CAAN;AACD,C;;AAVD","file":"BreakStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { BreakCompletion } from \"../completions.js\";\nimport type { BabelNodeBreakStatement } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeBreakStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n throw new BreakCompletion(realm.intrinsics.empty, ast.loc, ast.label && ast.label.name);\n}\n"]}
|
||||
240
build/node_modules/prepack/lib/evaluators/CallExpression.js
generated
vendored
Normal file
240
build/node_modules/prepack/lib/evaluators/CallExpression.js
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
if (ast.callee.type === "Super") {
|
||||
return (0, _SuperCall2.default)(ast.arguments, strictCode, env, realm);
|
||||
}
|
||||
|
||||
// ECMA262 12.3.4.1
|
||||
realm.setNextExecutionContextLocation(ast.loc);
|
||||
|
||||
// 1. Let ref be the result of evaluating MemberExpression.
|
||||
var ref = env.evaluate(ast.callee, strictCode);
|
||||
|
||||
// 2. Let func be ? GetValue(ref).
|
||||
var func = _singletons.Environment.GetValue(realm, ref);
|
||||
|
||||
return EvaluateCall(ref, func, ast, strictCode, env, realm);
|
||||
};
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _babelTypes = require("babel-types");
|
||||
|
||||
var t = _interopRequireWildcard(_babelTypes);
|
||||
|
||||
var _SuperCall = require("./SuperCall");
|
||||
|
||||
var _SuperCall2 = _interopRequireDefault(_SuperCall);
|
||||
|
||||
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 }; }
|
||||
|
||||
function callBothFunctionsAndJoinTheirEffects(args, ast, strictCode, env, realm) {
|
||||
var _args = _slicedToArray(args, 3),
|
||||
cond = _args[0],
|
||||
func1 = _args[1],
|
||||
func2 = _args[2];
|
||||
|
||||
(0, _invariant2.default)(cond instanceof _index.AbstractValue && cond.getType() === _index.BooleanValue);
|
||||
(0, _invariant2.default)(_index.Value.isTypeCompatibleWith(func1.getType(), _index.FunctionValue));
|
||||
(0, _invariant2.default)(_index.Value.isTypeCompatibleWith(func2.getType(), _index.FunctionValue));
|
||||
|
||||
var _realm$evaluateForEff = realm.evaluateForEffects(function () {
|
||||
return EvaluateCall(func1, func1, ast, strictCode, env, realm);
|
||||
}),
|
||||
_realm$evaluateForEff2 = _slicedToArray(_realm$evaluateForEff, 5),
|
||||
compl1 = _realm$evaluateForEff2[0],
|
||||
gen1 = _realm$evaluateForEff2[1],
|
||||
bindings1 = _realm$evaluateForEff2[2],
|
||||
properties1 = _realm$evaluateForEff2[3],
|
||||
createdObj1 = _realm$evaluateForEff2[4];
|
||||
|
||||
var _realm$evaluateForEff3 = realm.evaluateForEffects(function () {
|
||||
return EvaluateCall(func2, func2, ast, strictCode, env, realm);
|
||||
}),
|
||||
_realm$evaluateForEff4 = _slicedToArray(_realm$evaluateForEff3, 5),
|
||||
compl2 = _realm$evaluateForEff4[0],
|
||||
gen2 = _realm$evaluateForEff4[1],
|
||||
bindings2 = _realm$evaluateForEff4[2],
|
||||
properties2 = _realm$evaluateForEff4[3],
|
||||
createdObj2 = _realm$evaluateForEff4[4];
|
||||
|
||||
var joinedEffects = _singletons.Join.joinEffects(realm, cond, [compl1, gen1, bindings1, properties1, createdObj1], [compl2, gen2, bindings2, properties2, createdObj2]);
|
||||
var completion = joinedEffects[0];
|
||||
if (completion instanceof _completions.PossiblyNormalCompletion) {
|
||||
// in this case one of the branches may complete abruptly, which means that
|
||||
// not all control flow branches join into one flow at this point.
|
||||
// Consequently we have to continue tracking changes until the point where
|
||||
// all the branches come together into one.
|
||||
completion = realm.composeWithSavedCompletion(completion);
|
||||
}
|
||||
|
||||
// Note that the effects of (non joining) abrupt branches are not included
|
||||
// in joinedEffects, but are tracked separately inside completion.
|
||||
realm.applyEffects(joinedEffects);
|
||||
|
||||
// return or throw completion
|
||||
if (completion instanceof _completions.AbruptCompletion) throw completion;
|
||||
(0, _invariant2.default)(completion instanceof _index.Value);
|
||||
return completion;
|
||||
}
|
||||
|
||||
function EvaluateCall(ref, func, ast, strictCode, env, realm) {
|
||||
function generateRuntimeCall() {
|
||||
var args = [func];
|
||||
|
||||
var _ref = ref instanceof _environment.Reference ? [ref.base, ref.referencedName] : [],
|
||||
_ref2 = _slicedToArray(_ref, 2),
|
||||
thisArg = _ref2[0],
|
||||
propName = _ref2[1];
|
||||
|
||||
if (thisArg instanceof _index.Value) args = [thisArg];
|
||||
if (propName !== undefined && typeof propName !== "string") args.push(propName);
|
||||
args = args.concat((0, _index2.ArgumentListEvaluation)(realm, strictCode, env, ast.arguments));
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var arg = _step.value;
|
||||
|
||||
if (arg !== func) {
|
||||
_singletons.Leak.leakValue(realm, arg, ast.loc);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _index.AbstractValue.createTemporalFromBuildFunction(realm, _index.Value, args, function (nodes) {
|
||||
var callFunc = void 0;
|
||||
var argStart = 1;
|
||||
if (thisArg instanceof _index.Value) {
|
||||
if (typeof propName === "string") {
|
||||
callFunc = t.memberExpression(nodes[0], t.identifier(propName), !t.isValidIdentifier(propName));
|
||||
} else {
|
||||
callFunc = t.memberExpression(nodes[0], nodes[1], true);
|
||||
argStart = 2;
|
||||
}
|
||||
} else {
|
||||
callFunc = nodes[0];
|
||||
}
|
||||
var fun_args = nodes.slice(argStart);
|
||||
return t.callExpression(callFunc, fun_args);
|
||||
});
|
||||
}
|
||||
|
||||
if (func instanceof _index.AbstractValue) {
|
||||
if (!_index.Value.isTypeCompatibleWith(func.getType(), _index.FunctionValue)) {
|
||||
var loc = ast.callee.type === "MemberExpression" ? ast.callee.property.loc : ast.callee.loc;
|
||||
var error = new _errors.CompilerDiagnostic("might not be a function", loc, "PP0005", "RecoverableError");
|
||||
if (realm.handleError(error) === "Fail") throw new _errors.FatalError();
|
||||
} else if (func.kind === "conditional") {
|
||||
return callBothFunctionsAndJoinTheirEffects(func.args, ast, strictCode, env, realm);
|
||||
} else {
|
||||
// Assume that it is a safe function. TODO #705: really?
|
||||
}
|
||||
return generateRuntimeCall();
|
||||
}
|
||||
(0, _invariant2.default)(func instanceof _index.ConcreteValue);
|
||||
|
||||
// 3. If Type(ref) is Reference and IsPropertyReference(ref) is false and GetReferencedName(ref) is "eval", then
|
||||
if (ref instanceof _environment.Reference && !_singletons.Environment.IsPropertyReference(realm, ref) && _singletons.Environment.GetReferencedName(realm, ref) === "eval") {
|
||||
// a. If SameValue(func, %eval%) is true, then
|
||||
if ((0, _index2.SameValue)(realm, func, realm.intrinsics.eval)) {
|
||||
// i. Let argList be ? ArgumentListEvaluation(Arguments).
|
||||
var argList = (0, _index2.ArgumentListEvaluation)(realm, strictCode, env, ast.arguments);
|
||||
// ii. If argList has no elements, return undefined.
|
||||
if (argList.length === 0) return realm.intrinsics.undefined;
|
||||
// iii. Let evalText be the first element of argList.
|
||||
var evalText = argList[0];
|
||||
// iv. If the source code matching this CallExpression is strict code, let strictCaller be true. Otherwise let strictCaller be false.
|
||||
var strictCaller = strictCode;
|
||||
// v. Let evalRealm be the current Realm Record.
|
||||
var evalRealm = realm;
|
||||
// vi. Return ? PerformEval(evalText, evalRealm, strictCaller, true).
|
||||
if (evalText instanceof _index.AbstractValue) {
|
||||
var _loc = ast.arguments[0].loc;
|
||||
var _error = new _errors.CompilerDiagnostic("eval argument must be a known value", _loc, "PP0006", "RecoverableError");
|
||||
if (realm.handleError(_error) === "Fail") throw new _errors.FatalError();
|
||||
// Assume that it is a safe eval with no visible heap changes or abrupt control flow.
|
||||
return generateRuntimeCall();
|
||||
}
|
||||
return _singletons.Functions.PerformEval(realm, evalText, evalRealm, strictCaller, true);
|
||||
}
|
||||
}
|
||||
|
||||
var thisValue = void 0;
|
||||
|
||||
// 4. If Type(ref) is Reference, then
|
||||
if (ref instanceof _environment.Reference) {
|
||||
// a. If IsPropertyReference(ref) is true, then
|
||||
if (_singletons.Environment.IsPropertyReference(realm, ref)) {
|
||||
// i. Let thisValue be GetThisValue(ref).
|
||||
thisValue = (0, _index2.GetThisValue)(realm, ref);
|
||||
} else {
|
||||
// b. Else, the base of ref is an Environment Record
|
||||
// i. Let refEnv be GetBase(ref).
|
||||
var refEnv = _singletons.Environment.GetBase(realm, ref);
|
||||
(0, _invariant2.default)(refEnv instanceof _environment.EnvironmentRecord);
|
||||
|
||||
// ii. Let thisValue be refEnv.WithBaseObject().
|
||||
thisValue = refEnv.WithBaseObject();
|
||||
}
|
||||
} else {
|
||||
// 5. Else Type(ref) is not Reference,
|
||||
// a. Let thisValue be undefined.
|
||||
thisValue = realm.intrinsics.undefined;
|
||||
}
|
||||
|
||||
// 6. Let thisCall be this CallExpression.
|
||||
var thisCall = ast;
|
||||
|
||||
// 7. Let tailCall be IsInTailPosition(thisCall). (See 14.6.1)
|
||||
var tailCall = (0, _index2.IsInTailPosition)(realm, thisCall);
|
||||
|
||||
// 8. Return ? EvaluateDirectCall(func, thisValue, Arguments, tailCall).
|
||||
return (0, _index2.EvaluateDirectCall)(realm, strictCode, env, ref, func, thisValue, ast.arguments, tailCall);
|
||||
}
|
||||
//# sourceMappingURL=CallExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/CallExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/CallExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
82
build/node_modules/prepack/lib/evaluators/CatchClause.js
generated
vendored
Normal file
82
build/node_modules/prepack/lib/evaluators/CatchClause.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm, thrownValue) {
|
||||
(0, _invariant2.default)(thrownValue instanceof _completions.ThrowCompletion, "Metadata isn't a throw completion");
|
||||
|
||||
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
var oldEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// 2. Let catchEnv be NewDeclarativeEnvironment(oldEnv).
|
||||
var catchEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
|
||||
// 3. Let catchEnvRec be catchEnv's EnvironmentRecord.
|
||||
var catchEnvRec = catchEnv.environmentRecord;
|
||||
|
||||
// 4. For each element argName of the BoundNames of CatchParameter, do
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = _singletons.Environment.BoundNames(realm, ast.param)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var argName = _step.value;
|
||||
|
||||
// a. Perform ! catchEnvRec.CreateMutableBinding(argName, false).
|
||||
catchEnvRec.CreateMutableBinding(argName, false);
|
||||
}
|
||||
|
||||
// 5. Set the running execution context's LexicalEnvironment to catchEnv.
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
realm.getRunningContext().lexicalEnvironment = catchEnv;
|
||||
|
||||
try {
|
||||
// 6. Let status be the result of performing BindingInitialization for CatchParameter passing thrownValue and catchEnv as arguments.
|
||||
_singletons.Environment.BindingInitialization(realm, ast.param, thrownValue.value, strictCode, catchEnv);
|
||||
|
||||
// 7. If status is an abrupt completion, then
|
||||
// a. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
// b. Return Completion(status).
|
||||
|
||||
// 8. Let B be the result of evaluating Block.
|
||||
var B = catchEnv.evaluate(ast.body, strictCode);
|
||||
(0, _invariant2.default)(B instanceof _index.Value);
|
||||
|
||||
// 10. Return Completion(B).
|
||||
return B;
|
||||
} finally {
|
||||
// 9. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
realm.onDestroyScope(catchEnv);
|
||||
}
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=CatchClause.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/CatchClause.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/CatchClause.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/CatchClause.js"],"names":["ast","strictCode","env","realm","thrownValue","oldEnv","getRunningContext","lexicalEnvironment","catchEnv","NewDeclarativeEnvironment","catchEnvRec","environmentRecord","BoundNames","param","argName","CreateMutableBinding","BindingInitialization","value","B","evaluate","body","onDestroyScope"],"mappings":";;;;;;kBAoBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKbC,WALa,EAMN;AACP,2BAAUA,mDAAV,EAAkD,mCAAlD;;AAEA;AACA,MAAIC,SAASF,MAAMG,iBAAN,GAA0BC,kBAAvC;;AAEA;AACA,MAAIC,WAAW,wBAAYC,yBAAZ,CAAsCN,KAAtC,EAA6CE,MAA7C,CAAf;;AAEA;AACA,MAAIK,cAAcF,SAASG,iBAA3B;;AAEA;AAZO;AAAA;AAAA;;AAAA;AAaP,yBAAoB,wBAAYC,UAAZ,CAAuBT,KAAvB,EAA8BH,IAAIa,KAAlC,CAApB,8HAA8D;AAAA,UAArDC,OAAqD;;AAC5D;AACAJ,kBAAYK,oBAAZ,CAAiCD,OAAjC,EAA0C,KAA1C;AACD;;AAED;AAlBO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAmBPX,QAAMG,iBAAN,GAA0BC,kBAA1B,GAA+CC,QAA/C;;AAEA,MAAI;AACF;AACA,4BAAYQ,qBAAZ,CAAkCb,KAAlC,EAAyCH,IAAIa,KAA7C,EAAoDT,YAAYa,KAAhE,EAAuEhB,UAAvE,EAAmFO,QAAnF;;AAEA;AACA;AACA;;AAEA;AACA,QAAIU,IAAIV,SAASW,QAAT,CAAkBnB,IAAIoB,IAAtB,EAA4BnB,UAA5B,CAAR;AACA,6BAAUiB,yBAAV;;AAEA;AACA,WAAOA,CAAP;AACD,GAdD,SAcU;AACR;AACAf,UAAMG,iBAAN,GAA0BC,kBAA1B,GAA+CF,MAA/C;AACAF,UAAMkB,cAAN,CAAqBb,QAArB;AACD;AACF,C;;AArDD;;AACA;;AACA;;;;AACA","file":"CatchClause.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { Value } from \"../values/index.js\";\nimport { ThrowCompletion } from \"../completions.js\";\nimport invariant from \"../invariant.js\";\nimport { Environment } from \"../singletons.js\";\nimport type { BabelNodeCatchClause } from \"babel-types\";\n\n// ECAM262 13.15.7\nexport default function(\n ast: BabelNodeCatchClause,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm,\n thrownValue: any\n): Value {\n invariant(thrownValue instanceof ThrowCompletion, \"Metadata isn't a throw completion\");\n\n // 1. Let oldEnv be the running execution context's LexicalEnvironment.\n let oldEnv = realm.getRunningContext().lexicalEnvironment;\n\n // 2. Let catchEnv be NewDeclarativeEnvironment(oldEnv).\n let catchEnv = Environment.NewDeclarativeEnvironment(realm, oldEnv);\n\n // 3. Let catchEnvRec be catchEnv's EnvironmentRecord.\n let catchEnvRec = catchEnv.environmentRecord;\n\n // 4. For each element argName of the BoundNames of CatchParameter, do\n for (let argName of Environment.BoundNames(realm, ast.param)) {\n // a. Perform ! catchEnvRec.CreateMutableBinding(argName, false).\n catchEnvRec.CreateMutableBinding(argName, false);\n }\n\n // 5. Set the running execution context's LexicalEnvironment to catchEnv.\n realm.getRunningContext().lexicalEnvironment = catchEnv;\n\n try {\n // 6. Let status be the result of performing BindingInitialization for CatchParameter passing thrownValue and catchEnv as arguments.\n Environment.BindingInitialization(realm, ast.param, thrownValue.value, strictCode, catchEnv);\n\n // 7. If status is an abrupt completion, then\n // a. Set the running execution context's LexicalEnvironment to oldEnv.\n // b. Return Completion(status).\n\n // 8. Let B be the result of evaluating Block.\n let B = catchEnv.evaluate(ast.body, strictCode);\n invariant(B instanceof Value);\n\n // 10. Return Completion(B).\n return B;\n } finally {\n // 9. Set the running execution context's LexicalEnvironment to oldEnv.\n realm.getRunningContext().lexicalEnvironment = oldEnv;\n realm.onDestroyScope(catchEnv);\n }\n}\n"]}
|
||||
341
build/node_modules/prepack/lib/evaluators/ClassDeclaration.js
generated
vendored
Normal file
341
build/node_modules/prepack/lib/evaluators/ClassDeclaration.js
generated
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.ClassDefinitionEvaluation = ClassDefinitionEvaluation;
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Let status be the result of BindingClassDeclarationEvaluation of this ClassDeclaration.
|
||||
BindingClassDeclarationEvaluation(realm, ast, strictCode, env);
|
||||
|
||||
// 2. ReturnIfAbrupt(status).
|
||||
|
||||
// 3. Return NormalCompletion(empty).
|
||||
return realm.intrinsics.empty;
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _parse = require("../utils/parse.js");
|
||||
|
||||
var _parse2 = _interopRequireDefault(_parse);
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function EvaluateClassHeritage(realm, ClassHeritage, strictCode) {
|
||||
var ref = realm.getRunningContext().lexicalEnvironment.evaluate(ClassHeritage, strictCode);
|
||||
var val = _singletons.Environment.GetValue(realm, ref);
|
||||
if (val instanceof _index.AbstractValue) {
|
||||
var error = new _errors.CompilerDiagnostic("unknown super class", ClassHeritage.loc, "PP0009", "RecoverableError");
|
||||
if (realm.handleError(error) === "Fail") throw new _errors.FatalError();
|
||||
}
|
||||
if (!(val instanceof _index.ObjectValue)) {
|
||||
return null;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// ECMA262 14.5.14
|
||||
function ClassDefinitionEvaluation(realm, ast, className, strictCode, env) {
|
||||
// 1. Let lex be the LexicalEnvironment of the running execution context.
|
||||
var lex = env;
|
||||
|
||||
// 2. Let classScope be NewDeclarativeEnvironment(lex).
|
||||
var classScope = _singletons.Environment.NewDeclarativeEnvironment(realm, lex);
|
||||
var F = void 0;
|
||||
|
||||
try {
|
||||
// 3. Let classScopeEnvRec be classScope’s EnvironmentRecord.
|
||||
var classScopeEnvRec = classScope.environmentRecord;
|
||||
|
||||
// 4. If className is not undefined, then
|
||||
if (className !== undefined) {
|
||||
// a. Perform classScopeEnvRec.CreateImmutableBinding(className, true).
|
||||
classScopeEnvRec.CreateImmutableBinding(className, true);
|
||||
}
|
||||
|
||||
var protoParent = void 0;
|
||||
var constructorParent = void 0;
|
||||
// 5. If ClassHeritage opt is not present, then
|
||||
var ClassHeritage = ast.superClass;
|
||||
if (!ClassHeritage) {
|
||||
// a. Let protoParent be the intrinsic object %ObjectPrototype%.
|
||||
protoParent = realm.intrinsics.ObjectPrototype;
|
||||
|
||||
// b. Let constructorParent be the intrinsic object %FunctionPrototype%.
|
||||
constructorParent = realm.intrinsics.FunctionPrototype;
|
||||
} else {
|
||||
// 6. Else
|
||||
// a. Set the running execution context’s LexicalEnvironment to classScope.
|
||||
realm.getRunningContext().lexicalEnvironment = classScope;
|
||||
var superclass = null;
|
||||
try {
|
||||
// b. Let superclass be the result of evaluating ClassHeritage.
|
||||
superclass = EvaluateClassHeritage(realm, ClassHeritage, strictCode);
|
||||
} finally {
|
||||
// c. Set the running execution context’s LexicalEnvironment to lex.
|
||||
realm.getRunningContext().lexicalEnvironment = lex;
|
||||
}
|
||||
|
||||
// d. ReturnIfAbrupt(superclass).
|
||||
|
||||
// e. If superclass is null, then
|
||||
if (superclass === null) {
|
||||
// i. Let protoParent be null.
|
||||
protoParent = realm.intrinsics.null;
|
||||
|
||||
// ii. Let constructorParent be the intrinsic object %FunctionPrototype%.
|
||||
constructorParent = realm.intrinsics.FunctionPrototype;
|
||||
} else if (!(0, _index2.IsConstructor)(realm, superclass)) {
|
||||
// f. Else if IsConstructor(superclass) is false, throw a TypeError exception.
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, "superclass must be a constructor");
|
||||
} else {
|
||||
// g. Else
|
||||
// i. If superclass has a [[FunctionKind]] internal slot whose value is "generator", throw a TypeError exception.
|
||||
if (superclass instanceof _index.ECMAScriptFunctionValue && superclass.$FunctionKind === "generator") {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, "superclass cannot be a generator");
|
||||
}
|
||||
|
||||
// ii. Let protoParent be Get(superclass, "prototype").
|
||||
protoParent = (0, _index2.Get)(realm, superclass, "prototype");
|
||||
|
||||
// iii. ReturnIfAbrupt(protoParent).
|
||||
|
||||
// iv. If Type(protoParent) is neither Object nor Null, throw a TypeError exception.
|
||||
if (!(protoParent instanceof _index.ObjectValue || protoParent instanceof _index.NullValue)) {
|
||||
if (protoParent instanceof _index.AbstractValue) {
|
||||
var error = new _errors.CompilerDiagnostic("unknown super class prototype", ClassHeritage.loc, "PP0010", "RecoverableError");
|
||||
if (realm.handleError(error) === "Fail") throw new _errors.FatalError();
|
||||
protoParent = realm.intrinsics.ObjectPrototype;
|
||||
} else {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, "protoParent must be an instance of Object or Null");
|
||||
}
|
||||
}
|
||||
|
||||
// v. Let constructorParent be superclass.
|
||||
constructorParent = superclass;
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Let proto be ObjectCreate(protoParent).
|
||||
var proto = _singletons.Create.ObjectCreate(realm, protoParent);
|
||||
|
||||
// react. Check the Flow class paramater annotations, stored in "superTypeParameters"
|
||||
if (realm.react.enabled && realm.react.flowRequired && ast.superTypeParameters) {
|
||||
proto.$SuperTypeParameters = ast.superTypeParameters;
|
||||
}
|
||||
var _constructor = void 0;
|
||||
var ClassBody = [];
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = ast.body.body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var elem = _step.value;
|
||||
|
||||
if (elem.type === "ClassMethod") {
|
||||
ClassBody.push(elem);
|
||||
}
|
||||
}
|
||||
// 8. If ClassBody opt is not present, let constructor be empty.
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ClassBody.length === 0) {
|
||||
_constructor = realm.intrinsics.empty;
|
||||
} else {
|
||||
// 9. Else, let constructor be ConstructorMethod of ClassBody.
|
||||
_constructor = (0, _index2.ConstructorMethod)(realm, ClassBody);
|
||||
}
|
||||
|
||||
// 10. If constructor is empty, then,
|
||||
if (_constructor instanceof _index.EmptyValue) {
|
||||
var constructorFile = void 0;
|
||||
// a. If ClassHeritage opt is present, then
|
||||
if (ast.superClass) {
|
||||
// i. Let constructor be the result of parsing the source text
|
||||
// constructor(... args){ super (...args);}
|
||||
// using the syntactic grammar with the goal symbol MethodDefinition.
|
||||
constructorFile = (0, _parse2.default)(realm, "class NeedClassForParsing { constructor(... args){ super (...args);} }", "");
|
||||
} else {
|
||||
// b. Else,
|
||||
// i. Let constructor be the result of parsing the source text
|
||||
// constructor( ){ }
|
||||
// using the syntactic grammar with the goal symbol MethodDefinition.
|
||||
constructorFile = (0, _parse2.default)(realm, "class NeedClassForParsing { constructor( ){ } }", "");
|
||||
}
|
||||
|
||||
var _constructorFile = constructorFile,
|
||||
_constructorFile$prog = _slicedToArray(_constructorFile.program.body, 1),
|
||||
classDeclaration = _constructorFile$prog[0];
|
||||
|
||||
(0, _invariant2.default)(classDeclaration.type === "ClassDeclaration");
|
||||
var _ref = classDeclaration,
|
||||
body = _ref.body;
|
||||
|
||||
(0, _invariant2.default)(body.body[0].type === "ClassMethod");
|
||||
_constructor = body.body[0];
|
||||
}
|
||||
|
||||
// 11. Set the running execution context’s LexicalEnvironment to classScope.
|
||||
realm.getRunningContext().lexicalEnvironment = classScope;
|
||||
|
||||
try {
|
||||
// 12. Let constructorInfo be the result of performing DefineMethod for constructor with arguments proto and constructorParent as the optional functionPrototype argument.
|
||||
var constructorInfo = _singletons.Functions.DefineMethod(realm, _constructor, proto, env, strictCode, constructorParent);
|
||||
|
||||
// 13. Assert: constructorInfo is not an abrupt completion.
|
||||
|
||||
// 14. Let F be constructorInfo.[[closure]]
|
||||
F = constructorInfo.$Closure;
|
||||
|
||||
// 15. If ClassHeritage opt is present, set F’s [[ConstructorKind]] internal slot to "derived".
|
||||
if (ast.superClass) {
|
||||
F.$ConstructorKind = "derived";
|
||||
}
|
||||
|
||||
// 16. Perform MakeConstructor(F, false, proto).
|
||||
(0, _index2.MakeConstructor)(realm, F, false, proto);
|
||||
|
||||
// 17. Perform MakeClassConstructor(F).
|
||||
(0, _index2.MakeClassConstructor)(realm, F);
|
||||
|
||||
// 18. Perform CreateMethodProperty(proto, "constructor", F).
|
||||
_singletons.Create.CreateMethodProperty(realm, proto, "constructor", F);
|
||||
|
||||
var methods = void 0;
|
||||
// 19. If ClassBody opt is not present, let methods be a new empty List.
|
||||
if (ClassBody.length === 0) {
|
||||
methods = [];
|
||||
} else {
|
||||
// 20. Else, let methods be NonConstructorMethodDefinitions of ClassBody.
|
||||
methods = (0, _index2.NonConstructorMethodDefinitions)(realm, ClassBody);
|
||||
}
|
||||
|
||||
// 21. For each ClassElement m in order from methods
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = methods[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var m = _step2.value;
|
||||
|
||||
// a. If IsStatic of m is false, then
|
||||
if (!(0, _index2.IsStatic)(m)) {
|
||||
// Let status be the result of performing PropertyDefinitionEvaluation for m with arguments proto and false.
|
||||
_singletons.Properties.PropertyDefinitionEvaluation(realm, m, proto, env, strictCode, false);
|
||||
} else {
|
||||
// Else,
|
||||
// Let status be the result of performing PropertyDefinitionEvaluation for m with arguments F and false.
|
||||
_singletons.Properties.PropertyDefinitionEvaluation(realm, m, F, env, strictCode, false);
|
||||
}
|
||||
// c. If status is an abrupt completion, then
|
||||
// i. Set the running execution context's LexicalEnvironment to lex.
|
||||
// ii. Return Completion(status).
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// 22. Set the running execution context’s LexicalEnvironment to lex.
|
||||
realm.getRunningContext().lexicalEnvironment = lex;
|
||||
}
|
||||
|
||||
// 23. If className is not undefined, then
|
||||
if (className !== undefined) {
|
||||
// Perform classScopeEnvRec.InitializeBinding(className, F).
|
||||
classScopeEnvRec.InitializeBinding(className, F);
|
||||
}
|
||||
} finally {
|
||||
realm.onDestroyScope(classScope);
|
||||
}
|
||||
// Return F.
|
||||
return F;
|
||||
}
|
||||
|
||||
// ECMA2 14.5.15
|
||||
function BindingClassDeclarationEvaluation(realm, ast, strictCode, env) {
|
||||
// ClassDeclaration : class BindingIdentifier ClassTail
|
||||
if (ast.id) {
|
||||
// 1. Let className be StringValue of BindingIdentifier.
|
||||
var className = ast.id.name;
|
||||
|
||||
// 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with argument className.
|
||||
var value = ClassDefinitionEvaluation(realm, ast, className, strictCode, env);
|
||||
|
||||
// 3. ReturnIfAbrupt(value).
|
||||
|
||||
// 4. Let hasNameProperty be HasOwnProperty(value, "name").
|
||||
var hasNameProperty = (0, _index2.HasOwnProperty)(realm, value, "name");
|
||||
|
||||
// 5. ReturnIfAbrupt(hasNameProperty).
|
||||
|
||||
// 6. If hasNameProperty is false, then perform SetFunctionName(value, className).
|
||||
if (hasNameProperty === false) {
|
||||
_singletons.Functions.SetFunctionName(realm, value, className);
|
||||
}
|
||||
|
||||
// 7. Let env be the running execution context’s LexicalEnvironment.
|
||||
|
||||
// 8. Let status be InitializeBoundName(className, value, env).
|
||||
_singletons.Environment.InitializeBoundName(realm, className, value, env);
|
||||
|
||||
// 9. ReturnIfAbrupt(status).
|
||||
|
||||
// 10. Return value.
|
||||
return value;
|
||||
} else {
|
||||
// ClassDeclaration : class ClassTail
|
||||
// 1. Return the result of ClassDefinitionEvaluation of ClassTail with argument undefined.
|
||||
return ClassDefinitionEvaluation(realm, ast, undefined, strictCode, env);
|
||||
}
|
||||
}
|
||||
|
||||
// ECMA262 14.5.16
|
||||
//# sourceMappingURL=ClassDeclaration.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ClassDeclaration.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ClassDeclaration.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
42
build/node_modules/prepack/lib/evaluators/ClassExpression.js
generated
vendored
Normal file
42
build/node_modules/prepack/lib/evaluators/ClassExpression.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. If BindingIdentifieropt is not present, let className be undefined.
|
||||
var className = void 0;
|
||||
// 2. Else, let className be StringValue of BindingIdentifier.
|
||||
if (ast.id) {
|
||||
className = ast.id.name;
|
||||
}
|
||||
// 3. Let value be the result of ClassDefinitionEvaluation of ClassTail with argument className.
|
||||
var value = (0, _ClassDeclaration.ClassDefinitionEvaluation)(realm, ast, className, strictCode, env);
|
||||
|
||||
// 4. ReturnIfAbrupt(value).
|
||||
|
||||
// 5. If className is not undefined, then
|
||||
if (className) {
|
||||
// a. Let hasNameProperty be HasOwnProperty(value, "name").
|
||||
var hasNameProperty = (0, _index.HasOwnProperty)(realm, value, "name");
|
||||
|
||||
// b. ReturnIfAbrupt(hasNameProperty).
|
||||
|
||||
// c. If hasNameProperty is false, then
|
||||
if (!hasNameProperty) {
|
||||
// i. Perform SetFunctionName(value, className).
|
||||
_singletons.Functions.SetFunctionName(realm, value, className);
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Return NormalCompletion(value).
|
||||
return value;
|
||||
};
|
||||
|
||||
var _index = require("../methods/index.js");
|
||||
|
||||
var _ClassDeclaration = require("./ClassDeclaration");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=ClassExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ClassExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ClassExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ClassExpression.js"],"names":["ast","strictCode","env","realm","className","id","name","value","hasNameProperty","SetFunctionName"],"mappings":";;;;;;kBAoBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP;AACA,MAAIC,kBAAJ;AACA;AACA,MAAIJ,IAAIK,EAAR,EAAY;AACVD,gBAAYJ,IAAIK,EAAJ,CAAOC,IAAnB;AACD;AACD;AACA,MAAIC,QAAQ,iDAA0BJ,KAA1B,EAAiCH,GAAjC,EAAsCI,SAAtC,EAAiDH,UAAjD,EAA6DC,GAA7D,CAAZ;;AAEA;;AAEA;AACA,MAAIE,SAAJ,EAAe;AACb;AACA,QAAII,kBAAkB,2BAAeL,KAAf,EAAsBI,KAAtB,EAA6B,MAA7B,CAAtB;;AAEA;;AAEA;AACA,QAAI,CAACC,eAAL,EAAsB;AACpB;AACA,4BAAUC,eAAV,CAA0BN,KAA1B,EAAiCI,KAAjC,EAAwCH,SAAxC;AACD;AACF;;AAED;AACA,SAAOG,KAAP;AACD,C;;AAtCD;;AACA;;AACA","file":"ClassExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport type { BabelNodeClassExpression } from \"babel-types\";\nimport { HasOwnProperty } from \"../methods/index.js\";\nimport { ClassDefinitionEvaluation } from \"./ClassDeclaration\";\nimport { Functions } from \"../singletons.js\";\n\n// ECMA262 14.5.16\nexport default function(\n ast: BabelNodeClassExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // 1. If BindingIdentifieropt is not present, let className be undefined.\n let className;\n // 2. Else, let className be StringValue of BindingIdentifier.\n if (ast.id) {\n className = ast.id.name;\n }\n // 3. Let value be the result of ClassDefinitionEvaluation of ClassTail with argument className.\n let value = ClassDefinitionEvaluation(realm, ast, className, strictCode, env);\n\n // 4. ReturnIfAbrupt(value).\n\n // 5. If className is not undefined, then\n if (className) {\n // a. Let hasNameProperty be HasOwnProperty(value, \"name\").\n let hasNameProperty = HasOwnProperty(realm, value, \"name\");\n\n // b. ReturnIfAbrupt(hasNameProperty).\n\n // c. If hasNameProperty is false, then\n if (!hasNameProperty) {\n // i. Perform SetFunctionName(value, className).\n Functions.SetFunctionName(realm, value, className);\n }\n }\n\n // 6. Return NormalCompletion(value).\n return value;\n}\n"]}
|
||||
36
build/node_modules/prepack/lib/evaluators/ConditionalExpression.js
generated
vendored
Normal file
36
build/node_modules/prepack/lib/evaluators/ConditionalExpression.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var exprRef = env.evaluate(ast.test, strictCode);
|
||||
var exprValue = _singletons.Environment.GetConditionValue(realm, exprRef);
|
||||
|
||||
if (exprValue instanceof _index.ConcreteValue) {
|
||||
if (_singletons.To.ToBoolean(realm, exprValue)) {
|
||||
return env.evaluate(ast.consequent, strictCode);
|
||||
} else {
|
||||
return env.evaluate(ast.alternate, strictCode);
|
||||
}
|
||||
}
|
||||
(0, _invariant2.default)(exprValue instanceof _index.AbstractValue);
|
||||
|
||||
if (!exprValue.mightNotBeTrue()) return env.evaluate(ast.consequent, strictCode);
|
||||
if (!exprValue.mightNotBeFalse()) return env.evaluate(ast.alternate, strictCode);
|
||||
return (0, _IfStatement.evaluateWithAbstractConditional)(exprValue, ast.consequent, ast.alternate, strictCode, env, realm);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _IfStatement = require("./IfStatement.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=ConditionalExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ConditionalExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ConditionalExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ConditionalExpression.js"],"names":["ast","strictCode","env","realm","exprRef","evaluate","test","exprValue","GetConditionValue","ToBoolean","consequent","alternate","mightNotBeTrue","mightNotBeFalse"],"mappings":";;;;;;kBAoBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKM;AACnB,MAAIC,UAAUF,IAAIG,QAAJ,CAAaL,IAAIM,IAAjB,EAAuBL,UAAvB,CAAd;AACA,MAAIM,YAAY,wBAAYC,iBAAZ,CAA8BL,KAA9B,EAAqCC,OAArC,CAAhB;;AAEA,MAAIG,yCAAJ,EAAwC;AACtC,QAAI,eAAGE,SAAH,CAAaN,KAAb,EAAoBI,SAApB,CAAJ,EAAoC;AAClC,aAAOL,IAAIG,QAAJ,CAAaL,IAAIU,UAAjB,EAA6BT,UAA7B,CAAP;AACD,KAFD,MAEO;AACL,aAAOC,IAAIG,QAAJ,CAAaL,IAAIW,SAAjB,EAA4BV,UAA5B,CAAP;AACD;AACF;AACD,2BAAUM,yCAAV;;AAEA,MAAI,CAACA,UAAUK,cAAV,EAAL,EAAiC,OAAOV,IAAIG,QAAJ,CAAaL,IAAIU,UAAjB,EAA6BT,UAA7B,CAAP;AACjC,MAAI,CAACM,UAAUM,eAAV,EAAL,EAAkC,OAAOX,IAAIG,QAAJ,CAAaL,IAAIW,SAAjB,EAA4BV,UAA5B,CAAP;AAClC,SAAO,kDAAgCM,SAAhC,EAA2CP,IAAIU,UAA/C,EAA2DV,IAAIW,SAA/D,EAA0EV,UAA1E,EAAsFC,GAAtF,EAA2FC,KAA3F,CAAP;AACD,C;;AA7BD;;AAEA;;AACA;;AAEA","file":"ConditionalExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { AbstractValue, ConcreteValue, Value } from \"../values/index.js\";\nimport type { Reference } from \"../environment.js\";\nimport { evaluateWithAbstractConditional } from \"./IfStatement.js\";\nimport { Environment, To } from \"../singletons.js\";\nimport type { BabelNodeConditionalExpression } from \"babel-types\";\nimport invariant from \"../invariant.js\";\nimport type { Realm } from \"../realm.js\";\n\nexport default function(\n ast: BabelNodeConditionalExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value | Reference {\n let exprRef = env.evaluate(ast.test, strictCode);\n let exprValue = Environment.GetConditionValue(realm, exprRef);\n\n if (exprValue instanceof ConcreteValue) {\n if (To.ToBoolean(realm, exprValue)) {\n return env.evaluate(ast.consequent, strictCode);\n } else {\n return env.evaluate(ast.alternate, strictCode);\n }\n }\n invariant(exprValue instanceof AbstractValue);\n\n if (!exprValue.mightNotBeTrue()) return env.evaluate(ast.consequent, strictCode);\n if (!exprValue.mightNotBeFalse()) return env.evaluate(ast.alternate, strictCode);\n return evaluateWithAbstractConditional(exprValue, ast.consequent, ast.alternate, strictCode, env, realm);\n}\n"]}
|
||||
12
build/node_modules/prepack/lib/evaluators/ContinueStatement.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/ContinueStatement.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
throw new _completions.ContinueCompletion(realm.intrinsics.empty, ast.loc, ast.label && ast.label.name);
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
//# sourceMappingURL=ContinueStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ContinueStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ContinueStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ContinueStatement.js"],"names":["ast","strictCode","env","realm","intrinsics","empty","loc","label","name"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,QAAM,oCAAuBA,MAAMC,UAAN,CAAiBC,KAAxC,EAA+CL,IAAIM,GAAnD,EAAwDN,IAAIO,KAAJ,IAAaP,IAAIO,KAAJ,CAAUC,IAA/E,CAAN;AACD,C;;AAVD","file":"ContinueStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { ContinueCompletion } from \"../completions.js\";\nimport type { BabelNodeContinueStatement } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeContinueStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n throw new ContinueCompletion(realm.intrinsics.empty, ast.loc, ast.label && ast.label.name);\n}\n"]}
|
||||
20
build/node_modules/prepack/lib/evaluators/Directive.js
generated
vendored
Normal file
20
build/node_modules/prepack/lib/evaluators/Directive.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var r = env.evaluate(ast.value, strictCode);
|
||||
(0, _invariant2.default)(r instanceof _index.Value);
|
||||
return r;
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=Directive.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/Directive.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/Directive.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/Directive.js"],"names":["ast","strictCode","env","realm","r","evaluate","value"],"mappings":";;;;;;kBAiBe,UAASA,GAAT,EAAkCC,UAAlC,EAAuDC,GAAvD,EAAgFC,KAAhF,EAAqG;AAClH,MAAIC,IAAIF,IAAIG,QAAJ,CAAaL,IAAIM,KAAjB,EAAwBL,UAAxB,CAAR;AACA,2BAAUG,yBAAV;AACA,SAAOA,CAAP;AACD,C;;AARD;;AAEA","file":"Directive.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { Value } from \"../values/index.js\";\nimport type { BabelNodeDirective } from \"babel-types\";\nimport invariant from \"../invariant.js\";\n\nexport default function(ast: BabelNodeDirective, strictCode: boolean, env: LexicalEnvironment, realm: Realm): Value {\n let r = env.evaluate(ast.value, strictCode);\n invariant(r instanceof Value);\n return r;\n}\n"]}
|
||||
17
build/node_modules/prepack/lib/evaluators/DirectiveLiteral.js
generated
vendored
Normal file
17
build/node_modules/prepack/lib/evaluators/DirectiveLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _StringLiteral = require("./StringLiteral");
|
||||
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_StringLiteral).default;
|
||||
}
|
||||
});
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=DirectiveLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/DirectiveLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/DirectiveLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/DirectiveLiteral.js"],"names":["default"],"mappings":";;;;;;;;;;;kDAWSA,O","file":"DirectiveLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nexport { default } from \"./StringLiteral\";\n"]}
|
||||
17
build/node_modules/prepack/lib/evaluators/DoExpression.js
generated
vendored
Normal file
17
build/node_modules/prepack/lib/evaluators/DoExpression.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _BlockStatement = require("./BlockStatement.js");
|
||||
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_BlockStatement).default;
|
||||
}
|
||||
});
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=DoExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/DoExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/DoExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/DoExpression.js"],"names":["default"],"mappings":";;;;;;;;;;;mDAWSA,O","file":"DoExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nexport { default } from \"./BlockStatement.js\";\n"]}
|
||||
121
build/node_modules/prepack/lib/evaluators/DoWhileStatement.js
generated
vendored
Normal file
121
build/node_modules/prepack/lib/evaluators/DoWhileStatement.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm, labelSet) {
|
||||
var body = ast.body,
|
||||
test = ast.test;
|
||||
|
||||
// 1. Let V be undefined.
|
||||
|
||||
var V = realm.intrinsics.undefined;
|
||||
|
||||
// 2. Repeat
|
||||
var resultOrDiagnostic = realm.evaluateWithUndoForDiagnostic(function () {
|
||||
while (true) {
|
||||
// a. Let stmt be the result of evaluating Statement.
|
||||
var stmt = env.evaluateCompletion(body, strictCode);
|
||||
//todo: check if stmt is a PossiblyNormalCompletion and defer to fixpoint computation below
|
||||
(0, _invariant2.default)(stmt instanceof _index.Value || stmt instanceof _completions.AbruptCompletion);
|
||||
|
||||
// b. If LoopContinues(stmt, labelSet) is false, return Completion(UpdateEmpty(stmt, V)).
|
||||
if ((0, _ForOfStatement.LoopContinues)(realm, stmt, labelSet) === false) {
|
||||
(0, _invariant2.default)(stmt instanceof _completions.AbruptCompletion);
|
||||
// ECMA262 13.1.7
|
||||
if (stmt instanceof _completions.BreakCompletion) {
|
||||
if (!stmt.target) return (0, _index2.UpdateEmpty)(realm, stmt, V).value;
|
||||
}
|
||||
throw (0, _index2.UpdateEmpty)(realm, stmt, V);
|
||||
}
|
||||
|
||||
// c. If stmt.[[Value]] is not empty, let V be stmt.[[Value]].
|
||||
var resultValue = (0, _ForOfStatement.InternalGetResultValue)(realm, stmt);
|
||||
if (!(resultValue instanceof _index.EmptyValue)) V = resultValue;
|
||||
|
||||
// d. Let exprRef be the result of evaluating Expression.
|
||||
var exprRef = env.evaluate(test, strictCode);
|
||||
|
||||
// e. Let exprValue be ? GetValue(exprRef).
|
||||
var exprValue = _singletons.Environment.GetConditionValue(realm, exprRef);
|
||||
|
||||
// f. If ToBoolean(exprValue) is false, return NormalCompletion(V).
|
||||
if (_singletons.To.ToBooleanPartial(realm, exprValue) === false) return V;
|
||||
}
|
||||
(0, _invariant2.default)(false);
|
||||
});
|
||||
if (resultOrDiagnostic instanceof _index.Value) return resultOrDiagnostic;
|
||||
|
||||
// If we get here then unrolling the loop did not work, possibly because the value of the loop condition is not known,
|
||||
// so instead try to compute a fixpoint for it
|
||||
var ftest = function ftest() {
|
||||
var exprRef = env.evaluate(test, strictCode);
|
||||
return _singletons.Environment.GetConditionValue(realm, exprRef);
|
||||
};
|
||||
var fbody = function fbody() {
|
||||
return env.evaluateCompletion(body, strictCode);
|
||||
};
|
||||
var effects = realm.evaluateForFixpointEffects(ftest, fbody);
|
||||
if (effects !== undefined) {
|
||||
var _effects = _slicedToArray(effects, 2),
|
||||
outsideEffects = _effects[0],
|
||||
insideEffects = _effects[1];
|
||||
|
||||
var _outsideEffects = _slicedToArray(outsideEffects, 1),
|
||||
rval = _outsideEffects[0];
|
||||
|
||||
var _insideEffects = _slicedToArray(insideEffects, 2),
|
||||
bodyGenerator = _insideEffects[1];
|
||||
|
||||
realm.applyEffects(outsideEffects);
|
||||
var exprRef = env.evaluate(test, strictCode);
|
||||
var exprValue = _singletons.Environment.GetValue(realm, exprRef);
|
||||
(0, _invariant2.default)(exprValue instanceof _index.AbstractValue);
|
||||
var cond = bodyGenerator.derive(exprValue.types, exprValue.values, [exprValue], function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 1),
|
||||
n = _ref2[0];
|
||||
|
||||
return n;
|
||||
}, {
|
||||
skipInvariant: true
|
||||
});
|
||||
var generator = realm.generator;
|
||||
(0, _invariant2.default)(generator !== undefined);
|
||||
generator.emitDoWhileStatement(cond, bodyGenerator);
|
||||
(0, _invariant2.default)(rval instanceof _index.Value, "todo: handle loops that throw exceptions or return");
|
||||
return rval;
|
||||
}
|
||||
|
||||
// If we get here the fixpoint computation failed as well. Report the diagnostic from the unrolling and throw.
|
||||
realm.handleError(resultOrDiagnostic);
|
||||
throw new _errors.FatalError();
|
||||
};
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _ForOfStatement = require("./ForOfStatement.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=DoWhileStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/DoWhileStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/DoWhileStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
build/node_modules/prepack/lib/evaluators/EmptyStatement.js
generated
vendored
Normal file
10
build/node_modules/prepack/lib/evaluators/EmptyStatement.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return realm.intrinsics.empty;
|
||||
};
|
||||
//# sourceMappingURL=EmptyStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/EmptyStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/EmptyStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/EmptyStatement.js"],"names":["ast","strictCode","env","realm","intrinsics","empty"],"mappings":";;;;;;kBAgBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,SAAOA,MAAMC,UAAN,CAAiBC,KAAxB;AACD,C","file":"EmptyStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport type { BabelNodeEmptyStatement } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeEmptyStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n return realm.intrinsics.empty;\n}\n"]}
|
||||
17
build/node_modules/prepack/lib/evaluators/ExpressionStatement.js
generated
vendored
Normal file
17
build/node_modules/prepack/lib/evaluators/ExpressionStatement.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// ECMA262 13.5.1
|
||||
// 1. Let exprRef be the result of evaluating Expression.
|
||||
var exprRef = env.evaluate(ast.expression, strictCode);
|
||||
|
||||
// 2. Return ? GetValue(exprRef).
|
||||
return _singletons.Environment.GetValue(realm, exprRef);
|
||||
};
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=ExpressionStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ExpressionStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ExpressionStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ExpressionStatement.js"],"names":["ast","strictCode","env","realm","exprRef","evaluate","expression","GetValue"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP;AACA;AACA,MAAIC,UAAUF,IAAIG,QAAJ,CAAaL,IAAIM,UAAjB,EAA6BL,UAA7B,CAAd;;AAEA;AACA,SAAO,wBAAYM,QAAZ,CAAqBJ,KAArB,EAA4BC,OAA5B,CAAP;AACD,C;;AAfD","file":"ExpressionStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { Environment } from \"../singletons.js\";\nimport type { BabelNodeExpressionStatement } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeExpressionStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // ECMA262 13.5.1\n // 1. Let exprRef be the result of evaluating Expression.\n let exprRef = env.evaluate(ast.expression, strictCode);\n\n // 2. Return ? GetValue(exprRef).\n return Environment.GetValue(realm, exprRef);\n}\n"]}
|
||||
20
build/node_modules/prepack/lib/evaluators/File.js
generated
vendored
Normal file
20
build/node_modules/prepack/lib/evaluators/File.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var r = env.evaluate(ast.program, strictCode);
|
||||
(0, _invariant2.default)(r instanceof _index.Value);
|
||||
return r;
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=File.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/File.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/File.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/File.js"],"names":["ast","strictCode","env","realm","r","evaluate","program"],"mappings":";;;;;;kBAiBe,UAASA,GAAT,EAA6BC,UAA7B,EAAkDC,GAAlD,EAA2EC,KAA3E,EAAgG;AAC7G,MAAIC,IAAIF,IAAIG,QAAJ,CAAaL,IAAIM,OAAjB,EAA0BL,UAA1B,CAAR;AACA,2BAAUG,yBAAV;AACA,SAAOA,CAAP;AACD,C;;AARD;;AAEA","file":"File.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { Value } from \"../values/index.js\";\nimport type { BabelNodeFile } from \"babel-types\";\nimport invariant from \"../invariant.js\";\n\nexport default function(ast: BabelNodeFile, strictCode: boolean, env: LexicalEnvironment, realm: Realm): Value {\n let r = env.evaluate(ast.program, strictCode);\n invariant(r instanceof Value);\n return r;\n}\n"]}
|
||||
275
build/node_modules/prepack/lib/evaluators/ForInStatement.js
generated
vendored
Normal file
275
build/node_modules/prepack/lib/evaluators/ForInStatement.js
generated
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm, labelSet) {
|
||||
var left = ast.left,
|
||||
right = ast.right,
|
||||
body = ast.body;
|
||||
|
||||
|
||||
function reportErrorAndThrowIfNotConcrete(val, loc) {
|
||||
if (val instanceof _index2.AbstractValue) reportError(realm, loc);
|
||||
}
|
||||
|
||||
try {
|
||||
if (left.type === "VariableDeclaration") {
|
||||
if (left.kind === "var") {
|
||||
// for (var ForBinding in Expression) Statement
|
||||
// 1. Let keyResult be ? ForIn/OfHeadEvaluation(« », Expression, enumerate).
|
||||
var keyResult = (0, _ForOfStatement.ForInOfHeadEvaluation)(realm, env, [], right, "enumerate", strictCode);
|
||||
if (keyResult.isPartialObject() && keyResult.isSimpleObject()) {
|
||||
return emitResidualLoopIfSafe(ast, strictCode, env, realm, left, right, keyResult, body);
|
||||
}
|
||||
reportErrorAndThrowIfNotConcrete(keyResult, right.loc);
|
||||
(0, _invariant2.default)(keyResult instanceof _index2.ObjectValue);
|
||||
|
||||
// 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, varBinding, labelSet).
|
||||
return (0, _ForOfStatement.ForInOfBodyEvaluation)(realm, env, left.declarations[0].id, body, keyResult, "varBinding", labelSet, strictCode);
|
||||
} else {
|
||||
// for (ForDeclaration in Expression) Statement
|
||||
// 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, Expression, enumerate).
|
||||
var _keyResult = (0, _ForOfStatement.ForInOfHeadEvaluation)(realm, env, _singletons.Environment.BoundNames(realm, left), right, "enumerate", strictCode);
|
||||
reportErrorAndThrowIfNotConcrete(_keyResult, right.loc);
|
||||
(0, _invariant2.default)(_keyResult instanceof _index2.ObjectValue);
|
||||
|
||||
// 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, lexicalBinding, labelSet).
|
||||
return (0, _ForOfStatement.ForInOfBodyEvaluation)(realm, env, left, body, _keyResult, "lexicalBinding", labelSet, strictCode);
|
||||
}
|
||||
} else {
|
||||
// for (LeftHandSideExpression in Expression) Statement
|
||||
// 1. Let keyResult be ? ForIn/OfHeadEvaluation(« », Expression, enumerate).
|
||||
var _keyResult2 = (0, _ForOfStatement.ForInOfHeadEvaluation)(realm, env, [], right, "enumerate", strictCode);
|
||||
reportErrorAndThrowIfNotConcrete(_keyResult2, right.loc);
|
||||
(0, _invariant2.default)(_keyResult2 instanceof _index2.ObjectValue);
|
||||
|
||||
// 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, keyResult, assignment, labelSet).
|
||||
return (0, _ForOfStatement.ForInOfBodyEvaluation)(realm, env, left, body, _keyResult2, "assignment", labelSet, strictCode);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof _completions.BreakCompletion) {
|
||||
if (!e.target) return (0, _index.UpdateEmpty)(realm, e, realm.intrinsics.undefined).value;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _ForOfStatement = require("./ForOfStatement.js");
|
||||
|
||||
var _index = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _index2 = require("../values/index.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 }; }
|
||||
|
||||
// helper func to report error
|
||||
function reportError(realm, loc) {
|
||||
var error = new _errors.CompilerDiagnostic("for in loops over unknown objects are not yet supported", loc, "PP0013", "FatalError");
|
||||
realm.handleError(error);
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
|
||||
// ECMA262 13.7.5.11
|
||||
|
||||
|
||||
function emitResidualLoopIfSafe(ast, strictCode, env, realm, lh, obexpr, ob, body) {
|
||||
(0, _invariant2.default)(ob.isSimpleObject());
|
||||
var oldEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
var blockEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
realm.getRunningContext().lexicalEnvironment = blockEnv;
|
||||
try {
|
||||
var envRec = blockEnv.environmentRecord;
|
||||
(0, _invariant2.default)(envRec instanceof _environment.DeclarativeEnvironmentRecord, "expected declarative environment record");
|
||||
var absStr = _index2.AbstractValue.createFromType(realm, _index2.StringValue);
|
||||
var boundName = void 0;
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = _singletons.Environment.BoundNames(realm, lh)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var n = _step.value;
|
||||
|
||||
(0, _invariant2.default)(boundName === undefined);
|
||||
boundName = t.identifier(n);
|
||||
envRec.CreateMutableBinding(n, false);
|
||||
envRec.InitializeBinding(n, absStr);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _realm$evaluateNodeFo = realm.evaluateNodeForEffects(body, strictCode, blockEnv),
|
||||
_realm$evaluateNodeFo2 = _slicedToArray(_realm$evaluateNodeFo, 5),
|
||||
compl = _realm$evaluateNodeFo2[0],
|
||||
gen = _realm$evaluateNodeFo2[1],
|
||||
bindings = _realm$evaluateNodeFo2[2],
|
||||
properties = _realm$evaluateNodeFo2[3],
|
||||
createdObj = _realm$evaluateNodeFo2[4];
|
||||
|
||||
if (compl instanceof _index2.Value && gen.empty() && bindings.size === 0 && properties.size === 1) {
|
||||
(0, _invariant2.default)(createdObj.size === 0); // or there will be more than one property
|
||||
var targetObject = void 0;
|
||||
var sourceObject = void 0;
|
||||
properties.forEach(function (desc, key, map) {
|
||||
if (key.object.unknownProperty === key) {
|
||||
targetObject = key.object;
|
||||
(0, _invariant2.default)(desc !== undefined);
|
||||
var sourceValue = desc.value;
|
||||
if (sourceValue instanceof _index2.AbstractValue) {
|
||||
// because sourceValue was written to key.object.unknownProperty it must be that
|
||||
var cond = sourceValue.args[0];
|
||||
// and because the write always creates a value of this shape
|
||||
(0, _invariant2.default)(cond instanceof _index2.AbstractValue && cond.kind === "template for property name condition");
|
||||
if (sourceValue.args[2] instanceof _index2.UndefinedValue) {
|
||||
// check that the value that was assigned itself came from
|
||||
// an expression of the form sourceObject[absStr].
|
||||
var mem = sourceValue.args[1];
|
||||
while (mem instanceof _index2.AbstractValue) {
|
||||
if (mem.kind === "sentinel member expression" && mem.args[0] instanceof _index2.ObjectValue && mem.args[1] === absStr) {
|
||||
sourceObject = mem.args[0];
|
||||
break;
|
||||
}
|
||||
// check if mem is a test for absStr being equal to a known property
|
||||
// if so skip over it until we get to the expression of the form sourceObject[absStr].
|
||||
var condition = mem.args[0];
|
||||
if (condition instanceof _index2.AbstractValue && condition.kind === "check for known property") {
|
||||
if (condition.args[0] === absStr) {
|
||||
mem = mem.args[2];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (targetObject instanceof _index2.ObjectValue && sourceObject !== undefined) {
|
||||
var o = ob;
|
||||
if (ob instanceof _index2.AbstractObjectValue && !ob.values.isTop() && ob.values.getElements().size === 1) {
|
||||
// Note that it is not safe, in general, to extract a concrete object from the values domain of
|
||||
// an abstract object. We can get away with it here only because the concrete object does not
|
||||
// escape the code below and is thus never referenced directly in generated code because of this logic.
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = ob.values.getElements()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var oe = _step2.value;
|
||||
o = oe;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var generator = realm.generator;
|
||||
(0, _invariant2.default)(generator !== undefined);
|
||||
// make target object simple and partial, so that it returns a fully
|
||||
// abstract value for every property it is queried for.
|
||||
targetObject.makeSimple();
|
||||
targetObject.makePartial();
|
||||
if (sourceObject === o) {
|
||||
// Known enumerable properties of sourceObject can become known properties of targetObject.
|
||||
(0, _invariant2.default)(sourceObject.isPartialObject());
|
||||
sourceObject.makeNotPartial();
|
||||
// EnumerableOwnProperties is sufficient because sourceObject is simple
|
||||
var keyValPairs = (0, _index.EnumerableOwnProperties)(realm, sourceObject, "key+value");
|
||||
sourceObject.makePartial();
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = keyValPairs[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var keyVal = _step3.value;
|
||||
|
||||
(0, _invariant2.default)(keyVal instanceof _index2.ArrayValue);
|
||||
var key = keyVal.$Get("0", keyVal);
|
||||
var val = keyVal.$Get("1", keyVal);
|
||||
(0, _invariant2.default)(key instanceof _index2.StringValue); // sourceObject is simple
|
||||
targetObject.$Set(key, val, targetObject);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// add loop to generator
|
||||
(0, _invariant2.default)(boundName != null);
|
||||
generator.emitForInStatement(o, lh, sourceObject, targetObject, boundName);
|
||||
return realm.intrinsics.undefined;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// 6. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
realm.onDestroyScope(blockEnv);
|
||||
}
|
||||
|
||||
reportError(realm, obexpr.loc);
|
||||
(0, _invariant2.default)(false);
|
||||
}
|
||||
//# sourceMappingURL=ForInStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ForInStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ForInStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
411
build/node_modules/prepack/lib/evaluators/ForOfStatement.js
generated
vendored
Normal file
411
build/node_modules/prepack/lib/evaluators/ForOfStatement.js
generated
vendored
Normal file
@@ -0,0 +1,411 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.InternalGetResultValue = InternalGetResultValue;
|
||||
exports.LoopContinues = LoopContinues;
|
||||
exports.ForInOfHeadEvaluation = ForInOfHeadEvaluation;
|
||||
exports.ForInOfBodyEvaluation = ForInOfBodyEvaluation;
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm, labelSet) {
|
||||
var left = ast.left,
|
||||
right = ast.right,
|
||||
body = ast.body;
|
||||
|
||||
|
||||
try {
|
||||
if (left.type === "VariableDeclaration") {
|
||||
if (left.kind === "var") {
|
||||
// for (var ForBinding o fAssignmentExpression) Statement
|
||||
// 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », AssignmentExpression, iterate).
|
||||
var keyResult = ForInOfHeadEvaluation(realm, env, [], right, "iterate", strictCode);
|
||||
(0, _invariant2.default)(keyResult instanceof _index.ObjectValue);
|
||||
|
||||
// 2. Return ? ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, varBinding, labelSet).
|
||||
return ForInOfBodyEvaluation(realm, env, left.declarations[0].id, body, keyResult, "varBinding", labelSet, strictCode);
|
||||
} else {
|
||||
// for (ForDeclaration of AssignmentExpression) Statement
|
||||
// 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, AssignmentExpression, iterate).
|
||||
var _keyResult = ForInOfHeadEvaluation(realm, env, _singletons.Environment.BoundNames(realm, left), right, "iterate", strictCode);
|
||||
(0, _invariant2.default)(_keyResult instanceof _index.ObjectValue);
|
||||
|
||||
// 2. Return ? ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, lexicalBinding, labelSet).
|
||||
return ForInOfBodyEvaluation(realm, env, left, body, _keyResult, "lexicalBinding", labelSet, strictCode);
|
||||
}
|
||||
} else {
|
||||
// for (LeftHandSideExpression of AssignmentExpression) Statement
|
||||
// 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« », AssignmentExpression, iterate).
|
||||
var _keyResult2 = ForInOfHeadEvaluation(realm, env, [], right, "iterate", strictCode);
|
||||
(0, _invariant2.default)(_keyResult2 instanceof _index.ObjectValue);
|
||||
|
||||
// 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, keyResult, assignment, labelSet).
|
||||
return ForInOfBodyEvaluation(realm, env, left, body, _keyResult2, "assignment", labelSet, strictCode);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof _completions.BreakCompletion) {
|
||||
if (!e.target) return (0, _index2.UpdateEmpty)(realm, e, realm.intrinsics.undefined).value;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function InternalGetResultValue(realm, result) {
|
||||
if (result instanceof _completions.AbruptCompletion) {
|
||||
return result.value;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// ECMA262 13.7.1.2
|
||||
function LoopContinues(realm, completion, labelSet) {
|
||||
// 1. If completion.[[Type]] is normal, return true.
|
||||
if (completion instanceof _index.Value) return true;
|
||||
(0, _invariant2.default)(completion instanceof _completions.AbruptCompletion);
|
||||
|
||||
// 2. If completion.[[Type]] is not continue, return false.
|
||||
if (!(completion instanceof _completions.ContinueCompletion)) return false;
|
||||
|
||||
// 3. If completion.[[Target]] is empty, return true.
|
||||
if (!completion.target) return true;
|
||||
|
||||
// 4. If completion.[[Target]] is an element of labelSet, return true.
|
||||
if (labelSet != null && labelSet.indexOf(completion.target) >= 0) return true;
|
||||
|
||||
// 5. Return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
// ECMA262 13.7.5.10
|
||||
function BindingInstantiation(realm, ast, env) {
|
||||
// ast = ForDeclaration : LetOrConst ForBinding
|
||||
|
||||
// 1. Let envRec be environment's EnvironmentRecord.
|
||||
var envRec = env.environmentRecord;
|
||||
|
||||
// 2. Assert: envRec is a declarative Environment Record.
|
||||
(0, _invariant2.default)(envRec instanceof _environment.DeclarativeEnvironmentRecord);
|
||||
|
||||
// 3. For each element name of the BoundNames of ForBinding do
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = _singletons.Environment.BoundNames(realm, ast)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var name = _step.value;
|
||||
|
||||
// a. If IsConstantDeclaration of LetOrConst is true, then
|
||||
if (ast.kind === "const") {
|
||||
// i. Perform ! envRec.CreateImmutableBinding(name, true).
|
||||
envRec.CreateImmutableBinding(name, true);
|
||||
} else {
|
||||
// b.
|
||||
// i. Perform ! envRec.CreateMutableBinding(name, false).
|
||||
envRec.CreateMutableBinding(name, false);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ECMA262 13.7.5.12
|
||||
function ForInOfHeadEvaluation(realm, env, TDZnames, expr, iterationKind, strictCode) {
|
||||
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
var oldEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// 2. If TDZnames is not an empty List, then
|
||||
if (TDZnames.length) {
|
||||
// a. Assert: TDZnames has no duplicate entries.
|
||||
|
||||
// b. Let TDZ be NewDeclarativeEnvironment(oldEnv).
|
||||
var TDZ = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
|
||||
// c. Let TDZEnvRec be TDZ's EnvironmentRecord.
|
||||
var TDZEnvRec = TDZ.environmentRecord;
|
||||
|
||||
// d. For each string name in TDZnames, do
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = TDZnames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var name = _step2.value;
|
||||
|
||||
// i. Perform ! TDZEnvRec.CreateMutableBinding(name, false).
|
||||
TDZEnvRec.CreateMutableBinding(name, false);
|
||||
}
|
||||
|
||||
// e. Set the running execution context's LexicalEnvironment to TDZ.
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
realm.getRunningContext().lexicalEnvironment = TDZ;
|
||||
env = TDZ;
|
||||
}
|
||||
|
||||
var exprRef = void 0;
|
||||
try {
|
||||
// 3. Let exprRef be the result of evaluating expr.
|
||||
exprRef = env.evaluate(expr, strictCode);
|
||||
} finally {
|
||||
// 4. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
var lexEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
if (lexEnv !== oldEnv) realm.onDestroyScope(lexEnv);
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
}
|
||||
env = oldEnv;
|
||||
|
||||
// 5. Let exprValue be ? GetValue(exprRef).
|
||||
var exprValue = _singletons.Environment.GetValue(realm, exprRef);
|
||||
|
||||
// 6. If iterationKind is enumerate, then
|
||||
if (iterationKind === "enumerate") {
|
||||
// a. If exprValue.[[Value]] is null or undefined, then
|
||||
if (exprValue instanceof _index.NullValue || exprValue instanceof _index.UndefinedValue) {
|
||||
// i. Return Completion{[[Type]]: break, [[Value]]: empty, [[Target]]: empty}.
|
||||
throw new _completions.BreakCompletion(realm.intrinsics.empty, expr.loc, undefined);
|
||||
}
|
||||
|
||||
// b. Let obj be ToObject(exprValue).
|
||||
var obj = _singletons.To.ToObjectPartial(realm, exprValue);
|
||||
|
||||
// c. Return ? EnumerateObjectProperties(obj).
|
||||
if (obj.isPartialObject() || obj instanceof _index.AbstractObjectValue) {
|
||||
return obj;
|
||||
} else {
|
||||
return _singletons.Properties.EnumerateObjectProperties(realm, obj);
|
||||
}
|
||||
} else {
|
||||
// 8. Else,
|
||||
// 1. Assert: iterationKind is iterate.
|
||||
(0, _invariant2.default)(iterationKind === "iterate", "expected iterationKind to be iterate");
|
||||
|
||||
if (exprValue instanceof _index.AbstractValue) {
|
||||
var error = new _errors.CompilerDiagnostic("for of loops over unknown collections are not yet supported", expr.loc, "PP0014", "FatalError");
|
||||
realm.handleError(error);
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
|
||||
// 1. Return ? GetIterator(exprValue).
|
||||
return (0, _index2.GetIterator)(realm, exprValue);
|
||||
}
|
||||
}
|
||||
|
||||
// ECMA262 13.7.5.13
|
||||
function ForInOfBodyEvaluation(realm, env, lhs, stmt, iterator, lhsKind, labelSet, strictCode) {
|
||||
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
var oldEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// 2. Let V be undefined.
|
||||
var V = realm.intrinsics.undefined;
|
||||
|
||||
// 3. Let destructuring be IsDestructuring of lhs.
|
||||
var destructuring = _singletons.Environment.IsDestructuring(lhs);
|
||||
|
||||
// 4. If destructuring is true and if lhsKind is assignment, then
|
||||
if (destructuring && lhsKind === "assignment") {
|
||||
// a. Assert: lhs is a LeftHandSideExpression.
|
||||
(0, _invariant2.default)(lhs.type !== "VariableDeclaration");
|
||||
|
||||
// b. Let assignmentPattern be the parse of the source text corresponding to lhs using AssignmentPattern as the goal symbol.
|
||||
}
|
||||
|
||||
// 5. Repeat
|
||||
while (true) {
|
||||
// a. Let nextResult be ? IteratorStep(iterator).
|
||||
var nextResult = (0, _index2.IteratorStep)(realm, iterator);
|
||||
|
||||
// b. If nextResult is false, return NormalCompletion(V).
|
||||
if (!nextResult) return V;
|
||||
|
||||
// c. Let nextValue be ? IteratorValue(nextResult).
|
||||
var nextValue = (0, _index2.IteratorValue)(realm, nextResult);
|
||||
|
||||
// d. If lhsKind is either assignment or varBinding, then
|
||||
var iterationEnv = void 0;
|
||||
var lhsRef = void 0;
|
||||
if (lhsKind === "assignment" || lhsKind === "varBinding") {
|
||||
// i. If destructuring is false, then
|
||||
if (!destructuring) {
|
||||
// 1. Let lhsRef be the result of evaluating lhs. (It may be evaluated repeatedly.)
|
||||
lhsRef = env.evaluateCompletion(lhs, strictCode);
|
||||
}
|
||||
} else {
|
||||
// e. Else,
|
||||
// i. Assert: lhsKind is lexicalBinding.
|
||||
(0, _invariant2.default)(lhsKind === "lexicalBinding", "expected lhsKind to be lexicalBinding");
|
||||
(0, _invariant2.default)(lhs.type === "VariableDeclaration");
|
||||
|
||||
// ii. Assert: lhs is a ForDeclaration.
|
||||
|
||||
// iii. Let iterationEnv be NewDeclarativeEnvironment(oldEnv).
|
||||
iterationEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
|
||||
// iv. Perform BindingInstantiation for lhs passing iterationEnv as the argument.
|
||||
BindingInstantiation(realm, lhs, iterationEnv);
|
||||
|
||||
// v. Set the running execution context's LexicalEnvironment to iterationEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = iterationEnv;
|
||||
env = iterationEnv;
|
||||
|
||||
// vi. If destructuring is false, then
|
||||
if (!destructuring) {
|
||||
var names = _singletons.Environment.BoundNames(realm, lhs);
|
||||
|
||||
// 1. Assert: lhs binds a single name.
|
||||
(0, _invariant2.default)(names.length === 1, "expected single name");
|
||||
|
||||
// 2. Let lhsName be the sole element of BoundNames of lhs.
|
||||
var lhsName = names[0];
|
||||
|
||||
// 3. Let lhsRef be ! ResolveBinding(lhsName).
|
||||
lhsRef = _singletons.Environment.ResolveBinding(realm, lhsName, strictCode);
|
||||
}
|
||||
}
|
||||
|
||||
// f. If destructuring is false, then
|
||||
var status = void 0;
|
||||
try {
|
||||
if (!destructuring) {
|
||||
// i. If lhsRef is an abrupt completion, then
|
||||
if (lhsRef instanceof _completions.AbruptCompletion) {
|
||||
// 1. Let status be lhsRef.
|
||||
status = lhsRef;
|
||||
} else if (lhsKind === "lexicalBinding") {
|
||||
// ii. Else if lhsKind is lexicalBinding, then
|
||||
// 1. Let status be InitializeReferencedBinding(lhsRef, nextValue).
|
||||
(0, _invariant2.default)(lhsRef instanceof _environment.Reference);
|
||||
status = _singletons.Environment.InitializeReferencedBinding(realm, lhsRef, nextValue);
|
||||
} else {
|
||||
// iii. Else,
|
||||
// 1. Let status be PutValue(lhsRef, nextValue).
|
||||
(0, _invariant2.default)(lhsRef !== undefined);
|
||||
status = _singletons.Properties.PutValue(realm, lhsRef, nextValue);
|
||||
}
|
||||
} else {
|
||||
// g. Else,
|
||||
// i. If lhsKind is assignment, then
|
||||
if (lhsKind === "assignment") {
|
||||
(0, _invariant2.default)(lhs.type === "ArrayPattern" || lhs.type === "ObjectPattern");
|
||||
|
||||
// 1. Let status be the result of performing DestructuringAssignmentEvaluation of assignmentPattern using nextValue as the argument.
|
||||
status = (0, _index2.DestructuringAssignmentEvaluation)(realm, lhs, nextValue, strictCode, iterationEnv || env);
|
||||
} else if (lhsKind === "varBinding") {
|
||||
// ii. Else if lhsKind is varBinding, then
|
||||
// 1. Assert: lhs is a ForBinding.
|
||||
|
||||
// 2. Let status be the result of performing BindingInitialization for lhs passing nextValue and undefined as the arguments.
|
||||
status = _singletons.Environment.BindingInitialization(realm, lhs, nextValue, strictCode, undefined);
|
||||
} else {
|
||||
// iii. Else,
|
||||
// 1. Assert: lhsKind is lexicalBinding.
|
||||
(0, _invariant2.default)(lhsKind === "lexicalBinding");
|
||||
|
||||
// 2. Assert: lhs is a ForDeclaration.
|
||||
|
||||
// 3. Let status be the result of performing BindingInitialization for lhs passing nextValue and iterationEnv as arguments.
|
||||
(0, _invariant2.default)(iterationEnv !== undefined);
|
||||
status = _singletons.Environment.BindingInitialization(realm, lhs, nextValue, strictCode, iterationEnv);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof _completions.AbruptCompletion) {
|
||||
status = e;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// h. If status is an abrupt completion, then
|
||||
if (status instanceof _completions.AbruptCompletion) {
|
||||
// i. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
|
||||
// ii. Return ? IteratorClose(iterator, status).
|
||||
throw (0, _index2.IteratorClose)(realm, iterator, status);
|
||||
}
|
||||
|
||||
// i. Let result be the result of evaluating stmt.
|
||||
var result = env.evaluateCompletion(stmt, strictCode);
|
||||
(0, _invariant2.default)(result instanceof _index.Value || result instanceof _completions.AbruptCompletion);
|
||||
|
||||
// j. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
|
||||
var lexEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
if (lexEnv !== oldEnv) realm.onDestroyScope(lexEnv);
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
env = oldEnv;
|
||||
|
||||
// k. If LoopContinues(result, labelSet) is false, return ? IteratorClose(iterator, UpdateEmpty(result, V)).
|
||||
if (!LoopContinues(realm, result, labelSet)) {
|
||||
(0, _invariant2.default)(result instanceof _completions.AbruptCompletion);
|
||||
result = (0, _index2.UpdateEmpty)(realm, result, V);
|
||||
(0, _invariant2.default)(result instanceof _completions.AbruptCompletion);
|
||||
throw (0, _index2.IteratorClose)(realm, iterator, result);
|
||||
}
|
||||
|
||||
// l. If result.[[Value]] is not empty, let V be result.[[Value]].
|
||||
var resultValue = InternalGetResultValue(realm, result);
|
||||
if (!(resultValue instanceof _index.EmptyValue)) V = resultValue;
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
(0, _invariant2.default)(false); // can't get here but there is no other way to make Flow happy
|
||||
}
|
||||
|
||||
// ECMA262 13.7.5.11
|
||||
//# sourceMappingURL=ForOfStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ForOfStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ForOfStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
268
build/node_modules/prepack/lib/evaluators/ForStatement.js
generated
vendored
Normal file
268
build/node_modules/prepack/lib/evaluators/ForStatement.js
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.CreatePerIterationEnvironment = CreatePerIterationEnvironment;
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm, labelSet) {
|
||||
var init = ast.init,
|
||||
test = ast.test,
|
||||
update = ast.update,
|
||||
body = ast.body;
|
||||
|
||||
|
||||
if (init && init.type === "VariableDeclaration") {
|
||||
if (init.kind === "var") {
|
||||
// for (var VariableDeclarationList; Expression; Expression) Statement
|
||||
// 1. Let varDcl be the result of evaluating VariableDeclarationList.
|
||||
var varDcl = env.evaluate(init, strictCode);
|
||||
|
||||
// 2. ReturnIfAbrupt(varDcl).
|
||||
varDcl;
|
||||
|
||||
// 3. Return ? ForBodyEvaluation(the first Expression, the second Expression, Statement, « », labelSet).
|
||||
return ForBodyEvaluation(realm, test, update, body, [], labelSet, strictCode);
|
||||
} else {
|
||||
// for (LexicalDeclaration Expression; Expression) Statement
|
||||
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
var oldEnv = env;
|
||||
|
||||
// 2. Let loopEnv be NewDeclarativeEnvironment(oldEnv).
|
||||
var loopEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
|
||||
// 3. Let loopEnvRec be loopEnv's EnvironmentRecord.
|
||||
var loopEnvRec = loopEnv.environmentRecord;
|
||||
|
||||
// 4. Let isConst be the result of performing IsConstantDeclaration of LexicalDeclaration.
|
||||
var isConst = init.kind === "const";
|
||||
|
||||
// 5. Let boundNames be the BoundNames of LexicalDeclaration.
|
||||
var boundNames = _singletons.Environment.BoundNames(realm, init);
|
||||
|
||||
// 6. For each element dn of boundNames do
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = boundNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var dn = _step2.value;
|
||||
|
||||
// a. If isConst is true, then
|
||||
if (isConst) {
|
||||
// i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true).
|
||||
loopEnvRec.CreateImmutableBinding(dn, true);
|
||||
} else {
|
||||
// b. Else,
|
||||
// i. Perform ! loopEnvRec.CreateMutableBinding(dn, false).
|
||||
loopEnvRec.CreateMutableBinding(dn, false);
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Set the running execution context's LexicalEnvironment to loopEnv.
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
realm.getRunningContext().lexicalEnvironment = loopEnv;
|
||||
|
||||
// 8. Let forDcl be the result of evaluating LexicalDeclaration.
|
||||
var forDcl = loopEnv.evaluateCompletion(init, strictCode);
|
||||
|
||||
// 9. If forDcl is an abrupt completion, then
|
||||
if (forDcl instanceof _completions.AbruptCompletion) {
|
||||
// a. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
var currentEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
realm.onDestroyScope(currentEnv);
|
||||
if (currentEnv !== loopEnv) (0, _invariant2.default)(loopEnv.destroyed);
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
|
||||
// b. Return Completion(forDcl).
|
||||
throw forDcl;
|
||||
}
|
||||
|
||||
// 10. If isConst is false, let perIterationLets be boundNames; otherwise let perIterationLets be « ».
|
||||
var perIterationLets = !isConst ? boundNames : [];
|
||||
|
||||
var bodyResult = void 0;
|
||||
try {
|
||||
// 11. Let bodyResult be ForBodyEvaluation(the first Expression, the second Expression, Statement, perIterationLets, labelSet).
|
||||
bodyResult = ForBodyEvaluation(realm, test, update, body, perIterationLets, labelSet, strictCode);
|
||||
} finally {
|
||||
// 12. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
var _currentEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
realm.onDestroyScope(_currentEnv);
|
||||
if (_currentEnv !== loopEnv) (0, _invariant2.default)(loopEnv.destroyed);
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
}
|
||||
// 13. Return Completion(bodyResult).
|
||||
return bodyResult;
|
||||
}
|
||||
} else {
|
||||
// for (Expression; Expression; Expression) Statement
|
||||
// 1. If the first Expression is present, then
|
||||
if (init) {
|
||||
// a. Let exprRef be the result of evaluating the first Expression.
|
||||
var exprRef = env.evaluate(init, strictCode);
|
||||
|
||||
// b. Perform ? GetValue(exprRef).
|
||||
_singletons.Environment.GetValue(realm, exprRef);
|
||||
}
|
||||
|
||||
// 2. Return ? ForBodyEvaluation(the second Expression, the third Expression, Statement, « », labelSet).
|
||||
return ForBodyEvaluation(realm, test, update, body, [], labelSet, strictCode);
|
||||
}
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _ForOfStatement = require("./ForOfStatement.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// ECMA262 13.7.4.9
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function CreatePerIterationEnvironment(realm, perIterationBindings) {
|
||||
// 1. If perIterationBindings has any elements, then
|
||||
if (perIterationBindings.length > 0) {
|
||||
// a. Let lastIterationEnv be the running execution context's LexicalEnvironment.
|
||||
var lastIterationEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
// b. Let lastIterationEnvRec be lastIterationEnv's EnvironmentRecord.
|
||||
var lastIterationEnvRec = lastIterationEnv.environmentRecord;
|
||||
// c. Let outer be lastIterationEnv's outer environment reference.
|
||||
var outer = lastIterationEnv.parent;
|
||||
// d. Assert: outer is not null.
|
||||
(0, _invariant2.default)(outer !== null);
|
||||
// e. Let thisIterationEnv be NewDeclarativeEnvironment(outer).
|
||||
var thisIterationEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, outer);
|
||||
// f. Let thisIterationEnvRec be thisIterationEnv's EnvironmentRecord.
|
||||
realm.onDestroyScope(lastIterationEnv);
|
||||
var thisIterationEnvRec = thisIterationEnv.environmentRecord;
|
||||
// g. For each element bn of perIterationBindings do,
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = perIterationBindings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var bn = _step.value;
|
||||
|
||||
// i. Perform ! thisIterationEnvRec.CreateMutableBinding(bn, false).
|
||||
thisIterationEnvRec.CreateMutableBinding(bn, false);
|
||||
// ii. Let lastValue be ? lastIterationEnvRec.GetBindingValue(bn, true).
|
||||
var lastValue = lastIterationEnvRec.GetBindingValue(bn, true);
|
||||
// iii.Perform thisIterationEnvRec.InitializeBinding(bn, lastValue).
|
||||
thisIterationEnvRec.InitializeBinding(bn, lastValue);
|
||||
}
|
||||
// h. Set the running execution context's LexicalEnvironment to thisIterationEnv.
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
realm.getRunningContext().lexicalEnvironment = thisIterationEnv;
|
||||
}
|
||||
// 2. Return undefined.
|
||||
return realm.intrinsics.undefined;
|
||||
}
|
||||
|
||||
// ECMA262 13.7.4.8
|
||||
function ForBodyEvaluation(realm, test, increment, stmt, perIterationBindings, labelSet, strictCode) {
|
||||
// 1. Let V be undefined.
|
||||
var V = realm.intrinsics.undefined;
|
||||
|
||||
// 2. Perform ? CreatePerIterationEnvironment(perIterationBindings).
|
||||
CreatePerIterationEnvironment(realm, perIterationBindings);
|
||||
var env = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// 3. Repeat
|
||||
while (true) {
|
||||
// a. If test is not [empty], then
|
||||
if (test) {
|
||||
// i. Let testRef be the result of evaluating test.
|
||||
var testRef = env.evaluate(test, strictCode);
|
||||
|
||||
// ii. Let testValue be ? GetValue(testRef).
|
||||
var testValue = _singletons.Environment.GetValue(realm, testRef);
|
||||
|
||||
// iii. If ToBoolean(testValue) is false, return NormalCompletion(V).
|
||||
if (!_singletons.To.ToBooleanPartial(realm, testValue)) return V;
|
||||
}
|
||||
|
||||
// b. Let result be the result of evaluating stmt.
|
||||
var result = env.evaluateCompletion(stmt, strictCode);
|
||||
(0, _invariant2.default)(result instanceof _index.Value || result instanceof _completions.AbruptCompletion);
|
||||
|
||||
// c. If LoopContinues(result, labelSet) is false, return Completion(UpdateEmpty(result, V)).
|
||||
if (!(0, _ForOfStatement.LoopContinues)(realm, result, labelSet)) {
|
||||
(0, _invariant2.default)(result instanceof _completions.AbruptCompletion);
|
||||
// ECMA262 13.1.7
|
||||
if (result instanceof _completions.BreakCompletion) {
|
||||
if (!result.target) return (0, _index2.UpdateEmpty)(realm, result, V).value;
|
||||
}
|
||||
throw (0, _index2.UpdateEmpty)(realm, result, V);
|
||||
}
|
||||
|
||||
// d. If result.[[Value]] is not empty, let V be result.[[Value]].
|
||||
var resultValue = (0, _ForOfStatement.InternalGetResultValue)(realm, result);
|
||||
if (!(resultValue instanceof _index.EmptyValue)) V = resultValue;
|
||||
|
||||
// e. Perform ? CreatePerIterationEnvironment(perIterationBindings).
|
||||
CreatePerIterationEnvironment(realm, perIterationBindings);
|
||||
env = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// f. If increment is not [empty], then
|
||||
if (increment) {
|
||||
// i. Let incRef be the result of evaluating increment.
|
||||
var incRef = env.evaluate(increment, strictCode);
|
||||
|
||||
// ii. Perform ? GetValue(incRef).
|
||||
_singletons.Environment.GetValue(realm, incRef);
|
||||
}
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(false);
|
||||
}
|
||||
|
||||
// ECMA262 13.7.4.7
|
||||
//# sourceMappingURL=ForStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ForStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ForStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
76
build/node_modules/prepack/lib/evaluators/FunctionDeclaration.js
generated
vendored
Normal file
76
build/node_modules/prepack/lib/evaluators/FunctionDeclaration.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
if (ast.generator) {
|
||||
// 1. If the function code for GeneratorDeclaration is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var strict = strictCode || (0, _strict3.default)(ast.body);
|
||||
|
||||
// 2. Let name be StringValue of BindingIdentifier.
|
||||
var name = void 0;
|
||||
if (ast.id) {
|
||||
name = new _index.StringValue(realm, ast.id.name);
|
||||
} else {
|
||||
name = new _index.StringValue(realm, "default");
|
||||
}
|
||||
|
||||
// 3. Let F be GeneratorFunctionCreate(Normal, FormalParameters, GeneratorBody, scope, strict).
|
||||
var F = _singletons.Functions.GeneratorFunctionCreate(realm, "normal", ast.params, ast.body, env, strict);
|
||||
|
||||
// 4. Let prototype be ObjectCreate(%GeneratorPrototype%).
|
||||
var prototype = _singletons.Create.ObjectCreate(realm, realm.intrinsics.GeneratorPrototype);
|
||||
|
||||
// 5. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
|
||||
_singletons.Properties.DefinePropertyOrThrow(realm, F, "prototype", {
|
||||
value: prototype,
|
||||
writable: true,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
// 6. Perform SetFunctionName(F, name).
|
||||
_singletons.Functions.SetFunctionName(realm, F, name);
|
||||
|
||||
// 7 .Return F.
|
||||
return F;
|
||||
} else {
|
||||
// 1. If the function code for FunctionDeclaration is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var _strict = strictCode || (0, _strict3.default)(ast.body);
|
||||
|
||||
// 2. Let name be StringValue of BindingIdentifier.
|
||||
var _name = void 0;
|
||||
if (ast.id) {
|
||||
_name = new _index.StringValue(realm, ast.id.name);
|
||||
} else {
|
||||
_name = new _index.StringValue(realm, "default");
|
||||
}
|
||||
|
||||
// 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, strict).
|
||||
var _F = _singletons.Functions.FunctionCreate(realm, "normal", ast.params, ast.body, env, _strict);
|
||||
if (ast.id && ast.id.name) _F.__originalName = ast.id.name;
|
||||
|
||||
// 4. Perform MakeConstructor(F).
|
||||
(0, _construct.MakeConstructor)(realm, _F);
|
||||
|
||||
// 5. Perform SetFunctionName(F, name).
|
||||
_singletons.Functions.SetFunctionName(realm, _F, _name);
|
||||
|
||||
// 6. Return F.
|
||||
return _F;
|
||||
}
|
||||
};
|
||||
|
||||
var _construct = require("../methods/construct.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _strict2 = require("../utils/strict.js");
|
||||
|
||||
var _strict3 = _interopRequireDefault(_strict2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=FunctionDeclaration.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/FunctionDeclaration.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/FunctionDeclaration.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/FunctionDeclaration.js"],"names":["ast","strictCode","env","realm","generator","strict","body","name","id","F","GeneratorFunctionCreate","params","prototype","ObjectCreate","intrinsics","GeneratorPrototype","DefinePropertyOrThrow","value","writable","configurable","SetFunctionName","FunctionCreate","__originalName"],"mappings":";;;;;;kBAqBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,MAAIH,IAAII,SAAR,EAAmB;AACjB;AACA,QAAIC,SAASJ,cAAc,sBAASD,IAAIM,IAAb,CAA3B;;AAEA;AACA,QAAIC,aAAJ;AACA,QAAIP,IAAIQ,EAAR,EAAY;AACVD,aAAO,uBAAgBJ,KAAhB,EAAuBH,IAAIQ,EAAJ,CAAOD,IAA9B,CAAP;AACD,KAFD,MAEO;AACLA,aAAO,uBAAgBJ,KAAhB,EAAuB,SAAvB,CAAP;AACD;;AAED;AACA,QAAIM,IAAI,sBAAUC,uBAAV,CAAkCP,KAAlC,EAAyC,QAAzC,EAAmDH,IAAIW,MAAvD,EAA+DX,IAAIM,IAAnE,EAAyEJ,GAAzE,EAA8EG,MAA9E,CAAR;;AAEA;AACA,QAAIO,YAAY,mBAAOC,YAAP,CAAoBV,KAApB,EAA2BA,MAAMW,UAAN,CAAiBC,kBAA5C,CAAhB;;AAEA;AACA,2BAAWC,qBAAX,CAAiCb,KAAjC,EAAwCM,CAAxC,EAA2C,WAA3C,EAAwD;AACtDQ,aAAOL,SAD+C;AAEtDM,gBAAU,IAF4C;AAGtDC,oBAAc;AAHwC,KAAxD;;AAMA;AACA,0BAAUC,eAAV,CAA0BjB,KAA1B,EAAiCM,CAAjC,EAAoCF,IAApC;;AAEA;AACA,WAAOE,CAAP;AACD,GA9BD,MA8BO;AACL;AACA,QAAIJ,UAASJ,cAAc,sBAASD,IAAIM,IAAb,CAA3B;;AAEA;AACA,QAAIC,cAAJ;AACA,QAAIP,IAAIQ,EAAR,EAAY;AACVD,cAAO,uBAAgBJ,KAAhB,EAAuBH,IAAIQ,EAAJ,CAAOD,IAA9B,CAAP;AACD,KAFD,MAEO;AACLA,cAAO,uBAAgBJ,KAAhB,EAAuB,SAAvB,CAAP;AACD;;AAED;AACA,QAAIM,KAAI,sBAAUY,cAAV,CAAyBlB,KAAzB,EAAgC,QAAhC,EAA0CH,IAAIW,MAA9C,EAAsDX,IAAIM,IAA1D,EAAgEJ,GAAhE,EAAqEG,OAArE,CAAR;AACA,QAAIL,IAAIQ,EAAJ,IAAUR,IAAIQ,EAAJ,CAAOD,IAArB,EAA2BE,GAAEa,cAAF,GAAmBtB,IAAIQ,EAAJ,CAAOD,IAA1B;;AAE3B;AACA,oCAAgBJ,KAAhB,EAAuBM,EAAvB;;AAEA;AACA,0BAAUW,eAAV,CAA0BjB,KAA1B,EAAiCM,EAAjC,EAAoCF,KAApC;;AAEA;AACA,WAAOE,EAAP;AACD;AACF,C;;AApED;;AACA;;AACA;;AACA","file":"FunctionDeclaration.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { MakeConstructor } from \"../methods/construct.js\";\nimport { Create, Functions, Properties } from \"../singletons.js\";\nimport { StringValue } from \"../values/index.js\";\nimport IsStrict from \"../utils/strict.js\";\nimport type { BabelNodeFunctionDeclaration } from \"babel-types\";\n\n// ECMA262 14.1.20\nexport default function(\n ast: BabelNodeFunctionDeclaration,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n if (ast.generator) {\n // 1. If the function code for GeneratorDeclaration is strict mode code, let strict be true. Otherwise let strict be false.\n let strict = strictCode || IsStrict(ast.body);\n\n // 2. Let name be StringValue of BindingIdentifier.\n let name;\n if (ast.id) {\n name = new StringValue(realm, ast.id.name);\n } else {\n name = new StringValue(realm, \"default\");\n }\n\n // 3. Let F be GeneratorFunctionCreate(Normal, FormalParameters, GeneratorBody, scope, strict).\n let F = Functions.GeneratorFunctionCreate(realm, \"normal\", ast.params, ast.body, env, strict);\n\n // 4. Let prototype be ObjectCreate(%GeneratorPrototype%).\n let prototype = Create.ObjectCreate(realm, realm.intrinsics.GeneratorPrototype);\n\n // 5. Perform DefinePropertyOrThrow(F, \"prototype\", PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).\n Properties.DefinePropertyOrThrow(realm, F, \"prototype\", {\n value: prototype,\n writable: true,\n configurable: false,\n });\n\n // 6. Perform SetFunctionName(F, name).\n Functions.SetFunctionName(realm, F, name);\n\n // 7 .Return F.\n return F;\n } else {\n // 1. If the function code for FunctionDeclaration is strict mode code, let strict be true. Otherwise let strict be false.\n let strict = strictCode || IsStrict(ast.body);\n\n // 2. Let name be StringValue of BindingIdentifier.\n let name;\n if (ast.id) {\n name = new StringValue(realm, ast.id.name);\n } else {\n name = new StringValue(realm, \"default\");\n }\n\n // 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, strict).\n let F = Functions.FunctionCreate(realm, \"normal\", ast.params, ast.body, env, strict);\n if (ast.id && ast.id.name) F.__originalName = ast.id.name;\n\n // 4. Perform MakeConstructor(F).\n MakeConstructor(realm, F);\n\n // 5. Perform SetFunctionName(F, name).\n Functions.SetFunctionName(realm, F, name);\n\n // 6. Return F.\n return F;\n }\n}\n"]}
|
||||
151
build/node_modules/prepack/lib/evaluators/FunctionExpression.js
generated
vendored
Normal file
151
build/node_modules/prepack/lib/evaluators/FunctionExpression.js
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// ECMA262 14.1.21
|
||||
|
||||
if (ast.id) {
|
||||
if (ast.generator) {
|
||||
// 1. If the function code for this GeneratorExpression is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var strict = strictCode || (0, _strict5.default)(ast.body);
|
||||
|
||||
// 2. Let scope be the running execution context's LexicalEnvironment.
|
||||
var scope = env;
|
||||
|
||||
// 3. Let funcEnv be NewDeclarativeEnvironment(scope).
|
||||
var funcEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, scope);
|
||||
|
||||
// 4. Let envRec be funcEnv's EnvironmentRecord.
|
||||
var envRec = funcEnv.environmentRecord;
|
||||
|
||||
// 5. Let name be StringValue of BindingIdentifier.
|
||||
(0, _invariant2.default)(ast.id);
|
||||
var name = ast.id.name;
|
||||
|
||||
// 6. Perform envRec.CreateImmutableBinding(name, false).
|
||||
envRec.CreateImmutableBinding(name, false);
|
||||
|
||||
// 7. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, GeneratorBody, funcEnv, strict).
|
||||
var closure = _singletons.Functions.GeneratorFunctionCreate(realm, "normal", ast.params, ast.body, funcEnv, strict);
|
||||
closure.loc = ast.loc;
|
||||
|
||||
// 8. Let prototype be ObjectCreate(%GeneratorPrototype%).
|
||||
var prototype = _singletons.Create.ObjectCreate(realm, realm.intrinsics.GeneratorPrototype);
|
||||
prototype.originalConstructor = closure;
|
||||
|
||||
// 9. Perform DefinePropertyOrThrow(closure, "prototype", PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
|
||||
_singletons.Properties.DefinePropertyOrThrow(realm, closure, "prototype", {
|
||||
value: prototype,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
// 10. Perform SetFunctionName(closure, name).
|
||||
_singletons.Functions.SetFunctionName(realm, closure, new _index2.StringValue(realm, name));
|
||||
|
||||
// 11. Perform envRec.InitializeBinding(name, closure).
|
||||
envRec.InitializeBinding(name, closure);
|
||||
|
||||
// 12. Return closure.
|
||||
return closure;
|
||||
} else {
|
||||
// 1. If the function code for FunctionExpression is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var _strict = strictCode || (0, _strict5.default)(ast.body);
|
||||
|
||||
// 2. Let scope be the running execution context's LexicalEnvironment.
|
||||
var _scope = env;
|
||||
|
||||
// 3. Let funcEnv be NewDeclarativeEnvironment(scope).
|
||||
var _funcEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, _scope, false);
|
||||
|
||||
// 4. Let envRec be funcEnv's EnvironmentRecord.
|
||||
var _envRec = _funcEnv.environmentRecord;
|
||||
|
||||
// 5. Let name be StringValue of BindingIdentifier.
|
||||
(0, _invariant2.default)(ast.id);
|
||||
var _name = ast.id.name;
|
||||
|
||||
// 6. Perform envRec.CreateImmutableBinding(name, false).
|
||||
_envRec.CreateImmutableBinding(_name, false);
|
||||
|
||||
// 7. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, funcEnv, strict).
|
||||
var _closure = _singletons.Functions.FunctionCreate(realm, "normal", ast.params, ast.body, _funcEnv, _strict);
|
||||
_closure.loc = ast.loc;
|
||||
|
||||
// 8. Perform MakeConstructor(closure).
|
||||
(0, _index.MakeConstructor)(realm, _closure);
|
||||
|
||||
// 9. Perform SetFunctionName(closure, name).
|
||||
_singletons.Functions.SetFunctionName(realm, _closure, new _index2.StringValue(realm, _name));
|
||||
|
||||
// 10. Perform envRec.InitializeBinding(name, closure).
|
||||
_envRec.InitializeBinding(_name, _closure);
|
||||
|
||||
// 11. Return closure.
|
||||
return _closure;
|
||||
}
|
||||
} else {
|
||||
if (ast.generator) {
|
||||
// 1. If the function code for this GeneratorExpression is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var _strict2 = strictCode || (0, _strict5.default)(ast.body);
|
||||
|
||||
// 2. Let scope be the LexicalEnvironment of the running execution context.
|
||||
var _scope2 = env;
|
||||
|
||||
// 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, GeneratorBody, scope, strict).
|
||||
var _closure2 = _singletons.Functions.GeneratorFunctionCreate(realm, "normal", ast.params, ast.body, _scope2, _strict2);
|
||||
|
||||
// 4. Let prototype be ObjectCreate(%GeneratorPrototype%).
|
||||
var _prototype = _singletons.Create.ObjectCreate(realm, realm.intrinsics.GeneratorPrototype);
|
||||
_prototype.originalConstructor = _closure2;
|
||||
|
||||
// 5. Perform DefinePropertyOrThrow(closure, "prototype", PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
|
||||
_singletons.Properties.DefinePropertyOrThrow(realm, _closure2, "prototype", {
|
||||
value: _prototype,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
// 6. Return closure.
|
||||
return _closure2;
|
||||
} else {
|
||||
// 1. If the function code for FunctionExpression is strict mode code, let strict be true. Otherwise let strict be false.
|
||||
var _strict3 = strictCode || (0, _strict5.default)(ast.body);
|
||||
|
||||
// 2. Let scope be the LexicalEnvironment of the running execution context.
|
||||
var _scope3 = env;
|
||||
|
||||
// 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, strict).
|
||||
var _closure3 = _singletons.Functions.FunctionCreate(realm, "normal", ast.params, ast.body, _scope3, _strict3);
|
||||
_closure3.loc = ast.loc;
|
||||
|
||||
// 4. Perform MakeConstructor(closure).
|
||||
(0, _index.MakeConstructor)(realm, _closure3);
|
||||
|
||||
// 5. Return closure.
|
||||
return _closure3;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var _index = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _index2 = require("../values/index.js");
|
||||
|
||||
var _strict4 = require("../utils/strict.js");
|
||||
|
||||
var _strict5 = _interopRequireDefault(_strict4);
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=FunctionExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/FunctionExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/FunctionExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
13
build/node_modules/prepack/lib/evaluators/Identifier.js
generated
vendored
Normal file
13
build/node_modules/prepack/lib/evaluators/Identifier.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Return ? ResolveBinding(StringValue of Identifier).
|
||||
return _singletons.Environment.ResolveBinding(realm, ast.name, strictCode, env);
|
||||
};
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=Identifier.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/Identifier.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/Identifier.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/Identifier.js"],"names":["ast","strictCode","env","realm","ResolveBinding","name"],"mappings":";;;;;;kBAkBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKF;AACX;AACA,SAAO,wBAAYC,cAAZ,CAA2BD,KAA3B,EAAkCH,IAAIK,IAAtC,EAA4CJ,UAA5C,EAAwDC,GAAxD,CAAP;AACD,C;;AAZD","file":"Identifier.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Reference } from \"../environment.js\";\nimport { Environment } from \"../singletons.js\";\nimport type { BabelNodeIdentifier } from \"babel-types\";\n\n// ECMA262 12.1.6\nexport default function(\n ast: BabelNodeIdentifier,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Reference {\n // 1. Return ? ResolveBinding(StringValue of Identifier).\n return Environment.ResolveBinding(realm, ast.name, strictCode, env);\n}\n"]}
|
||||
136
build/node_modules/prepack/lib/evaluators/IfStatement.js
generated
vendored
Normal file
136
build/node_modules/prepack/lib/evaluators/IfStatement.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.evaluate = evaluate;
|
||||
exports.evaluateWithAbstractConditional = evaluateWithAbstractConditional;
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _realm = require("../realm.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function evaluate(ast, strictCode, env, realm) {
|
||||
// 1. Let exprRef be the result of evaluating Expression
|
||||
var exprRef = env.evaluate(ast.test, strictCode);
|
||||
// 2. Let exprValue be ToBoolean(? GetValue(exprRef))
|
||||
var exprValue = _singletons.Environment.GetConditionValue(realm, exprRef);
|
||||
|
||||
if (exprValue instanceof _index.ConcreteValue) {
|
||||
var stmtCompletion = void 0;
|
||||
if (_singletons.To.ToBoolean(realm, exprValue)) {
|
||||
// 3.a. Let stmtCompletion be the result of evaluating the first Statement
|
||||
stmtCompletion = env.evaluateCompletion(ast.consequent, strictCode);
|
||||
} else {
|
||||
if (ast.alternate)
|
||||
// 4.a. Let stmtCompletion be the result of evaluating the second Statement
|
||||
stmtCompletion = env.evaluateCompletion(ast.alternate, strictCode);else
|
||||
// 3 (of the if only statement). Return NormalCompletion(undefined)
|
||||
stmtCompletion = realm.intrinsics.undefined;
|
||||
}
|
||||
// 5. Return Completion(UpdateEmpty(stmtCompletion, undefined)
|
||||
//if (stmtCompletion instanceof Reference) return stmtCompletion;
|
||||
(0, _invariant2.default)(!(stmtCompletion instanceof _environment.Reference));
|
||||
stmtCompletion = (0, _index2.UpdateEmpty)(realm, stmtCompletion, realm.intrinsics.undefined);
|
||||
if (stmtCompletion instanceof _completions.AbruptCompletion) {
|
||||
throw stmtCompletion;
|
||||
}
|
||||
(0, _invariant2.default)(stmtCompletion instanceof _index.Value);
|
||||
return stmtCompletion;
|
||||
}
|
||||
(0, _invariant2.default)(exprValue instanceof _index.AbstractValue);
|
||||
|
||||
if (!exprValue.mightNotBeTrue()) {
|
||||
var _stmtCompletion = env.evaluate(ast.consequent, strictCode);
|
||||
(0, _invariant2.default)(!(_stmtCompletion instanceof _environment.Reference));
|
||||
_stmtCompletion = (0, _index2.UpdateEmpty)(realm, _stmtCompletion, realm.intrinsics.undefined);
|
||||
if (_stmtCompletion instanceof _completions.AbruptCompletion) {
|
||||
throw _stmtCompletion;
|
||||
}
|
||||
(0, _invariant2.default)(_stmtCompletion instanceof _index.Value);
|
||||
return _stmtCompletion;
|
||||
} else if (!exprValue.mightNotBeFalse()) {
|
||||
var _stmtCompletion2 = void 0;
|
||||
if (ast.alternate) _stmtCompletion2 = env.evaluate(ast.alternate, strictCode);else _stmtCompletion2 = realm.intrinsics.undefined;
|
||||
(0, _invariant2.default)(!(_stmtCompletion2 instanceof _environment.Reference));
|
||||
_stmtCompletion2 = (0, _index2.UpdateEmpty)(realm, _stmtCompletion2, realm.intrinsics.undefined);
|
||||
if (_stmtCompletion2 instanceof _completions.AbruptCompletion) {
|
||||
throw _stmtCompletion2;
|
||||
}
|
||||
(0, _invariant2.default)(_stmtCompletion2 instanceof _index.Value);
|
||||
return _stmtCompletion2;
|
||||
} else {
|
||||
(0, _invariant2.default)(exprValue instanceof _index.AbstractValue);
|
||||
return evaluateWithAbstractConditional(exprValue, ast.consequent, ast.alternate, strictCode, env, realm);
|
||||
}
|
||||
}
|
||||
|
||||
function evaluateWithAbstractConditional(condValue, consequent, alternate, strictCode, env, realm) {
|
||||
// Evaluate consequent and alternate in sandboxes and get their effects.
|
||||
var _Path$withCondition = _singletons.Path.withCondition(condValue, function () {
|
||||
return realm.evaluateNodeForEffects(consequent, strictCode, env);
|
||||
}),
|
||||
_Path$withCondition2 = _slicedToArray(_Path$withCondition, 5),
|
||||
compl1 = _Path$withCondition2[0],
|
||||
gen1 = _Path$withCondition2[1],
|
||||
bindings1 = _Path$withCondition2[2],
|
||||
properties1 = _Path$withCondition2[3],
|
||||
createdObj1 = _Path$withCondition2[4];
|
||||
|
||||
var _Path$withInverseCond = _singletons.Path.withInverseCondition(condValue, function () {
|
||||
return alternate ? realm.evaluateNodeForEffects(alternate, strictCode, env) : (0, _realm.construct_empty_effects)(realm);
|
||||
}),
|
||||
_Path$withInverseCond2 = _slicedToArray(_Path$withInverseCond, 5),
|
||||
compl2 = _Path$withInverseCond2[0],
|
||||
gen2 = _Path$withInverseCond2[1],
|
||||
bindings2 = _Path$withInverseCond2[2],
|
||||
properties2 = _Path$withInverseCond2[3],
|
||||
createdObj2 = _Path$withInverseCond2[4];
|
||||
|
||||
// Join the effects, creating an abstract view of what happened, regardless
|
||||
// of the actual value of condValue.
|
||||
|
||||
|
||||
var joinedEffects = _singletons.Join.joinEffects(realm, condValue, [compl1, gen1, bindings1, properties1, createdObj1], [compl2, gen2, bindings2, properties2, createdObj2]);
|
||||
var completion = joinedEffects[0];
|
||||
if (completion instanceof _completions.PossiblyNormalCompletion) {
|
||||
// in this case one of the branches may complete abruptly, which means that
|
||||
// not all control flow branches join into one flow at this point.
|
||||
// Consequently we have to continue tracking changes until the point where
|
||||
// all the branches come together into one.
|
||||
completion = realm.composeWithSavedCompletion(completion);
|
||||
}
|
||||
// Note that the effects of (non joining) abrupt branches are not included
|
||||
// in joinedEffects, but are tracked separately inside completion.
|
||||
realm.applyEffects(joinedEffects);
|
||||
|
||||
// return or throw completion
|
||||
if (completion instanceof _completions.AbruptCompletion) throw completion;
|
||||
(0, _invariant2.default)(completion instanceof _index.Value);
|
||||
return completion;
|
||||
}
|
||||
//# sourceMappingURL=IfStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/IfStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/IfStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
416
build/node_modules/prepack/lib/evaluators/JSXElement.js
generated
vendored
Normal file
416
build/node_modules/prepack/lib/evaluators/JSXElement.js
generated
vendored
Normal file
@@ -0,0 +1,416 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
(0, _invariant2.default)(realm.react.enabled, "JSXElements can only be evaluated with the reactEnabled option");
|
||||
var openingElement = ast.openingElement;
|
||||
var type = evaluateJSXIdentifier(openingElement.name, strictCode, env, realm);
|
||||
|
||||
var _evaluateJSXAttribute = evaluateJSXAttributes(openingElement.name, openingElement.attributes, ast.children, strictCode, env, realm),
|
||||
attributes = _evaluateJSXAttribute.attributes,
|
||||
children = _evaluateJSXAttribute.children;
|
||||
|
||||
var key = attributes.get("key") || realm.intrinsics.null;
|
||||
var ref = attributes.get("ref") || realm.intrinsics.null;
|
||||
|
||||
if (key === realm.intrinsics.undefined) {
|
||||
key = realm.intrinsics.null;
|
||||
}
|
||||
if (ref === realm.intrinsics.undefined) {
|
||||
ref = realm.intrinsics.null;
|
||||
}
|
||||
|
||||
// React uses keys to identify nodes as they get updated through the reconcilation
|
||||
// phase. Keys are used in a map and thus need to be converted to strings
|
||||
if (key !== realm.intrinsics.null) {
|
||||
key = (0, _BinaryExpression.computeBinary)(realm, "+", realm.intrinsics.emptyString, key);
|
||||
}
|
||||
var props = createReactProps(realm, type, attributes, children, env);
|
||||
|
||||
return createReactElement(realm, type, key, ref, props);
|
||||
};
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _utils = require("../react/utils.js");
|
||||
|
||||
var _jsx = require("../react/jsx.js");
|
||||
|
||||
var _babelTypes = require("babel-types");
|
||||
|
||||
var t = _interopRequireWildcard(_babelTypes);
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _BinaryExpression = require("./BinaryExpression.js");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
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; } }
|
||||
|
||||
var RESERVED_PROPS = {
|
||||
key: true,
|
||||
ref: true,
|
||||
__self: true,
|
||||
__source: true
|
||||
};
|
||||
|
||||
// taken from Babel
|
||||
function cleanJSXElementLiteralChild(child) {
|
||||
var lines = child.split(/\r\n|\n|\r/);
|
||||
|
||||
var lastNonEmptyLine = 0;
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i].match(/[^ \t]/)) {
|
||||
lastNonEmptyLine = i;
|
||||
}
|
||||
}
|
||||
|
||||
var str = "";
|
||||
|
||||
for (var _i = 0; _i < lines.length; _i++) {
|
||||
var line = lines[_i];
|
||||
|
||||
var isFirstLine = _i === 0;
|
||||
var isLastLine = _i === lines.length - 1;
|
||||
var isLastNonEmptyLine = _i === lastNonEmptyLine;
|
||||
|
||||
// replace rendered whitespace tabs with spaces
|
||||
var trimmedLine = line.replace(/\t/g, " ");
|
||||
|
||||
// trim whitespace touching a newline
|
||||
if (!isFirstLine) {
|
||||
trimmedLine = trimmedLine.replace(/^[ ]+/, "");
|
||||
}
|
||||
|
||||
// trim whitespace touching an endline
|
||||
if (!isLastLine) {
|
||||
trimmedLine = trimmedLine.replace(/[ ]+$/, "");
|
||||
}
|
||||
|
||||
if (trimmedLine) {
|
||||
if (!isLastNonEmptyLine) {
|
||||
trimmedLine += " ";
|
||||
}
|
||||
|
||||
str += trimmedLine;
|
||||
}
|
||||
}
|
||||
|
||||
if (str) {
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function evaluateJSXMemberExpression(ast, strictCode, env, realm) {
|
||||
switch (ast.type) {
|
||||
case "JSXIdentifier":
|
||||
return _singletons.Environment.GetValue(realm, _singletons.Environment.ResolveBinding(realm, ast.name, strictCode, env));
|
||||
case "JSXMemberExpression":
|
||||
return _singletons.Environment.GetValue(realm, env.evaluate((0, _jsx.convertJSXExpressionToIdentifier)(ast), strictCode));
|
||||
default:
|
||||
(0, _invariant2.default)(false, "Unknown JSX Identifier");
|
||||
}
|
||||
}
|
||||
|
||||
function evaluateJSXIdentifier(ast, strictCode, env, realm) {
|
||||
if (isTagName(ast)) {
|
||||
// special cased lower-case and custom elements
|
||||
return new _index.StringValue(realm, ast.name);
|
||||
}
|
||||
return evaluateJSXMemberExpression(ast, strictCode, env, realm);
|
||||
}
|
||||
|
||||
function evaluateJSXValue(value, strictCode, env, realm) {
|
||||
if (value != null) {
|
||||
switch (value.type) {
|
||||
case "JSXText":
|
||||
return new _index.StringValue(realm, value.value);
|
||||
case "StringLiteral":
|
||||
return new _index.StringValue(realm, value.value);
|
||||
case "JSXExpressionContainer":
|
||||
return _singletons.Environment.GetValue(realm, env.evaluate(value.expression, strictCode));
|
||||
case "JSXElement":
|
||||
return _singletons.Environment.GetValue(realm, env.evaluate(value, strictCode));
|
||||
default:
|
||||
(0, _invariant2.default)(false, "Unknown JSX value type: " + value.type);
|
||||
}
|
||||
}
|
||||
(0, _invariant2.default)(false, "Null or undefined value passed when trying to evaluate JSX node value");
|
||||
}
|
||||
|
||||
function isTagName(ast) {
|
||||
return ast.type === "JSXIdentifier" && /^[a-z]|\-/.test(ast.name);
|
||||
}
|
||||
|
||||
function getDefaultProps(elementType, env, realm) {
|
||||
var name = void 0;
|
||||
if (elementType.type === "JSXIdentifier") {
|
||||
name = elementType.name;
|
||||
}
|
||||
if (!isTagName(elementType) && typeof name === "string") {
|
||||
// find the value of "ComponentXXX.defaultProps"
|
||||
var defaultProps = _singletons.Environment.GetValue(realm, env.evaluate(t.memberExpression(t.identifier(name), t.identifier("defaultProps")), false));
|
||||
|
||||
if (defaultProps instanceof _index.ObjectValue) {
|
||||
return defaultProps;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function evaluateJSXChildren(children, strictCode, env, realm) {
|
||||
if (children.length === 0) {
|
||||
return null;
|
||||
}
|
||||
if (children.length === 1) {
|
||||
var singleChild = evaluateJSXValue(children[0], strictCode, env, realm);
|
||||
|
||||
if (singleChild instanceof _index.StringValue) {
|
||||
var text = cleanJSXElementLiteralChild(singleChild.value);
|
||||
if (text !== null) {
|
||||
singleChild.value = text;
|
||||
}
|
||||
}
|
||||
return singleChild;
|
||||
}
|
||||
var array = _singletons.Create.ArrayCreate(realm, 0);
|
||||
var dynamicChildrenLength = children.length;
|
||||
var dynamicIterator = 0;
|
||||
var lastChildValue = null;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var value = evaluateJSXValue(children[i], strictCode, env, realm);
|
||||
if (value instanceof _index.StringValue) {
|
||||
var _text = cleanJSXElementLiteralChild(value.value);
|
||||
if (_text === null) {
|
||||
dynamicChildrenLength--;
|
||||
// this is a space full of whitespace, so let's proceed
|
||||
continue;
|
||||
} else {
|
||||
value.value = _text;
|
||||
}
|
||||
}
|
||||
lastChildValue = value;
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, array, "" + dynamicIterator, value);
|
||||
dynamicIterator++;
|
||||
}
|
||||
if (dynamicChildrenLength === 1) {
|
||||
return lastChildValue;
|
||||
}
|
||||
|
||||
_singletons.Properties.Set(realm, array, "length", new _index.NumberValue(realm, dynamicChildrenLength), false);
|
||||
return array;
|
||||
}
|
||||
|
||||
function evaluateJSXAttributes(elementType, astAttributes, astChildren, strictCode, env, realm) {
|
||||
var attributes = new Map();
|
||||
var children = evaluateJSXChildren(astChildren, strictCode, env, realm);
|
||||
var defaultProps = getDefaultProps(elementType, env, realm);
|
||||
|
||||
// defaultProps are a bit like default function arguments
|
||||
// if an actual value exists, it should overwrite the default value
|
||||
if (defaultProps !== null) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = defaultProps.properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var _ref = _step.value;
|
||||
|
||||
var _ref2 = _slicedToArray(_ref, 1);
|
||||
|
||||
var key = _ref2[0];
|
||||
|
||||
var defaultPropValue = (0, _index2.Get)(realm, defaultProps, key);
|
||||
|
||||
if (defaultPropValue instanceof _index.Value) {
|
||||
if (key === "children") {
|
||||
if (children === null) {
|
||||
children = defaultPropValue;
|
||||
}
|
||||
} else {
|
||||
attributes.set(key, defaultPropValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = astAttributes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var astAttribute = _step2.value;
|
||||
|
||||
switch (astAttribute.type) {
|
||||
case "JSXAttribute":
|
||||
var name = astAttribute.name,
|
||||
value = astAttribute.value;
|
||||
|
||||
|
||||
(0, _invariant2.default)(name.type === "JSXIdentifier", "JSX attribute name type not supported: " + astAttribute.type);
|
||||
attributes.set(name.name, evaluateJSXValue(value, strictCode, env, realm));
|
||||
break;
|
||||
case "JSXSpreadAttribute":
|
||||
var spreadValue = _singletons.Environment.GetValue(realm, env.evaluate(astAttribute.argument, strictCode));
|
||||
|
||||
if (spreadValue instanceof _index.ObjectValue) {
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = spreadValue.properties[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var _ref3 = _step3.value;
|
||||
|
||||
var _ref4 = _slicedToArray(_ref3, 2);
|
||||
|
||||
var _key = _ref4[0];
|
||||
var spreadProp = _ref4[1];
|
||||
|
||||
if (spreadProp !== undefined && spreadProp.descriptor !== undefined) {
|
||||
var spreadPropValue = spreadProp.descriptor.value;
|
||||
|
||||
if (spreadPropValue instanceof _index.Value) {
|
||||
if (_key === "children") {
|
||||
children = spreadPropValue;
|
||||
} else {
|
||||
attributes.set(_key, spreadPropValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new _errors.FatalError("ObjectValues are the only supported value for JSX Spread Attributes");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
(0, _invariant2.default)(false, "Unknown JSX attribute type:: " + astAttribute.type);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
attributes: attributes,
|
||||
children: children
|
||||
};
|
||||
}
|
||||
|
||||
function createReactProps(realm, type, attributes, children, env) {
|
||||
var obj = _singletons.Create.ObjectCreate(realm, realm.intrinsics.ObjectPrototype);
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator4 = attributes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
||||
var _ref5 = _step4.value;
|
||||
|
||||
var _ref6 = _slicedToArray(_ref5, 2);
|
||||
|
||||
var key = _ref6[0];
|
||||
var value = _ref6[1];
|
||||
|
||||
if (typeof key === "string") {
|
||||
if (RESERVED_PROPS.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, key, value);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (children !== null) {
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "children", children);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function createReactElement(realm, type, key, ref, props) {
|
||||
var obj = _singletons.Create.ObjectCreate(realm, realm.intrinsics.ObjectPrototype);
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "$$typeof", (0, _utils.getReactSymbol)("react.element", realm));
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "type", type);
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "key", key);
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "ref", ref);
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "props", props);
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, "_owner", realm.intrinsics.null);
|
||||
return obj;
|
||||
}
|
||||
//# sourceMappingURL=JSXElement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/JSXElement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/JSXElement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
81
build/node_modules/prepack/lib/evaluators/LabeledStatement.js
generated
vendored
Normal file
81
build/node_modules/prepack/lib/evaluators/LabeledStatement.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
//1. Let newLabelSet be a new empty List.
|
||||
var newLabelSet = [];
|
||||
|
||||
//2. Return LabelledEvaluation of this LabelledStatement with argument newLabelSet.
|
||||
return LabelledEvaluation(newLabelSet, ast, strictCode, env, realm);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// ECMA262 13.13.14
|
||||
function LabelledEvaluation(labelSet, ast, strictCode, env, realm) {
|
||||
// LabelledStatement:LabelIdentifier:LabelledItem
|
||||
switch (ast.type) {
|
||||
case "LabeledStatement":
|
||||
var labeledAst = ast;
|
||||
// 1. Let label be the StringValue of LabelIdentifier.
|
||||
var label = labeledAst.label.name;
|
||||
|
||||
// 2. Append label as an element of labelSet.
|
||||
labelSet.push(label);
|
||||
|
||||
// 3. Let stmtResult be LabelledEvaluation of LabelledItem with argument labelSet.
|
||||
var normalCompletionStmtResult = void 0;
|
||||
try {
|
||||
normalCompletionStmtResult = LabelledEvaluation(labelSet, labeledAst.body, strictCode, env, realm);
|
||||
} catch (stmtResult) {
|
||||
// 4. If stmtResult.[[Type]] is break and SameValue(stmtResult.[[Target]], label) is true, then
|
||||
if (stmtResult instanceof _completions.BreakCompletion && stmtResult.target === label) {
|
||||
// a. Let stmtResult be NormalCompletion(stmtResult.[[Value]]).
|
||||
normalCompletionStmtResult = stmtResult.value;
|
||||
} else {
|
||||
// 5. Return Completion(stmtResult).
|
||||
throw stmtResult;
|
||||
}
|
||||
}
|
||||
// 5. Return Completion(stmtResult).
|
||||
return normalCompletionStmtResult;
|
||||
|
||||
case "VariableDeclaration":
|
||||
if (ast.kind === "var") {
|
||||
var _r = env.evaluate(ast, strictCode);
|
||||
(0, _invariant2.default)(_r instanceof _index.Value);
|
||||
return _r;
|
||||
}
|
||||
// fall through to throw
|
||||
case "FunctionDeclaration":
|
||||
case "ClassDeclaration":
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.SyntaxError, ast.type + " may not have a label");
|
||||
|
||||
default:
|
||||
var r = env.evaluate(ast, strictCode, labelSet);
|
||||
(0, _invariant2.default)(r instanceof _index.Value);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
// ECMA262 13.13.15
|
||||
/**
|
||||
* 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=LabeledStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/LabeledStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/LabeledStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/LabeledStatement.js"],"names":["ast","strictCode","env","realm","newLabelSet","LabelledEvaluation","labelSet","type","labeledAst","label","name","push","normalCompletionStmtResult","body","stmtResult","target","value","kind","r","evaluate","createErrorThrowCompletion","intrinsics","SyntaxError"],"mappings":";;;;;;kBAyEe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKM;AACnB;AACA,MAAIC,cAAc,EAAlB;;AAEA;AACA,SAAOC,mBAAmBD,WAAnB,EAAgCJ,GAAhC,EAAqCC,UAArC,EAAiDC,GAAjD,EAAsDC,KAAtD,CAAP;AACD,C;;AAvED;;AAEA;;AAEA;;;;;;AAEA;AACA,SAASE,kBAAT,CACEC,QADF,EAEEN,GAFF,EAGEC,UAHF,EAIEC,GAJF,EAKEC,KALF,EAMS;AACP;AACA,UAAQH,IAAIO,IAAZ;AACE,SAAK,kBAAL;AACE,UAAIC,aAAeR,GAAnB;AACA;AACA,UAAIS,QAAQD,WAAWC,KAAX,CAAiBC,IAA7B;;AAEA;AACAJ,eAASK,IAAT,CAAcF,KAAd;;AAEA;AACA,UAAIG,mCAAJ;AACA,UAAI;AACFA,qCAA6BP,mBAAmBC,QAAnB,EAA6BE,WAAWK,IAAxC,EAA8CZ,UAA9C,EAA0DC,GAA1D,EAA+DC,KAA/D,CAA7B;AACD,OAFD,CAEE,OAAOW,UAAP,EAAmB;AACnB;AACA,YAAIA,sDAAyCA,WAAWC,MAAX,KAAsBN,KAAnE,EAA0E;AACxE;AACAG,uCAA6BE,WAAWE,KAAxC;AACD,SAHD,MAGO;AACL;AACA,gBAAMF,UAAN;AACD;AACF;AACD;AACA,aAAOF,0BAAP;;AAEF,SAAK,qBAAL;AACE,UAAIZ,IAAIiB,IAAJ,KAAa,KAAjB,EAAwB;AACtB,YAAIC,KAAIhB,IAAIiB,QAAJ,CAAanB,GAAb,EAAkBC,UAAlB,CAAR;AACA,iCAAUiB,0BAAV;AACA,eAAOA,EAAP;AACD;AACH;AACA,SAAK,qBAAL;AACA,SAAK,kBAAL;AACE,YAAMf,MAAMiB,0BAAN,CAAiCjB,MAAMkB,UAAN,CAAiBC,WAAlD,EAA+DtB,IAAIO,IAAJ,GAAW,uBAA1E,CAAN;;AAEF;AACE,UAAIW,IAAIhB,IAAIiB,QAAJ,CAAanB,GAAb,EAAkBC,UAAlB,EAA8BK,QAA9B,CAAR;AACA,+BAAUY,yBAAV;AACA,aAAOA,CAAP;AAxCJ;AA0CD;;AAED;AAxEA","file":"LabeledStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { Value } from \"../values/index.js\";\nimport type { Reference } from \"../environment.js\";\nimport { BreakCompletion } from \"../completions.js\";\nimport type { BabelNodeLabeledStatement, BabelNode } from \"babel-types\";\nimport invariant from \"../invariant.js\";\n\n// ECMA262 13.13.14\nfunction LabelledEvaluation(\n labelSet: Array<string>,\n ast: BabelNode,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // LabelledStatement:LabelIdentifier:LabelledItem\n switch (ast.type) {\n case \"LabeledStatement\":\n let labeledAst = ((ast: any): BabelNodeLabeledStatement);\n // 1. Let label be the StringValue of LabelIdentifier.\n let label = labeledAst.label.name;\n\n // 2. Append label as an element of labelSet.\n labelSet.push(label);\n\n // 3. Let stmtResult be LabelledEvaluation of LabelledItem with argument labelSet.\n let normalCompletionStmtResult;\n try {\n normalCompletionStmtResult = LabelledEvaluation(labelSet, labeledAst.body, strictCode, env, realm);\n } catch (stmtResult) {\n // 4. If stmtResult.[[Type]] is break and SameValue(stmtResult.[[Target]], label) is true, then\n if (stmtResult instanceof BreakCompletion && stmtResult.target === label) {\n // a. Let stmtResult be NormalCompletion(stmtResult.[[Value]]).\n normalCompletionStmtResult = stmtResult.value;\n } else {\n // 5. Return Completion(stmtResult).\n throw stmtResult;\n }\n }\n // 5. Return Completion(stmtResult).\n return normalCompletionStmtResult;\n\n case \"VariableDeclaration\":\n if (ast.kind === \"var\") {\n let r = env.evaluate(ast, strictCode);\n invariant(r instanceof Value);\n return r;\n }\n // fall through to throw\n case \"FunctionDeclaration\":\n case \"ClassDeclaration\":\n throw realm.createErrorThrowCompletion(realm.intrinsics.SyntaxError, ast.type + \" may not have a label\");\n\n default:\n let r = env.evaluate(ast, strictCode, labelSet);\n invariant(r instanceof Value);\n return r;\n }\n}\n\n// ECMA262 13.13.15\nexport default function(\n ast: BabelNodeLabeledStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value | Reference {\n //1. Let newLabelSet be a new empty List.\n let newLabelSet = [];\n\n //2. Return LabelledEvaluation of this LabelledStatement with argument newLabelSet.\n return LabelledEvaluation(newLabelSet, ast, strictCode, env, realm);\n}\n"]}
|
||||
118
build/node_modules/prepack/lib/evaluators/LogicalExpression.js
generated
vendored
Normal file
118
build/node_modules/prepack/lib/evaluators/LogicalExpression.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var lref = env.evaluate(ast.left, strictCode);
|
||||
var lval = _singletons.Environment.GetValue(realm, lref);
|
||||
|
||||
if (lval instanceof _index.ConcreteValue) {
|
||||
var lbool = _singletons.To.ToBoolean(realm, lval);
|
||||
|
||||
if (ast.operator === "&&") {
|
||||
// ECMA262 12.13.3
|
||||
if (lbool === false) return lval;
|
||||
} else {
|
||||
(0, _invariant2.default)(ast.operator === "||");
|
||||
// ECMA262 12.13.3
|
||||
if (lbool === true) return lval;
|
||||
}
|
||||
|
||||
var rref = env.evaluate(ast.right, strictCode);
|
||||
return _singletons.Environment.GetValue(realm, rref);
|
||||
}
|
||||
(0, _invariant2.default)(lval instanceof _index.AbstractValue);
|
||||
var lcond = _singletons.Environment.GetConditionValue(realm, lref);
|
||||
|
||||
if (!lcond.mightNotBeFalse()) return ast.operator === "||" ? env.evaluate(ast.right, strictCode) : lval;
|
||||
if (!lcond.mightNotBeTrue()) return ast.operator === "&&" ? env.evaluate(ast.right, strictCode) : lval;
|
||||
|
||||
// Create empty effects for the case where ast.right is not evaluated
|
||||
|
||||
var _construct_empty_effe = (0, _realm.construct_empty_effects)(realm),
|
||||
_construct_empty_effe2 = _slicedToArray(_construct_empty_effe, 5),
|
||||
compl1 = _construct_empty_effe2[0],
|
||||
gen1 = _construct_empty_effe2[1],
|
||||
bindings1 = _construct_empty_effe2[2],
|
||||
properties1 = _construct_empty_effe2[3],
|
||||
createdObj1 = _construct_empty_effe2[4];
|
||||
|
||||
compl1; // ignore
|
||||
|
||||
// Evaluate ast.right in a sandbox to get its effects
|
||||
var wrapper = ast.operator === "&&" ? _singletons.Path.withCondition : _singletons.Path.withInverseCondition;
|
||||
|
||||
var _wrapper = wrapper(lval, function () {
|
||||
return realm.evaluateNodeForEffects(ast.right, strictCode, env);
|
||||
}),
|
||||
_wrapper2 = _slicedToArray(_wrapper, 5),
|
||||
compl2 = _wrapper2[0],
|
||||
gen2 = _wrapper2[1],
|
||||
bindings2 = _wrapper2[2],
|
||||
properties2 = _wrapper2[3],
|
||||
createdObj2 = _wrapper2[4];
|
||||
|
||||
// Join the effects, creating an abstract view of what happened, regardless
|
||||
// of the actual value of lval.
|
||||
// Note that converting a value to boolean never has a side effect, so we can
|
||||
// use lval as is for the join condition.
|
||||
|
||||
|
||||
var joinedEffects = void 0;
|
||||
if (ast.operator === "&&") {
|
||||
joinedEffects = _singletons.Join.joinEffects(realm, lval, [compl2, gen2, bindings2, properties2, createdObj2], [lval, gen1, bindings1, properties1, createdObj1]);
|
||||
} else {
|
||||
joinedEffects = _singletons.Join.joinEffects(realm, lval, [lval, gen1, bindings1, properties1, createdObj1], [compl2, gen2, bindings2, properties2, createdObj2]);
|
||||
}
|
||||
var completion = joinedEffects[0];
|
||||
if (completion instanceof _completions.PossiblyNormalCompletion) {
|
||||
// in this case the evaluation of ast.right may complete abruptly, which means that
|
||||
// not all control flow branches join into one flow at this point.
|
||||
// Consequently we have to continue tracking changes until the point where
|
||||
// all the branches come together into one.
|
||||
completion = realm.composeWithSavedCompletion(completion);
|
||||
}
|
||||
// Note that the effects of (non joining) abrupt branches are not included
|
||||
// in joinedEffects, but are tracked separately inside completion.
|
||||
realm.applyEffects(joinedEffects);
|
||||
|
||||
// return or throw completion
|
||||
if (completion instanceof _completions.AbruptCompletion) throw completion;
|
||||
(0, _invariant2.default)(completion instanceof _index.Value); // references do not survive join
|
||||
if (lval instanceof _index.Value && compl2 instanceof _index.Value) {
|
||||
// joinEffects does the right thing for the side effects of the second expression but for the result the join
|
||||
// produces a conditional expressions of the form (a ? b : a) for a && b and (a ? a : b) for a || b
|
||||
// Rather than look for this pattern everywhere, we override this behavior and replace the completion with
|
||||
// the actual logical operator. This helps with simplification and reasoning when dealing with path conditions.
|
||||
completion = _index.AbstractValue.createFromLogicalOp(realm, ast.operator, lval, compl2, ast.loc);
|
||||
}
|
||||
return completion;
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _realm = require("../realm.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=LogicalExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/LogicalExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/LogicalExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
56
build/node_modules/prepack/lib/evaluators/MemberExpression.js
generated
vendored
Normal file
56
build/node_modules/prepack/lib/evaluators/MemberExpression.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
if (ast.object.type === "Super") {
|
||||
return (0, _SuperProperty2.default)(ast, strictCode, env, realm);
|
||||
}
|
||||
|
||||
// 1. Let baseReference be the result of evaluating MemberExpression.
|
||||
var baseReference = env.evaluate(ast.object, strictCode);
|
||||
|
||||
// 2. Let baseValue be ? GetValue(baseReference).
|
||||
var baseValue = _singletons.Environment.GetValue(realm, baseReference);
|
||||
|
||||
var propertyNameValue = void 0;
|
||||
if (ast.computed) {
|
||||
// 3. Let propertyNameReference be the result of evaluating Expression.
|
||||
var propertyNameReference = env.evaluate(ast.property, strictCode);
|
||||
|
||||
// 4. Let propertyNameValue be ? GetValue(propertyNameReference).
|
||||
propertyNameValue = _singletons.Environment.GetValue(realm, propertyNameReference);
|
||||
} else {
|
||||
// 3. Let propertyNameString be StringValue of IdentifierName.
|
||||
propertyNameValue = new _index.StringValue(realm, ast.property.name);
|
||||
}
|
||||
|
||||
// 5. Let bv be ? RequireObjectCoercible(baseValue).
|
||||
var bv = (0, _index2.RequireObjectCoercible)(realm, baseValue, ast.object.loc);
|
||||
|
||||
// 6. Let propertyKey be ? ToPropertyKey(propertyNameValue).
|
||||
var propertyKey = _singletons.To.ToPropertyKeyPartial(realm, propertyNameValue);
|
||||
|
||||
// 7. If the code matched by the syntactic production that is being evaluated is strict mode code, let strict be true, else let strict be false.
|
||||
var strict = strictCode;
|
||||
|
||||
// 8. Return a value of type Reference whose base value is bv, whose referenced name is propertyKey, and whose strict reference flag is strict.
|
||||
return new _environment.Reference(bv, propertyKey, strict);
|
||||
};
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _SuperProperty = require("./SuperProperty");
|
||||
|
||||
var _SuperProperty2 = _interopRequireDefault(_SuperProperty);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=MemberExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/MemberExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/MemberExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/MemberExpression.js"],"names":["ast","strictCode","env","realm","object","type","baseReference","evaluate","baseValue","GetValue","propertyNameValue","computed","propertyNameReference","property","name","bv","loc","propertyKey","ToPropertyKeyPartial","strict"],"mappings":";;;;;;kBAqBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKF;AACX,MAAIH,IAAII,MAAJ,CAAWC,IAAX,KAAoB,OAAxB,EAAiC;AAC/B,WAAO,6BAAcL,GAAd,EAAmBC,UAAnB,EAA+BC,GAA/B,EAAoCC,KAApC,CAAP;AACD;;AAED;AACA,MAAIG,gBAAgBJ,IAAIK,QAAJ,CAAaP,IAAII,MAAjB,EAAyBH,UAAzB,CAApB;;AAEA;AACA,MAAIO,YAAY,wBAAYC,QAAZ,CAAqBN,KAArB,EAA4BG,aAA5B,CAAhB;;AAEA,MAAII,0BAAJ;AACA,MAAIV,IAAIW,QAAR,EAAkB;AAChB;AACA,QAAIC,wBAAwBV,IAAIK,QAAJ,CAAaP,IAAIa,QAAjB,EAA2BZ,UAA3B,CAA5B;;AAEA;AACAS,wBAAoB,wBAAYD,QAAZ,CAAqBN,KAArB,EAA4BS,qBAA5B,CAApB;AACD,GAND,MAMO;AACL;AACAF,wBAAoB,uBAAgBP,KAAhB,EAAuBH,IAAIa,QAAJ,CAAaC,IAApC,CAApB;AACD;;AAED;AACA,MAAIC,KAAK,oCAAuBZ,KAAvB,EAA8BK,SAA9B,EAAyCR,IAAII,MAAJ,CAAWY,GAApD,CAAT;;AAEA;AACA,MAAIC,cAAc,eAAGC,oBAAH,CAAwBf,KAAxB,EAA+BO,iBAA/B,CAAlB;;AAEA;AACA,MAAIS,SAASlB,UAAb;;AAEA;AACA,SAAO,2BAAcc,EAAd,EAAkBE,WAAlB,EAA+BE,MAA/B,CAAP;AACD,C;;AA/CD;;AACA;;AACA;;AACA;;AAEA","file":"MemberExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { Reference } from \"../environment.js\";\nimport { StringValue } from \"../values/index.js\";\nimport { RequireObjectCoercible } from \"../methods/index.js\";\nimport { Environment, To } from \"../singletons.js\";\nimport type { BabelNodeMemberExpression } from \"babel-types\";\nimport SuperProperty from \"./SuperProperty\";\n\n// ECMA262 12.3.2.1\nexport default function(\n ast: BabelNodeMemberExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Reference {\n if (ast.object.type === \"Super\") {\n return SuperProperty(ast, strictCode, env, realm);\n }\n\n // 1. Let baseReference be the result of evaluating MemberExpression.\n let baseReference = env.evaluate(ast.object, strictCode);\n\n // 2. Let baseValue be ? GetValue(baseReference).\n let baseValue = Environment.GetValue(realm, baseReference);\n\n let propertyNameValue;\n if (ast.computed) {\n // 3. Let propertyNameReference be the result of evaluating Expression.\n let propertyNameReference = env.evaluate(ast.property, strictCode);\n\n // 4. Let propertyNameValue be ? GetValue(propertyNameReference).\n propertyNameValue = Environment.GetValue(realm, propertyNameReference);\n } else {\n // 3. Let propertyNameString be StringValue of IdentifierName.\n propertyNameValue = new StringValue(realm, ast.property.name);\n }\n\n // 5. Let bv be ? RequireObjectCoercible(baseValue).\n let bv = RequireObjectCoercible(realm, baseValue, ast.object.loc);\n\n // 6. Let propertyKey be ? ToPropertyKey(propertyNameValue).\n let propertyKey = To.ToPropertyKeyPartial(realm, propertyNameValue);\n\n // 7. If the code matched by the syntactic production that is being evaluated is strict mode code, let strict be true, else let strict be false.\n let strict = strictCode;\n\n // 8. Return a value of type Reference whose base value is bv, whose referenced name is propertyKey, and whose strict reference flag is strict.\n return new Reference(bv, propertyKey, strict);\n}\n"]}
|
||||
12
build/node_modules/prepack/lib/evaluators/MetaProperty.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/MetaProperty.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return (0, _get.GetNewTarget)(realm);
|
||||
};
|
||||
|
||||
var _get = require("../methods/get.js");
|
||||
//# sourceMappingURL=MetaProperty.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/MetaProperty.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/MetaProperty.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/MetaProperty.js"],"names":["ast","strictCode","env","realm"],"mappings":";;;;;;kBAkBe,UAASA,GAAT,EAAqCC,UAArC,EAA0DC,GAA1D,EAAmFC,KAAnF,EAAwG;AACrH,SAAO,uBAAaA,KAAb,CAAP;AACD,C;;AAND","file":"MetaProperty.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { GetNewTarget } from \"../methods/get.js\";\nimport type { BabelNodeMetaProperty } from \"babel-types\";\n\n// ECMA 12.3.8.1\nexport default function(ast: BabelNodeMetaProperty, strictCode: boolean, env: LexicalEnvironment, realm: Realm): Value {\n return GetNewTarget(realm);\n}\n"]}
|
||||
63
build/node_modules/prepack/lib/evaluators/NewExpression.js
generated
vendored
Normal file
63
build/node_modules/prepack/lib/evaluators/NewExpression.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
realm.setNextExecutionContextLocation(ast.loc);
|
||||
|
||||
// ECMA262 12.3.3.1 We just implement this method inline since it's only called here.
|
||||
// 1. Return ? EvaluateNew(NewExpression, empty).
|
||||
|
||||
// ECMA262 2.3.3.1.1
|
||||
|
||||
var constructProduction = ast.callee;
|
||||
var args = ast.arguments;
|
||||
|
||||
// These steps not necessary due to our AST representation.
|
||||
// 1. Assert: constructProduction is either a NewExpression or a MemberExpression.
|
||||
// 2. Assert: arguments is either empty or an Arguments production.
|
||||
|
||||
// 3. Let ref be the result of evaluating constructProduction.
|
||||
var ref = env.evaluate(constructProduction, strictCode);
|
||||
|
||||
// 4. Let constructor be ? GetValue(ref).
|
||||
var constructor = _singletons.Environment.GetValue(realm, ref);
|
||||
|
||||
var argsList = void 0;
|
||||
|
||||
// 5. If arguments is empty, let argList be a new empty List.
|
||||
if (!args.length) {
|
||||
argsList = [];
|
||||
} else {
|
||||
// 6. Else,
|
||||
// a. Let argList be ArgumentListEvaluation of arguments.
|
||||
argsList = (0, _index2.ArgumentListEvaluation)(realm, strictCode, env, args); // BabelNodeNewExpression needs updating
|
||||
|
||||
// This step not necessary since we propagate completions with exceptions.
|
||||
// b. ReturnIfAbrupt(argList).
|
||||
}
|
||||
|
||||
// 7. If IsConstructor(constructor) is false, throw a TypeError exception.
|
||||
if ((0, _index2.IsConstructor)(realm, constructor) === false) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);
|
||||
}
|
||||
(0, _invariant2.default)(constructor instanceof _index.ObjectValue);
|
||||
|
||||
// 8. Return ? Construct(constructor, argList).
|
||||
return (0, _index2.Construct)(realm, constructor, argsList);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=NewExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/NewExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/NewExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/NewExpression.js"],"names":["ast","strictCode","env","realm","setNextExecutionContextLocation","loc","constructProduction","callee","args","arguments","ref","evaluate","constructor","GetValue","argsList","length","createErrorThrowCompletion","intrinsics","TypeError"],"mappings":";;;;;;kBAqBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKA;AACbA,QAAMC,+BAAN,CAAsCJ,IAAIK,GAA1C;;AAEA;AACA;;AAEA;;AAEA,MAAIC,sBAAsBN,IAAIO,MAA9B;AACA,MAAIC,OAAOR,IAAIS,SAAf;;AAEA;AACA;AACA;;AAEA;AACA,MAAIC,MAAMR,IAAIS,QAAJ,CAAaL,mBAAb,EAAkCL,UAAlC,CAAV;;AAEA;AACA,MAAIW,cAAc,wBAAYC,QAAZ,CAAqBV,KAArB,EAA4BO,GAA5B,CAAlB;;AAEA,MAAII,iBAAJ;;AAEA;AACA,MAAI,CAACN,KAAKO,MAAV,EAAkB;AAChBD,eAAW,EAAX;AACD,GAFD,MAEO;AACL;AACA;AACAA,eAAW,oCAAuBX,KAAvB,EAA8BF,UAA9B,EAA0CC,GAA1C,EAAgDM,IAAhD,CAAX,CAHK,CAGmE;;AAExE;AACA;AACD;;AAED;AACA,MAAI,2BAAcL,KAAd,EAAqBS,WAArB,MAAsC,KAA1C,EAAiD;AAC/C,UAAMT,MAAMa,0BAAN,CAAiCb,MAAMc,UAAN,CAAiBC,SAAlD,CAAN;AACD;AACD,2BAAUN,yCAAV;;AAEA;AACA,SAAO,uBAAUT,KAAV,EAAiBS,WAAjB,EAA8BE,QAA9B,CAAP;AACD,C;;AAxDD;;AACA;;AACA;;AAGA","file":"NewExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { ObjectValue } from \"../values/index.js\";\nimport { Environment } from \"../singletons.js\";\nimport { IsConstructor } from \"../methods/index.js\";\nimport { ArgumentListEvaluation } from \"../methods/index.js\";\nimport { Construct } from \"../methods/index.js\";\nimport invariant from \"../invariant.js\";\nimport type { BabelNodeNewExpression } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeNewExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): ObjectValue {\n realm.setNextExecutionContextLocation(ast.loc);\n\n // ECMA262 12.3.3.1 We just implement this method inline since it's only called here.\n // 1. Return ? EvaluateNew(NewExpression, empty).\n\n // ECMA262 2.3.3.1.1\n\n let constructProduction = ast.callee;\n let args = ast.arguments;\n\n // These steps not necessary due to our AST representation.\n // 1. Assert: constructProduction is either a NewExpression or a MemberExpression.\n // 2. Assert: arguments is either empty or an Arguments production.\n\n // 3. Let ref be the result of evaluating constructProduction.\n let ref = env.evaluate(constructProduction, strictCode);\n\n // 4. Let constructor be ? GetValue(ref).\n let constructor = Environment.GetValue(realm, ref);\n\n let argsList;\n\n // 5. If arguments is empty, let argList be a new empty List.\n if (!args.length) {\n argsList = [];\n } else {\n // 6. Else,\n // a. Let argList be ArgumentListEvaluation of arguments.\n argsList = ArgumentListEvaluation(realm, strictCode, env, (args: any)); // BabelNodeNewExpression needs updating\n\n // This step not necessary since we propagate completions with exceptions.\n // b. ReturnIfAbrupt(argList).\n }\n\n // 7. If IsConstructor(constructor) is false, throw a TypeError exception.\n if (IsConstructor(realm, constructor) === false) {\n throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError);\n }\n invariant(constructor instanceof ObjectValue);\n\n // 8. Return ? Construct(constructor, argList).\n return Construct(realm, constructor, argsList);\n}\n"]}
|
||||
10
build/node_modules/prepack/lib/evaluators/NullLiteral.js
generated
vendored
Normal file
10
build/node_modules/prepack/lib/evaluators/NullLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return realm.intrinsics.null;
|
||||
};
|
||||
//# sourceMappingURL=NullLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/NullLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/NullLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/NullLiteral.js"],"names":["ast","strictCode","env","realm","intrinsics","null"],"mappings":";;;;;;kBAgBe,UAASA,GAAT,EAAoCC,UAApC,EAAyDC,GAAzD,EAAkFC,KAAlF,EAAuG;AACpH,SAAOA,MAAMC,UAAN,CAAiBC,IAAxB;AACD,C","file":"NullLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport type { BabelNodeNullLiteral } from \"babel-types\";\n\nexport default function(ast: BabelNodeNullLiteral, strictCode: boolean, env: LexicalEnvironment, realm: Realm): Value {\n return realm.intrinsics.null;\n}\n"]}
|
||||
12
build/node_modules/prepack/lib/evaluators/NumericLiteral.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/NumericLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return new _index.NumberValue(realm, ast.value);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
//# sourceMappingURL=NumericLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/NumericLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/NumericLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/NumericLiteral.js"],"names":["ast","strictCode","env","realm","value"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,SAAO,uBAAgBA,KAAhB,EAAuBH,IAAII,KAA3B,CAAP;AACD,C;;AAVD","file":"NumericLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { NumberValue } from \"../values/index.js\";\nimport type { BabelNodeNumericLiteral } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeNumericLiteral,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n return new NumberValue(realm, ast.value);\n}\n"]}
|
||||
139
build/node_modules/prepack/lib/evaluators/ObjectExpression.js
generated
vendored
Normal file
139
build/node_modules/prepack/lib/evaluators/ObjectExpression.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.EvalPropertyName = EvalPropertyName;
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Let obj be ObjectCreate(%ObjectPrototype%).
|
||||
var obj = _singletons.Create.ObjectCreate(realm, realm.intrinsics.ObjectPrototype);
|
||||
|
||||
// 2. Let status be the result of performing PropertyDefinitionEvaluation of PropertyDefinitionList with arguments obj and true.
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = ast.properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var prop = _step.value;
|
||||
|
||||
if (prop.type === "ObjectProperty") {
|
||||
// 12.2.6.9 case 3
|
||||
// 1. Let propKey be the result of evaluating PropertyName.
|
||||
var propKey = EvalPropertyNamePartial(prop, env, realm, strictCode);
|
||||
|
||||
// 2. ReturnIfAbrupt(propKey).
|
||||
|
||||
// 3. Let exprValueRef be the result of evaluating AssignmentExpression.
|
||||
var exprValueRef = env.evaluate(prop.value, strictCode);
|
||||
|
||||
// 4. Let propValue be ? GetValue(exprValueRef).
|
||||
var propValue = _singletons.Environment.GetValue(realm, exprValueRef);
|
||||
|
||||
// 5. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
if ((0, _index2.IsAnonymousFunctionDefinition)(realm, prop.value)) {
|
||||
(0, _invariant2.default)(propValue instanceof _index.ObjectValue);
|
||||
|
||||
// a. Let hasNameProperty be ? HasOwnProperty(propValue, "name").
|
||||
var hasNameProperty = (0, _index2.HasOwnProperty)(realm, propValue, "name");
|
||||
|
||||
// b. If hasNameProperty is false, perform SetFunctionName(propValue, propKey).
|
||||
(0, _invariant2.default)(!hasNameProperty); // No expression that passes through IsAnonymousFunctionDefinition can have it here
|
||||
_singletons.Functions.SetFunctionName(realm, propValue, propKey);
|
||||
}
|
||||
|
||||
// 6. Assert: enumerable is true.
|
||||
|
||||
// 7. Return CreateDataPropertyOrThrow(object, propKey, propValue).
|
||||
if (propKey instanceof _index.AbstractValue) {
|
||||
if (propKey.mightNotBeString()) {
|
||||
var error = new _errors.CompilerDiagnostic("property key value is unknown", prop.loc, "PP0011", "FatalError");
|
||||
if (realm.handleError(error) === "Fail") throw new _errors.FatalError();
|
||||
continue; // recover by ignoring the property, which is only ever safe to do if the property is dead,
|
||||
// which is assuming a bit much, hence the designation as a FatalError.
|
||||
}
|
||||
obj.$SetPartial(propKey, propValue, obj);
|
||||
} else {
|
||||
_singletons.Create.CreateDataPropertyOrThrow(realm, obj, propKey, propValue);
|
||||
}
|
||||
} else {
|
||||
(0, _invariant2.default)(prop.type === "ObjectMethod");
|
||||
_singletons.Properties.PropertyDefinitionEvaluation(realm, prop, obj, env, strictCode, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. ReturnIfAbrupt(status).
|
||||
|
||||
// 4. Return obj.
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var _errors = require("../errors.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// Returns the result of evaluating PropertyName.
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function EvalPropertyName(prop, env, realm, strictCode) {
|
||||
var result = EvalPropertyNamePartial(prop, env, realm, strictCode);
|
||||
if (result instanceof _index.AbstractValue) {
|
||||
var error = new _errors.CompilerDiagnostic("unknown computed property name", prop.loc, "PP0014", "FatalError");
|
||||
realm.handleError(error);
|
||||
throw new _errors.FatalError();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function EvalPropertyNamePartial(prop, env, realm, strictCode) {
|
||||
if (prop.computed) {
|
||||
var propertyKeyName = _singletons.Environment.GetValue(realm, env.evaluate(prop.key, strictCode));
|
||||
if (propertyKeyName instanceof _index.AbstractValue) return propertyKeyName;
|
||||
(0, _invariant2.default)(propertyKeyName instanceof _index.ConcreteValue);
|
||||
return _singletons.To.ToPropertyKey(realm, propertyKeyName);
|
||||
} else {
|
||||
if (prop.key.type === "Identifier") {
|
||||
return new _index.StringValue(realm, prop.key.name);
|
||||
} else {
|
||||
var _propertyKeyName = _singletons.Environment.GetValue(realm, env.evaluate(prop.key, strictCode));
|
||||
(0, _invariant2.default)(_propertyKeyName instanceof _index.ConcreteValue); // syntax only allows literals if !prop.computed
|
||||
return _singletons.To.ToString(realm, _propertyKeyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ECMA262 12.2.6.8
|
||||
//# sourceMappingURL=ObjectExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ObjectExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ObjectExpression.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
600
build/node_modules/prepack/lib/evaluators/Program.js
generated
vendored
Normal file
600
build/node_modules/prepack/lib/evaluators/Program.js
generated
vendored
Normal file
@@ -0,0 +1,600 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.GlobalDeclarationInstantiation = GlobalDeclarationInstantiation;
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
strictCode = (0, _strict2.default)(ast);
|
||||
|
||||
GlobalDeclarationInstantiation(realm, ast, env, strictCode);
|
||||
|
||||
var val = void 0;
|
||||
|
||||
var _iteratorNormalCompletion11 = true;
|
||||
var _didIteratorError11 = false;
|
||||
var _iteratorError11 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator11 = ast.body[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
|
||||
var node = _step11.value;
|
||||
|
||||
if (node.type !== "FunctionDeclaration") {
|
||||
var res = env.evaluateCompletionDeref(node, strictCode);
|
||||
if (res instanceof _completions.AbruptCompletion) {
|
||||
if (!realm.useAbstractInterpretation) throw res;
|
||||
// We are about the leave this program and this presents a join point where all non exeptional control flows
|
||||
// converge into a single flow using the joined effects as the new state.
|
||||
res = _singletons.Functions.incorporateSavedCompletion(realm, res);
|
||||
// The call to incorporateSavedCompletion above, has taken care of the join because res is abrupt.
|
||||
// What remains to be done is to emit throw statements to the generator.
|
||||
if (res instanceof _completions.JoinedAbruptCompletions) {
|
||||
emitConditionalThrow(res.joinCondition, res.consequent, res.alternate);
|
||||
res = res.value;
|
||||
} else if (res instanceof _completions.ThrowCompletion) {
|
||||
emitThrow(res.value);
|
||||
res = realm.intrinsics.undefined;
|
||||
} else {
|
||||
(0, _invariant2.default)(false); // other kinds of abrupt completions should not get this far
|
||||
}
|
||||
}
|
||||
if (!(res instanceof _index.EmptyValue)) {
|
||||
val = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError11 = true;
|
||||
_iteratorError11 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion11 && _iterator11.return) {
|
||||
_iterator11.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError11) {
|
||||
throw _iteratorError11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var directives = ast.directives;
|
||||
if (!val && directives && directives.length) {
|
||||
var directive = directives[directives.length - 1];
|
||||
val = env.evaluate(directive, strictCode);
|
||||
(0, _invariant2.default)(val instanceof _index.Value);
|
||||
}
|
||||
|
||||
// We are about to leave this program and this presents a join point where all control flows
|
||||
// converge into a single flow and the joined effects become the final state.
|
||||
if (val instanceof _index.Value) {
|
||||
val = _singletons.Functions.incorporateSavedCompletion(realm, val);
|
||||
if (val instanceof _completions.PossiblyNormalCompletion) {
|
||||
// There are still some conditional throws to emit and state still has to be joined in.
|
||||
_singletons.Join.stopEffectCaptureJoinApplyAndReturnCompletion(val, new _completions.ReturnCompletion(realm.intrinsics.undefined), realm);
|
||||
// The global state has now been updated to the join of all the flows reaching this join point
|
||||
emitConditionalThrow(val.joinCondition, val.consequent, val.alternate);
|
||||
val = val.value;
|
||||
}
|
||||
} else {
|
||||
// program was empty. Nothing to do.
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(val === undefined || val instanceof _index.Value);
|
||||
return val || realm.intrinsics.empty;
|
||||
|
||||
function emitThrow(value) {
|
||||
var generator = realm.generator;
|
||||
(0, _invariant2.default)(generator !== undefined);
|
||||
generator.emitStatement([value], function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 1),
|
||||
argument = _ref2[0];
|
||||
|
||||
return t.throwStatement(argument);
|
||||
});
|
||||
}
|
||||
|
||||
function emitConditionalThrow(condition, trueBranch, falseBranch) {
|
||||
var generator = realm.generator;
|
||||
(0, _invariant2.default)(generator !== undefined);
|
||||
|
||||
var _deconstruct = deconstruct(condition, trueBranch, falseBranch),
|
||||
_deconstruct2 = _slicedToArray(_deconstruct, 2),
|
||||
args = _deconstruct2[0],
|
||||
buildfunc = _deconstruct2[1];
|
||||
|
||||
generator.emitStatement(args, buildfunc);
|
||||
}
|
||||
|
||||
function deconstruct(condition, trueBranch, falseBranch) {
|
||||
var targs = void 0;
|
||||
var tfunc = void 0;
|
||||
var fargs = void 0;
|
||||
var ffunc = void 0;
|
||||
if (trueBranch instanceof _completions.JoinedAbruptCompletions) {
|
||||
var _deconstruct3 = deconstruct(trueBranch.joinCondition, trueBranch.consequent, trueBranch.alternate);
|
||||
|
||||
var _deconstruct4 = _slicedToArray(_deconstruct3, 2);
|
||||
|
||||
targs = _deconstruct4[0];
|
||||
tfunc = _deconstruct4[1];
|
||||
} else if (trueBranch instanceof _completions.ThrowCompletion) {
|
||||
targs = [trueBranch.value];
|
||||
tfunc = function tfunc(_ref3) {
|
||||
var _ref4 = _slicedToArray(_ref3, 1),
|
||||
argument = _ref4[0];
|
||||
|
||||
return t.throwStatement(argument);
|
||||
};
|
||||
} else {
|
||||
targs = [];
|
||||
tfunc = function tfunc(nodes) {
|
||||
return t.emptyStatement();
|
||||
};
|
||||
}
|
||||
if (falseBranch instanceof _completions.JoinedAbruptCompletions) {
|
||||
var _deconstruct5 = deconstruct(falseBranch.joinCondition, falseBranch.consequent, falseBranch.alternate);
|
||||
|
||||
var _deconstruct6 = _slicedToArray(_deconstruct5, 2);
|
||||
|
||||
fargs = _deconstruct6[0];
|
||||
ffunc = _deconstruct6[1];
|
||||
} else if (falseBranch instanceof _completions.ThrowCompletion) {
|
||||
fargs = [falseBranch.value];
|
||||
ffunc = function ffunc(_ref5) {
|
||||
var _ref6 = _slicedToArray(_ref5, 1),
|
||||
argument = _ref6[0];
|
||||
|
||||
return t.throwStatement(argument);
|
||||
};
|
||||
} else {
|
||||
fargs = [];
|
||||
ffunc = function ffunc(nodes) {
|
||||
return t.emptyStatement();
|
||||
};
|
||||
}
|
||||
var args = [condition].concat(targs).concat(fargs);
|
||||
var func = function func(nodes) {
|
||||
return t.ifStatement(nodes[0], tfunc(nodes.splice(1, targs.length)), ffunc(nodes.splice(targs.length + 1, fargs.length)));
|
||||
};
|
||||
return [args, func];
|
||||
}
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _strict = require("../utils/strict.js");
|
||||
|
||||
var _strict2 = _interopRequireDefault(_strict);
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
var _traverseFast = require("../utils/traverse-fast.js");
|
||||
|
||||
var _traverseFast2 = _interopRequireDefault(_traverseFast);
|
||||
|
||||
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 }; }
|
||||
|
||||
// ECMA262 15.1.11
|
||||
function GlobalDeclarationInstantiation(realm, ast, env, strictCode) {
|
||||
realm.getRunningContext().isStrict = realm.isStrict = strictCode;
|
||||
|
||||
// 1. Let envRec be env's EnvironmentRecord.
|
||||
var envRec = env.environmentRecord;
|
||||
|
||||
// 2. Assert: envRec is a global Environment Record.
|
||||
(0, _invariant2.default)(envRec instanceof _environment.GlobalEnvironmentRecord, "expected global environment record");
|
||||
|
||||
// 3. Let lexNames be the LexicallyDeclaredNames of script.
|
||||
var lexNames = [];
|
||||
|
||||
// 4. Let varNames be the VarDeclaredNames of script.
|
||||
var varNames = [];
|
||||
|
||||
(0, _traverseFast2.default)(ast, function (node) {
|
||||
if (node.type === "VariableDeclaration") {
|
||||
if (node.kind === "var") {
|
||||
varNames = varNames.concat(_singletons.Environment.BoundNames(realm, node));
|
||||
} else {
|
||||
lexNames = lexNames.concat(_singletons.Environment.BoundNames(realm, node));
|
||||
}
|
||||
} else if (node.type === "FunctionExpression" || node.type === "FunctionDeclaration") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 5. For each name in lexNames, do
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = lexNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var name = _step.value;
|
||||
|
||||
// a. If envRec.HasVarDeclaration(name) is true, throw a SyntaxError exception.
|
||||
if (envRec.HasVarDeclaration(name)) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.SyntaxError, name + " already declared with var");
|
||||
}
|
||||
|
||||
// b. If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
|
||||
if (envRec.HasLexicalDeclaration(name)) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.SyntaxError, name + " already declared with let or const");
|
||||
}
|
||||
|
||||
// c. Let hasRestrictedGlobal be ? envRec.HasRestrictedGlobalProperty(name).
|
||||
var hasRestrictedGlobal = envRec.HasRestrictedGlobalProperty(name);
|
||||
|
||||
// d. If hasRestrictedGlobal is true, throw a SyntaxError exception.
|
||||
if (hasRestrictedGlobal) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.SyntaxError, name + " global object is restricted");
|
||||
}
|
||||
}
|
||||
|
||||
// 6. For each name in varNames, do
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = varNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var _name = _step2.value;
|
||||
|
||||
// a. If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
|
||||
if (envRec.HasLexicalDeclaration(_name)) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.SyntaxError, _name + " already declared with let or const");
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Let varDeclarations be the VarScopedDeclarations of script.
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var varDeclarations = _singletons.Functions.FindVarScopedDeclarations(ast);
|
||||
|
||||
// 8. Let functionsToInitialize be a new empty List.
|
||||
var functionsToInitialize = [];
|
||||
|
||||
// 9. Let declaredFunctionNames be a new empty List.
|
||||
var declaredFunctionNames = [];
|
||||
|
||||
// 10. For each d in varDeclarations, in reverse list order do
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = varDeclarations.reverse()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var d = _step3.value;
|
||||
|
||||
// a. If d is neither a VariableDeclaration or a ForBinding, then
|
||||
if (d.type !== "VariableDeclaration") {
|
||||
// i. Assert: d is either a FunctionDeclaration or a GeneratorDeclaration.
|
||||
(0, _invariant2.default)(d.type === "FunctionDeclaration", "expected function");
|
||||
|
||||
// ii. NOTE If there are multiple FunctionDeclarations for the same name, the last declaration is used.
|
||||
|
||||
// iii. Let fn be the sole element of the BoundNames of d.
|
||||
var fn = _singletons.Environment.BoundNames(realm, d)[0];
|
||||
|
||||
// iv. If fn is not an element of declaredFunctionNames, then
|
||||
if (declaredFunctionNames.indexOf(fn) < 0) {
|
||||
// 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(fn).
|
||||
var fnDefinable = envRec.CanDeclareGlobalFunction(fn);
|
||||
|
||||
// 2. If fnDefinable is false, throw a TypeError exception.
|
||||
if (!fnDefinable) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, fn + ": global function declarations are not allowed");
|
||||
}
|
||||
|
||||
// 3. Append fn to declaredFunctionNames.
|
||||
declaredFunctionNames.push(fn);
|
||||
|
||||
// 4. Insert d as the first element of functionsToInitialize.
|
||||
functionsToInitialize.unshift(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 11. Let declaredVarNames be a new empty List.
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var declaredVarNames = [];
|
||||
|
||||
// 12. For each d in varDeclarations, do
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator4 = varDeclarations[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
||||
var _d = _step4.value;
|
||||
|
||||
// a. If d is a VariableDeclaration or a ForBinding, then
|
||||
if (_d.type === "VariableDeclaration") {
|
||||
// i. For each String vn in the BoundNames of d, do
|
||||
var _iteratorNormalCompletion9 = true;
|
||||
var _didIteratorError9 = false;
|
||||
var _iteratorError9 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator9 = _singletons.Environment.BoundNames(realm, _d)[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
||||
var _vn = _step9.value;
|
||||
|
||||
// ii. If vn is not an element of declaredFunctionNames, then
|
||||
if (declaredFunctionNames.indexOf(_vn) < 0) {
|
||||
// 1. Let vnDefinable be ? envRec.CanDeclareGlobalVar(vn).
|
||||
var vnDefinable = envRec.CanDeclareGlobalVar(_vn);
|
||||
|
||||
// 2. If vnDefinable is false, throw a TypeError exception.
|
||||
if (!vnDefinable) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, _vn + ": global variable declarations are not allowed");
|
||||
}
|
||||
|
||||
// 3. If vn is not an element of declaredVarNames, then
|
||||
if (declaredVarNames.indexOf(_vn) < 0) {
|
||||
// a. Append vn to declaredVarNames.
|
||||
declaredVarNames.push(_vn);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError9 = true;
|
||||
_iteratorError9 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion9 && _iterator9.return) {
|
||||
_iterator9.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError9) {
|
||||
throw _iteratorError9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 13. NOTE: No abnormal terminations occur after this algorithm step if the global object is an ordinary object. However, if the global object is a Proxy exotic object it may exhibit behaviours that cause abnormal terminations in some of the following steps.
|
||||
|
||||
// 14. NOTE: Annex B.3.3.2 adds additional steps at this point.
|
||||
|
||||
// 15. Let lexDeclarations be the LexicallyScopedDeclarations of script.
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var lexDeclarations = [];
|
||||
var _iteratorNormalCompletion5 = true;
|
||||
var _didIteratorError5 = false;
|
||||
var _iteratorError5 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator5 = ast.body[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
||||
var s = _step5.value;
|
||||
|
||||
if (s.type === "VariableDeclaration" && s.kind !== "var") {
|
||||
lexDeclarations.push(s);
|
||||
}
|
||||
}
|
||||
|
||||
// 16. For each element d in lexDeclarations do
|
||||
} catch (err) {
|
||||
_didIteratorError5 = true;
|
||||
_iteratorError5 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion5 && _iterator5.return) {
|
||||
_iterator5.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError5) {
|
||||
throw _iteratorError5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion6 = true;
|
||||
var _didIteratorError6 = false;
|
||||
var _iteratorError6 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator6 = lexDeclarations[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
||||
var _d2 = _step6.value;
|
||||
|
||||
// a. NOTE Lexically declared names are only instantiated here but not initialized.
|
||||
|
||||
// b. For each element dn of the BoundNames of d do
|
||||
var _iteratorNormalCompletion10 = true;
|
||||
var _didIteratorError10 = false;
|
||||
var _iteratorError10 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator10 = _singletons.Environment.BoundNames(realm, _d2)[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
||||
var dn = _step10.value;
|
||||
|
||||
// i. If IsConstantDeclaration of d is true, then
|
||||
if (_d2.kind === "const") {
|
||||
// 1. Perform ? envRec.CreateImmutableBinding(dn, true).
|
||||
envRec.CreateImmutableBinding(dn, true);
|
||||
} else {
|
||||
// ii. Else,
|
||||
// 1. Perform ? envRec.CreateMutableBinding(dn, false).
|
||||
envRec.CreateMutableBinding(dn, false);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError10 = true;
|
||||
_iteratorError10 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion10 && _iterator10.return) {
|
||||
_iterator10.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError10) {
|
||||
throw _iteratorError10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 17. For each production f in functionsToInitialize, do
|
||||
} catch (err) {
|
||||
_didIteratorError6 = true;
|
||||
_iteratorError6 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion6 && _iterator6.return) {
|
||||
_iterator6.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError6) {
|
||||
throw _iteratorError6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion7 = true;
|
||||
var _didIteratorError7 = false;
|
||||
var _iteratorError7 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator7 = functionsToInitialize[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
||||
var f = _step7.value;
|
||||
|
||||
// a. Let fn be the sole element of the BoundNames of f.
|
||||
var fn = _singletons.Environment.BoundNames(realm, f)[0];
|
||||
|
||||
// b. Let fo be the result of performing InstantiateFunctionObject for f with argument env.
|
||||
var fo = env.evaluate(f, strictCode);
|
||||
(0, _invariant2.default)(fo instanceof _index.Value);
|
||||
|
||||
// c. Perform ? envRec.CreateGlobalFunctionBinding(fn, fo, false).
|
||||
envRec.CreateGlobalFunctionBinding(fn, fo, false);
|
||||
}
|
||||
|
||||
// 18. For each String vn in declaredVarNames, in list order do
|
||||
} catch (err) {
|
||||
_didIteratorError7 = true;
|
||||
_iteratorError7 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion7 && _iterator7.return) {
|
||||
_iterator7.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError7) {
|
||||
throw _iteratorError7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion8 = true;
|
||||
var _didIteratorError8 = false;
|
||||
var _iteratorError8 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator8 = declaredVarNames[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
||||
var vn = _step8.value;
|
||||
|
||||
// a. Perform ? envRec.CreateGlobalVarBinding(vn, false).
|
||||
envRec.CreateGlobalVarBinding(vn, false);
|
||||
}
|
||||
|
||||
// 19. Return NormalCompletion(empty).
|
||||
} catch (err) {
|
||||
_didIteratorError8 = true;
|
||||
_iteratorError8 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion8 && _iterator8.return) {
|
||||
_iterator8.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError8) {
|
||||
throw _iteratorError8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return realm.intrinsics.empty;
|
||||
}
|
||||
//# sourceMappingURL=Program.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/Program.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/Program.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
build/node_modules/prepack/lib/evaluators/RegExpLiteral.js
generated
vendored
Normal file
14
build/node_modules/prepack/lib/evaluators/RegExpLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return (0, _index2.RegExpCreate)(realm, new _index.StringValue(realm, ast.pattern), ast.flags ? new _index.StringValue(realm, ast.flags) : undefined);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
//# sourceMappingURL=RegExpLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/RegExpLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/RegExpLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/RegExpLiteral.js"],"names":["ast","strictCode","env","realm","pattern","flags","undefined"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,SAAO,0BACLA,KADK,EAEL,uBAAgBA,KAAhB,EAAuBH,IAAII,OAA3B,CAFK,EAGLJ,IAAIK,KAAJ,GAAY,uBAAgBF,KAAhB,EAAuBH,IAAIK,KAA3B,CAAZ,GAAgDC,SAH3C,CAAP;AAKD,C;;AAfD;;AACA","file":"RegExpLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { Value, StringValue } from \"../values/index.js\";\nimport { RegExpCreate } from \"../methods/index.js\";\nimport type { BabelNodeRegExpLiteral } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeRegExpLiteral,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n return RegExpCreate(\n realm,\n new StringValue(realm, ast.pattern),\n ast.flags ? new StringValue(realm, ast.flags) : undefined\n );\n}\n"]}
|
||||
20
build/node_modules/prepack/lib/evaluators/ReturnStatement.js
generated
vendored
Normal file
20
build/node_modules/prepack/lib/evaluators/ReturnStatement.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var arg = void 0;
|
||||
if (ast.argument) {
|
||||
arg = _singletons.Environment.GetValue(realm, env.evaluate(ast.argument, strictCode));
|
||||
} else {
|
||||
arg = realm.intrinsics.undefined;
|
||||
}
|
||||
throw new _completions.ReturnCompletion(arg, ast.loc);
|
||||
};
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
//# sourceMappingURL=ReturnStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ReturnStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ReturnStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ReturnStatement.js"],"names":["ast","strictCode","env","realm","arg","argument","GetValue","evaluate","intrinsics","undefined","loc"],"mappings":";;;;;;kBAkBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,MAAIC,YAAJ;AACA,MAAIJ,IAAIK,QAAR,EAAkB;AAChBD,UAAM,wBAAYE,QAAZ,CAAqBH,KAArB,EAA4BD,IAAIK,QAAJ,CAAaP,IAAIK,QAAjB,EAA2BJ,UAA3B,CAA5B,CAAN;AACD,GAFD,MAEO;AACLG,UAAMD,MAAMK,UAAN,CAAiBC,SAAvB;AACD;AACD,QAAM,kCAAqBL,GAArB,EAA0BJ,IAAIU,GAA9B,CAAN;AACD,C;;AAjBD;;AACA","file":"ReturnStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { Environment } from \"../singletons.js\";\nimport { ReturnCompletion } from \"../completions.js\";\nimport type { BabelNodeReturnStatement } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeReturnStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n let arg;\n if (ast.argument) {\n arg = Environment.GetValue(realm, env.evaluate(ast.argument, strictCode));\n } else {\n arg = realm.intrinsics.undefined;\n }\n throw new ReturnCompletion(arg, ast.loc);\n}\n"]}
|
||||
46
build/node_modules/prepack/lib/evaluators/SequenceExpression.js
generated
vendored
Normal file
46
build/node_modules/prepack/lib/evaluators/SequenceExpression.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
(0, _invariant2.default)(ast.expressions.length > 0);
|
||||
var val = void 0;
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = ast.expressions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var node = _step.value;
|
||||
|
||||
val = _singletons.Environment.GetValue(realm, env.evaluate(node, strictCode));
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(val !== undefined);
|
||||
return val;
|
||||
};
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=SequenceExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/SequenceExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/SequenceExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/SequenceExpression.js"],"names":["ast","strictCode","env","realm","expressions","length","val","node","GetValue","evaluate","undefined"],"mappings":";;;;;;kBAkBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,2BAAUH,IAAII,WAAJ,CAAgBC,MAAhB,GAAyB,CAAnC;AACA,MAAIC,YAAJ;AAFO;AAAA;AAAA;;AAAA;AAGP,yBAAiBN,IAAII,WAArB,8HAAkC;AAAA,UAAzBG,IAAyB;;AAChCD,YAAM,wBAAYE,QAAZ,CAAqBL,KAArB,EAA4BD,IAAIO,QAAJ,CAAaF,IAAb,EAAmBN,UAAnB,CAA5B,CAAN;AACD;AALM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAMP,2BAAUK,QAAQI,SAAlB;AACA,SAAOJ,GAAP;AACD,C;;AAjBD;;AAEA","file":"SequenceExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { Environment } from \"../singletons.js\";\nimport type { BabelNodeSequenceExpression } from \"babel-types\";\nimport invariant from \"../invariant.js\";\n\nexport default function(\n ast: BabelNodeSequenceExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n invariant(ast.expressions.length > 0);\n let val;\n for (let node of ast.expressions) {\n val = Environment.GetValue(realm, env.evaluate(node, strictCode));\n }\n invariant(val !== undefined);\n return val;\n}\n"]}
|
||||
12
build/node_modules/prepack/lib/evaluators/StringLiteral.js
generated
vendored
Normal file
12
build/node_modules/prepack/lib/evaluators/StringLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
return new _index.StringValue(realm, ast.value);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
//# sourceMappingURL=StringLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/StringLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/StringLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/StringLiteral.js"],"names":["ast","strictCode","env","realm","value"],"mappings":";;;;;;kBAiBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,SAAO,uBAAgBA,KAAhB,EAAuBH,IAAII,KAA3B,CAAP;AACD,C;;AAVD","file":"StringLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { StringValue } from \"../values/index.js\";\nimport type { BabelNodeStringLiteral } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeStringLiteral,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n return new StringValue(realm, ast.value);\n}\n"]}
|
||||
87
build/node_modules/prepack/lib/evaluators/SuperCall.js
generated
vendored
Normal file
87
build/node_modules/prepack/lib/evaluators/SuperCall.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = SuperCall;
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function GetSuperConstructor(realm) {
|
||||
// 1. Let envRec be GetThisEnvironment( ).
|
||||
var envRec = _singletons.Environment.GetThisEnvironment(realm);
|
||||
|
||||
// 2. Assert: envRec is a function Environment Record.
|
||||
(0, _invariant2.default)(envRec instanceof _environment.FunctionEnvironmentRecord);
|
||||
|
||||
// 3. Let activeFunction be envRec.[[FunctionObject]].
|
||||
var activeFunction = envRec.$FunctionObject;
|
||||
|
||||
// 4. Let superConstructor be activeFunction.[[GetPrototypeOf]]().
|
||||
var superConstructor = activeFunction.$GetPrototypeOf();
|
||||
|
||||
// 5. ReturnIfAbrupt(superConstructor).
|
||||
|
||||
// 6. If IsConstructor(superConstructor) is false, throw a TypeError exception.
|
||||
if (!(0, _index2.IsConstructor)(realm, superConstructor)) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, "super called outside of constructor");
|
||||
}
|
||||
(0, _invariant2.default)(superConstructor instanceof _index.ObjectValue);
|
||||
|
||||
// 7. Return superConstructor.
|
||||
return superConstructor;
|
||||
}
|
||||
|
||||
// ECMA262 12.3.5.1
|
||||
function SuperCall(Arguments, strictCode, env, realm) {
|
||||
// 1. Let newTarget be GetNewTarget().
|
||||
var newTarget = (0, _index2.GetNewTarget)(realm);
|
||||
|
||||
// 2. If newTarget is undefined, throw a ReferenceError exception.
|
||||
if (newTarget instanceof _index.UndefinedValue) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError, "newTarget is undefined");
|
||||
}
|
||||
|
||||
// 3. Let func be GetSuperConstructor().
|
||||
var func = GetSuperConstructor(realm);
|
||||
|
||||
// 4. ReturnIfAbrupt(func).
|
||||
|
||||
// 5. Let argList be ArgumentListEvaluation of Arguments.
|
||||
var argList = (0, _index2.ArgumentListEvaluation)(realm, strictCode, env, Arguments);
|
||||
|
||||
// 6. ReturnIfAbrupt(argList).
|
||||
|
||||
// 7. Let result be Construct(func, argList, newTarget).
|
||||
var result = (0, _index2.Construct)(realm, func, argList, newTarget);
|
||||
|
||||
// 8. ReturnIfAbrupt(result).
|
||||
|
||||
// 9. Let thisER be GetThisEnvironment( ).
|
||||
var thisER = _singletons.Environment.GetThisEnvironment(realm);
|
||||
|
||||
// 10. Return thisER.BindThisValue(result).
|
||||
return thisER.BindThisValue(result);
|
||||
}
|
||||
//# sourceMappingURL=SuperCall.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/SuperCall.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/SuperCall.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/SuperCall.js"],"names":["SuperCall","GetSuperConstructor","realm","envRec","GetThisEnvironment","activeFunction","$FunctionObject","superConstructor","$GetPrototypeOf","createErrorThrowCompletion","intrinsics","TypeError","Arguments","strictCode","env","newTarget","ReferenceError","func","argList","result","thisER","BindThisValue"],"mappings":";;;;;kBA8CwBA,S;;AAhCxB;;AACA;;AACA;;AACA;;AACA;;;;;;AAlBA;;;;;;;;;AAoBA,SAASC,mBAAT,CAA6BC,KAA7B,EAA2C;AACzC;AACA,MAAIC,SAAS,wBAAYC,kBAAZ,CAA+BF,KAA/B,CAAb;;AAEA;AACA,2BAAUC,wDAAV;;AAEA;AACA,MAAIE,iBAAiBF,OAAOG,eAA5B;;AAEA;AACA,MAAIC,mBAAmBF,eAAeG,eAAf,EAAvB;;AAEA;;AAEA;AACA,MAAI,CAAC,2BAAcN,KAAd,EAAqBK,gBAArB,CAAL,EAA6C;AAC3C,UAAML,MAAMO,0BAAN,CAAiCP,MAAMQ,UAAN,CAAiBC,SAAlD,EAA6D,qCAA7D,CAAN;AACD;AACD,2BAAUJ,8CAAV;;AAEA;AACA,SAAOA,gBAAP;AACD;;AAED;AACe,SAASP,SAAT,CACbY,SADa,EAEbC,UAFa,EAGbC,GAHa,EAIbZ,KAJa,EAKN;AACP;AACA,MAAIa,YAAY,0BAAab,KAAb,CAAhB;;AAEA;AACA,MAAIa,0CAAJ,EAAyC;AACvC,UAAMb,MAAMO,0BAAN,CAAiCP,MAAMQ,UAAN,CAAiBM,cAAlD,EAAkE,wBAAlE,CAAN;AACD;;AAED;AACA,MAAIC,OAAOhB,oBAAoBC,KAApB,CAAX;;AAEA;;AAEA;AACA,MAAIgB,UAAU,oCAAuBhB,KAAvB,EAA8BW,UAA9B,EAA0CC,GAA1C,EAA+CF,SAA/C,CAAd;;AAEA;;AAEA;AACA,MAAIO,SAAS,uBAAUjB,KAAV,EAAiBe,IAAjB,EAAuBC,OAAvB,EAAgCH,SAAhC,CAAb;;AAEA;;AAEA;AACA,MAAIK,SAAS,wBAAYhB,kBAAZ,CAA+BF,KAA/B,CAAb;;AAEA;AACA,SAAOkB,OAAOC,aAAP,CAAqBF,MAArB,CAAP;AACD","file":"SuperCall.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { BabelNodeExpression, BabelNodeSpreadElement } from \"babel-types\";\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport { FunctionEnvironmentRecord } from \"../environment.js\";\nimport { Value, UndefinedValue, ObjectValue } from \"../values/index.js\";\nimport { GetNewTarget, ArgumentListEvaluation, Construct, IsConstructor } from \"../methods/index.js\";\nimport { Environment } from \"../singletons.js\";\nimport invariant from \"../invariant.js\";\n\nfunction GetSuperConstructor(realm: Realm) {\n // 1. Let envRec be GetThisEnvironment( ).\n let envRec = Environment.GetThisEnvironment(realm);\n\n // 2. Assert: envRec is a function Environment Record.\n invariant(envRec instanceof FunctionEnvironmentRecord);\n\n // 3. Let activeFunction be envRec.[[FunctionObject]].\n let activeFunction = envRec.$FunctionObject;\n\n // 4. Let superConstructor be activeFunction.[[GetPrototypeOf]]().\n let superConstructor = activeFunction.$GetPrototypeOf();\n\n // 5. ReturnIfAbrupt(superConstructor).\n\n // 6. If IsConstructor(superConstructor) is false, throw a TypeError exception.\n if (!IsConstructor(realm, superConstructor)) {\n throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, \"super called outside of constructor\");\n }\n invariant(superConstructor instanceof ObjectValue);\n\n // 7. Return superConstructor.\n return superConstructor;\n}\n\n// ECMA262 12.3.5.1\nexport default function SuperCall(\n Arguments: Array<BabelNodeExpression | BabelNodeSpreadElement>,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // 1. Let newTarget be GetNewTarget().\n let newTarget = GetNewTarget(realm);\n\n // 2. If newTarget is undefined, throw a ReferenceError exception.\n if (newTarget instanceof UndefinedValue) {\n throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError, \"newTarget is undefined\");\n }\n\n // 3. Let func be GetSuperConstructor().\n let func = GetSuperConstructor(realm);\n\n // 4. ReturnIfAbrupt(func).\n\n // 5. Let argList be ArgumentListEvaluation of Arguments.\n let argList = ArgumentListEvaluation(realm, strictCode, env, Arguments);\n\n // 6. ReturnIfAbrupt(argList).\n\n // 7. Let result be Construct(func, argList, newTarget).\n let result = Construct(realm, func, argList, newTarget);\n\n // 8. ReturnIfAbrupt(result).\n\n // 9. Let thisER be GetThisEnvironment( ).\n let thisER = Environment.GetThisEnvironment(realm);\n\n // 10. Return thisER.BindThisValue(result).\n return thisER.BindThisValue(result);\n}\n"]}
|
||||
90
build/node_modules/prepack/lib/evaluators/SuperProperty.js
generated
vendored
Normal file
90
build/node_modules/prepack/lib/evaluators/SuperProperty.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = SuperProperty;
|
||||
|
||||
var _environment = require("../environment.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function MakeSuperPropertyReference(realm, propertyKey, strict) {
|
||||
// 1. Let env be GetThisEnvironment( ).
|
||||
var env = _singletons.Environment.GetThisEnvironment(realm);
|
||||
(0, _invariant2.default)(env instanceof _environment.FunctionEnvironmentRecord);
|
||||
|
||||
// 2. If env.HasSuperBinding() is false, throw a ReferenceError exception.
|
||||
if (!env.HasSuperBinding()) {
|
||||
throw realm.createErrorThrowCompletion(realm.intrinsics.ReferenceError, "env does not have super binding");
|
||||
}
|
||||
|
||||
// 3. Let actualThis be env.GetThisBinding().
|
||||
var actualThis = env.GetThisBinding();
|
||||
|
||||
// 4. ReturnIfAbrupt(actualThis).
|
||||
|
||||
// 5. Let baseValue be env.GetSuperBase().
|
||||
var baseValue = env.GetSuperBase();
|
||||
|
||||
// 6. Let bv be RequireObjectCoercible(baseValue).
|
||||
var bv = (0, _index2.RequireObjectCoercible)(realm, baseValue);
|
||||
|
||||
// 7. ReturnIfAbrupt(bv).
|
||||
|
||||
// 8. Return a value of type Reference that is a Super Reference whose base value is bv, whose referenced name is propertyKey, whose thisValue is actualThis, and whose strict reference flag is strict.
|
||||
return new _environment.Reference(bv, propertyKey, strict, actualThis);
|
||||
}
|
||||
|
||||
// ECMA262 12.3.5.1
|
||||
function SuperProperty(ast, strictCode, env, realm) {
|
||||
// SuperProperty : super [ Expression ]
|
||||
if (ast.computed) {
|
||||
// 1. Let propertyNameReference be the result of evaluating Expression.
|
||||
var propertyNameReference = env.evaluate(ast.property, strictCode);
|
||||
|
||||
// 2. Let propertyNameValue be GetValue(propertyNameReference).
|
||||
var propertyNameValue = _singletons.Environment.GetValue(realm, propertyNameReference);
|
||||
|
||||
// 3. Let propertyKey be ToPropertyKey(propertyNameValue).
|
||||
var propertyKey = _singletons.To.ToPropertyKeyPartial(realm, propertyNameValue);
|
||||
|
||||
// 4. ReturnIfAbrupt(propertyKey).
|
||||
|
||||
// 5. If the code matched by the syntactic production that is being evaluated is strict mode code, let strict be true, else let strict be false.
|
||||
var strict = strictCode;
|
||||
|
||||
// 6. Return MakeSuperPropertyReference(propertyKey, strict).
|
||||
return MakeSuperPropertyReference(realm, propertyKey, strict);
|
||||
} else {
|
||||
// SuperProperty : super . IdentifierName
|
||||
// 1. Let propertyKey be StringValue of IdentifierName.
|
||||
var _propertyKey = new _index.StringValue(realm, ast.property.name);
|
||||
|
||||
// 2. If the code matched by the syntactic production that is being evaluated is strict mode code, let strict be true, else let strict be false.
|
||||
var _strict = strictCode;
|
||||
|
||||
// 3. Return MakeSuperPropertyReference(propertyKey, strict).
|
||||
return MakeSuperPropertyReference(realm, _propertyKey, _strict);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SuperProperty.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/SuperProperty.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/SuperProperty.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
285
build/node_modules/prepack/lib/evaluators/SwitchStatement.js
generated
vendored
Normal file
285
build/node_modules/prepack/lib/evaluators/SwitchStatement.js
generated
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
"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.
|
||||
*/
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm, labelSet) {
|
||||
var expression = ast.discriminant;
|
||||
var cases = ast.cases;
|
||||
|
||||
// 1. Let exprRef be the result of evaluating Expression.
|
||||
var exprRef = env.evaluate(expression, strictCode);
|
||||
|
||||
// 2. Let switchValue be ? GetValue(exprRef).
|
||||
var switchValue = _singletons.Environment.GetValue(realm, exprRef);
|
||||
|
||||
// 3. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
var oldEnv = realm.getRunningContext().lexicalEnvironment;
|
||||
|
||||
// 4. Let blockEnv be NewDeclarativeEnvironment(oldEnv).
|
||||
var blockEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
|
||||
|
||||
// 5. Perform BlockDeclarationInstantiation(CaseBlock, blockEnv).
|
||||
var CaseBlock = cases.map(function (c) {
|
||||
return c.consequent;
|
||||
}).reduce(function (stmts, case_blk) {
|
||||
return stmts.concat(case_blk);
|
||||
}, []);
|
||||
_singletons.Environment.BlockDeclarationInstantiation(realm, strictCode, CaseBlock, blockEnv);
|
||||
|
||||
// 6. Set the running execution context's LexicalEnvironment to blockEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = blockEnv;
|
||||
|
||||
var R = void 0;
|
||||
try {
|
||||
// 7. Let R be the result of performing CaseBlockEvaluation of CaseBlock with argument switchValue.
|
||||
R = CaseBlockEvaluation(cases, switchValue, strictCode, blockEnv, realm);
|
||||
|
||||
// 9. Return R.
|
||||
return R;
|
||||
} catch (e) {
|
||||
if (e instanceof _completions.BreakCompletion) {
|
||||
if (!e.target) return (0, _index2.UpdateEmpty)(realm, e, realm.intrinsics.undefined).value;
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
// 8. Set the running execution context's LexicalEnvironment to oldEnv.
|
||||
realm.getRunningContext().lexicalEnvironment = oldEnv;
|
||||
realm.onDestroyScope(blockEnv);
|
||||
}
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _ForOfStatement = require("./ForOfStatement.js");
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _index2 = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// 13.12.10 Runtime Semantics: CaseSelectorEvaluation
|
||||
function CaseSelectorEvaluation(expression, strictCode, env, realm) {
|
||||
// 1. Let exprRef be the result of evaluating Expression.
|
||||
var exprRef = env.evaluate(expression, strictCode);
|
||||
|
||||
// 2. Return ? GetValue(exprRef).
|
||||
return _singletons.Environment.GetValue(realm, exprRef);
|
||||
}
|
||||
|
||||
function CaseBlockEvaluation(cases, input, strictCode, env, realm) {
|
||||
var EvaluateCase = function EvaluateCase(c) {
|
||||
var r = realm.intrinsics.empty;
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = c.consequent[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var node = _step.value;
|
||||
|
||||
var res = env.evaluateCompletion(node, strictCode);
|
||||
if (res instanceof _completions.AbruptCompletion) return (0, _index2.UpdateEmpty)(realm, res, r);
|
||||
if (!(res instanceof _index.EmptyValue)) r = res;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
};
|
||||
|
||||
var EvaluateCaseClauses = function EvaluateCaseClauses(A, V) {
|
||||
// 2. Let A be the List of CaseClause items in CaseClauses, in source text order.
|
||||
// A is passed in
|
||||
|
||||
// 3. Let found be false.
|
||||
var found = false;
|
||||
|
||||
// 4. Repeat for each CaseClause C in A,
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = A[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var C = _step2.value;
|
||||
|
||||
// a. If found is false, then
|
||||
if (!found) {
|
||||
// i. Let clauseSelector be the result of CaseSelectorEvaluation of C.
|
||||
var test = C.test;
|
||||
(0, _invariant2.default)(test);
|
||||
var clauseSelector = CaseSelectorEvaluation(test, strictCode, env, realm);
|
||||
|
||||
// ii. ReturnIfAbrupt(clauseSelector).
|
||||
// above will throw a Completion which will return
|
||||
|
||||
// iii. Let found be the result of performing Strict Equality Comparison input === clauseSelector.[[Value]].
|
||||
found = (0, _index2.StrictEqualityComparisonPartial)(realm, input, clauseSelector);
|
||||
}
|
||||
if (found) {
|
||||
// b. If found is true, then
|
||||
// i. Let R be the result of evaluating C.
|
||||
var R = EvaluateCase(C);
|
||||
|
||||
// ii. If R.[[Value]] is not empty, let V be R.[[Value]].
|
||||
var val = (0, _ForOfStatement.InternalGetResultValue)(realm, R);
|
||||
if (!(val instanceof _index.EmptyValue)) V = val;
|
||||
|
||||
// iii. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
if (R instanceof _completions.AbruptCompletion) {
|
||||
throw (0, _index2.UpdateEmpty)(realm, R, V);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [found, V];
|
||||
};
|
||||
|
||||
// CaseBlock:{}
|
||||
// 1. Return NormalCompletion(undefined).
|
||||
if (cases.length === 0) return realm.intrinsics.undefined;
|
||||
|
||||
// CaseBlock:{CaseClauses DefaultClause CaseClauses}
|
||||
var default_case_num = cases.findIndex(function (clause) {
|
||||
return clause.test === null;
|
||||
});
|
||||
|
||||
if (default_case_num !== -1) {
|
||||
// 2. Let A be the List of CaseClause items in the first CaseClauses, in source text order. If the first CaseClauses is not present, A is « ».
|
||||
var A = cases.slice(0, default_case_num);
|
||||
|
||||
var V = realm.intrinsics.undefined;
|
||||
|
||||
// 4. Repeat for each CaseClause C in A
|
||||
|
||||
// 5. Let foundInB be false.
|
||||
var _EvaluateCaseClauses = EvaluateCaseClauses(A, V);
|
||||
|
||||
var _EvaluateCaseClauses2 = _slicedToArray(_EvaluateCaseClauses, 2);
|
||||
|
||||
V = _EvaluateCaseClauses2[1];
|
||||
var foundInB = false;
|
||||
|
||||
// 6. Let B be the List containing the CaseClause items in the second CaseClauses, in source text order. If the second CaseClauses is not present, B is « ».
|
||||
var B = cases.slice(default_case_num + 1);
|
||||
|
||||
// 8. If foundInB is true, return NormalCompletion(V).
|
||||
var _EvaluateCaseClauses3 = EvaluateCaseClauses(B, V);
|
||||
|
||||
var _EvaluateCaseClauses4 = _slicedToArray(_EvaluateCaseClauses3, 2);
|
||||
|
||||
foundInB = _EvaluateCaseClauses4[0];
|
||||
V = _EvaluateCaseClauses4[1];
|
||||
if (foundInB) return V;
|
||||
|
||||
// 9. Let R be the result of evaluating DefaultClause.
|
||||
var R = EvaluateCase(cases[default_case_num]);
|
||||
|
||||
// 10. If R.[[Value]] is not empty, let V be R.[[Value]].
|
||||
var val = (0, _ForOfStatement.InternalGetResultValue)(realm, R);
|
||||
if (!(val instanceof _index.EmptyValue)) V = val;
|
||||
|
||||
// 11. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
if (R instanceof _completions.AbruptCompletion) {
|
||||
throw (0, _index2.UpdateEmpty)(realm, R, V);
|
||||
}
|
||||
|
||||
// 12: Repeat for each CaseClause C in B (NOTE this is another complete iteration of the second CaseClauses)
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = B[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var C = _step3.value;
|
||||
|
||||
// a. Let R be the result of evaluating CaseClause C.
|
||||
R = EvaluateCase(C);
|
||||
|
||||
// b. If R.[[Value]] is not empty, let V be R.[[Value]].
|
||||
var value = (0, _ForOfStatement.InternalGetResultValue)(realm, R);
|
||||
if (!(value instanceof _index.EmptyValue)) V = value;
|
||||
|
||||
// c. If R is an abrupt completion, return Completion(UpdateEmpty(R, V)).
|
||||
if (R instanceof _completions.AbruptCompletion) {
|
||||
throw (0, _index2.UpdateEmpty)(realm, R, V);
|
||||
}
|
||||
}
|
||||
|
||||
// 13. Return NormalCompletion(V).
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return V;
|
||||
} else {
|
||||
// CaseBlock:{CaseClauses}
|
||||
var _V = void 0;
|
||||
|
||||
var _EvaluateCaseClauses5 = EvaluateCaseClauses(cases, realm.intrinsics.undefined);
|
||||
|
||||
var _EvaluateCaseClauses6 = _slicedToArray(_EvaluateCaseClauses5, 2);
|
||||
|
||||
_V = _EvaluateCaseClauses6[1];
|
||||
|
||||
return _V;
|
||||
}
|
||||
}
|
||||
|
||||
// 13.12.11
|
||||
//# sourceMappingURL=SwitchStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/SwitchStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/SwitchStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
20
build/node_modules/prepack/lib/evaluators/TaggedTemplateExpression.js
generated
vendored
Normal file
20
build/node_modules/prepack/lib/evaluators/TaggedTemplateExpression.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Let tagRef be the result of evaluating MemberExpression.
|
||||
var tagRef = env.evaluate(ast.tag, strictCode);
|
||||
|
||||
// 2. Let thisCall be this MemberExpression.
|
||||
|
||||
// 3. Let tailCall be IsInTailPosition(thisCall).
|
||||
|
||||
// 4. Return ? EvaluateCall(tagRef, TemplateLiteral, tailCall).
|
||||
return (0, _call.EvaluateCall)(realm, strictCode, env, tagRef, ast.quasi);
|
||||
};
|
||||
|
||||
var _call = require("../methods/call.js");
|
||||
//# sourceMappingURL=TaggedTemplateExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/TaggedTemplateExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/TaggedTemplateExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/TaggedTemplateExpression.js"],"names":["ast","strictCode","env","realm","tagRef","evaluate","tag","quasi"],"mappings":";;;;;;kBAkBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP;AACA,MAAIC,SAASF,IAAIG,QAAJ,CAAaL,IAAIM,GAAjB,EAAsBL,UAAtB,CAAb;;AAEA;;AAEA;;AAEA;AACA,SAAO,wBAAaE,KAAb,EAAoBF,UAApB,EAAgCC,GAAhC,EAAqCE,MAArC,EAA6CJ,IAAIO,KAAjD,CAAP;AACD,C;;AAnBD","file":"TaggedTemplateExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { EvaluateCall } from \"../methods/call.js\";\nimport type { BabelNodeTaggedTemplateExpression } from \"babel-types\";\n\n// ECMA262 12.3.7\nexport default function(\n ast: BabelNodeTaggedTemplateExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // 1. Let tagRef be the result of evaluating MemberExpression.\n let tagRef = env.evaluate(ast.tag, strictCode);\n\n // 2. Let thisCall be this MemberExpression.\n\n // 3. Let tailCall be IsInTailPosition(thisCall).\n\n // 4. Return ? EvaluateCall(tagRef, TemplateLiteral, tailCall).\n return EvaluateCall(realm, strictCode, env, tagRef, ast.quasi);\n}\n"]}
|
||||
28
build/node_modules/prepack/lib/evaluators/TemplateLiteral.js
generated
vendored
Normal file
28
build/node_modules/prepack/lib/evaluators/TemplateLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var str = "";
|
||||
|
||||
for (var i = 0; i < ast.quasis.length; i++) {
|
||||
// add quasi
|
||||
var elem = ast.quasis[i];
|
||||
str += elem.value.cooked;
|
||||
|
||||
// add expression
|
||||
var expr = ast.expressions[i];
|
||||
if (expr) {
|
||||
str += _singletons.To.ToStringPartial(realm, _singletons.Environment.GetValue(realm, env.evaluate(expr, strictCode)));
|
||||
}
|
||||
}
|
||||
|
||||
return new _index.StringValue(realm, str);
|
||||
};
|
||||
|
||||
var _index = require("../values/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=TemplateLiteral.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/TemplateLiteral.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/TemplateLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/TemplateLiteral.js"],"names":["ast","strictCode","env","realm","str","i","quasis","length","elem","value","cooked","expr","expressions","ToStringPartial","GetValue","evaluate"],"mappings":";;;;;;kBAmBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,MAAIC,MAAM,EAAV;;AAEA,OAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAIL,IAAIM,MAAJ,CAAWC,MAA/B,EAAuCF,GAAvC,EAA4C;AAC1C;AACA,QAAIG,OAAOR,IAAIM,MAAJ,CAAWD,CAAX,CAAX;AACAD,WAAOI,KAAKC,KAAL,CAAWC,MAAlB;;AAEA;AACA,QAAIC,OAAOX,IAAIY,WAAJ,CAAgBP,CAAhB,CAAX;AACA,QAAIM,IAAJ,EAAU;AACRP,aAAO,eAAGS,eAAH,CAAmBV,KAAnB,EAA0B,wBAAYW,QAAZ,CAAqBX,KAArB,EAA4BD,IAAIa,QAAJ,CAAaJ,IAAb,EAAmBV,UAAnB,CAA5B,CAA1B,CAAP;AACD;AACF;;AAED,SAAO,uBAAgBE,KAAhB,EAAuBC,GAAvB,CAAP;AACD,C;;AA1BD;;AACA","file":"TemplateLiteral.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { StringValue } from \"../values/index.js\";\nimport { Environment, To } from \"../singletons.js\";\nimport type { BabelNodeTemplateLiteral } from \"babel-types\";\n\n// ECMA262 12.2.9\nexport default function(\n ast: BabelNodeTemplateLiteral,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n let str = \"\";\n\n for (let i = 0; i < ast.quasis.length; i++) {\n // add quasi\n let elem = ast.quasis[i];\n str += elem.value.cooked;\n\n // add expression\n let expr = ast.expressions[i];\n if (expr) {\n str += To.ToStringPartial(realm, Environment.GetValue(realm, env.evaluate(expr, strictCode)));\n }\n }\n\n return new StringValue(realm, str);\n}\n"]}
|
||||
13
build/node_modules/prepack/lib/evaluators/ThisExpression.js
generated
vendored
Normal file
13
build/node_modules/prepack/lib/evaluators/ThisExpression.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
// 1. Return ? ResolveThisBinding( ).
|
||||
return _singletons.Environment.ResolveThisBinding(realm);
|
||||
};
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=ThisExpression.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ThisExpression.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ThisExpression.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ThisExpression.js"],"names":["ast","strictCode","env","realm","ResolveThisBinding"],"mappings":";;;;;;kBAkBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP;AACA,SAAO,wBAAYC,kBAAZ,CAA+BD,KAA/B,CAAP;AACD,C;;AAZD","file":"ThisExpression.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { Environment } from \"../singletons.js\";\nimport type { BabelNodeThisExpression } from \"babel-types\";\n\n// ECMA262 12.2.2.1\nexport default function(\n ast: BabelNodeThisExpression,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n // 1. Return ? ResolveThisBinding( ).\n return Environment.ResolveThisBinding(realm);\n}\n"]}
|
||||
16
build/node_modules/prepack/lib/evaluators/ThrowStatement.js
generated
vendored
Normal file
16
build/node_modules/prepack/lib/evaluators/ThrowStatement.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var exprRef = env.evaluate(ast.argument, strictCode);
|
||||
var exprValue = _singletons.Environment.GetValue(realm, exprRef);
|
||||
throw new _completions.ThrowCompletion(exprValue, ast.loc);
|
||||
};
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
//# sourceMappingURL=ThrowStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/ThrowStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/ThrowStatement.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/evaluators/ThrowStatement.js"],"names":["ast","strictCode","env","realm","exprRef","evaluate","argument","exprValue","GetValue","loc"],"mappings":";;;;;;kBAkBe,UACbA,GADa,EAEbC,UAFa,EAGbC,GAHa,EAIbC,KAJa,EAKN;AACP,MAAIC,UAAUF,IAAIG,QAAJ,CAAaL,IAAIM,QAAjB,EAA2BL,UAA3B,CAAd;AACA,MAAIM,YAAY,wBAAYC,QAAZ,CAAqBL,KAArB,EAA4BC,OAA5B,CAAhB;AACA,QAAM,iCAAoBG,SAApB,EAA+BP,IAAIS,GAAnC,CAAN;AACD,C;;AAbD;;AACA","file":"ThrowStatement.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport type { LexicalEnvironment } from \"../environment.js\";\nimport type { Value } from \"../values/index.js\";\nimport { ThrowCompletion } from \"../completions.js\";\nimport { Environment } from \"../singletons.js\";\nimport type { BabelNodeThrowStatement } from \"babel-types\";\n\nexport default function(\n ast: BabelNodeThrowStatement,\n strictCode: boolean,\n env: LexicalEnvironment,\n realm: Realm\n): Value {\n let exprRef = env.evaluate(ast.argument, strictCode);\n let exprValue = Environment.GetValue(realm, exprRef);\n throw new ThrowCompletion(exprValue, ast.loc);\n}\n"]}
|
||||
251
build/node_modules/prepack/lib/evaluators/TryStatement.js
generated
vendored
Normal file
251
build/node_modules/prepack/lib/evaluators/TryStatement.js
generated
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (ast, strictCode, env, realm) {
|
||||
var blockRes = env.evaluateCompletionDeref(ast.block, strictCode);
|
||||
|
||||
var handlerRes = blockRes;
|
||||
var handler = ast.handler;
|
||||
if (handler) {
|
||||
// The start of the catch handler is a join point where all throw completions come together
|
||||
blockRes = _singletons.Functions.incorporateSavedCompletion(realm, blockRes);
|
||||
if (blockRes instanceof _completions.ThrowCompletion) {
|
||||
handlerRes = env.evaluateCompletionDeref(handler, strictCode, blockRes);
|
||||
// Note: The handler may have introduced new forks
|
||||
} else if (blockRes instanceof _completions.JoinedAbruptCompletions || blockRes instanceof _completions.PossiblyNormalCompletion) {
|
||||
if (blockRes instanceof _completions.PossiblyNormalCompletion) {
|
||||
// Nothing has been joined and we are going to keep it that way.
|
||||
// The current state may have advanced since the time control forked into the various paths recorded in blockRes.
|
||||
// Update the normal path and restore the global state to what it was at the time of the fork.
|
||||
var subsequentEffects = realm.getCapturedEffects(blockRes, blockRes.value);
|
||||
(0, _invariant2.default)(subsequentEffects !== undefined);
|
||||
realm.stopEffectCaptureAndUndoEffects(blockRes);
|
||||
_singletons.Join.updatePossiblyNormalCompletionWithSubsequentEffects(realm, blockRes, subsequentEffects);
|
||||
}
|
||||
// All of the forked threads of control are now joined together and the global state reflects their joint effects
|
||||
var handlerEffects = composeNestedThrowEffectsWithHandler(blockRes);
|
||||
handlerRes = handlerEffects[0];
|
||||
if (handlerRes instanceof _index2.Value) {
|
||||
// This can happen if all of the abrupt completions in blockRes were throw completions
|
||||
// and if the handler does not introduce any abrupt completions of its own.
|
||||
realm.applyEffects(handlerEffects);
|
||||
// The global state is now all joined up
|
||||
} else {
|
||||
// more than thread of control leaves the handler
|
||||
// The effects of each thread is tracked in handlerRes
|
||||
}
|
||||
} else {
|
||||
// The handler is not invoked, so just carry on.
|
||||
}
|
||||
}
|
||||
|
||||
var finalizerRes = handlerRes;
|
||||
if (ast.finalizer) {
|
||||
// The start of the finalizer is a join point where all threads of control come together.
|
||||
// However, we choose to keep the threads unjoined and to apply the finalizer separately to each thread.
|
||||
if (blockRes instanceof _completions.PossiblyNormalCompletion || blockRes instanceof _completions.JoinedAbruptCompletions) {
|
||||
// The current global state is a the point of the fork that led to blockRes
|
||||
// All subsequent effects are kept inside the branches of blockRes.
|
||||
var finalizerEffects = composeNestedEffectsWithFinalizer(blockRes);
|
||||
finalizerRes = finalizerEffects[0];
|
||||
// The result may become abrupt because of the finalizer, but it cannot become normal.
|
||||
(0, _invariant2.default)(!(finalizerRes instanceof _index2.Value));
|
||||
} else {
|
||||
// A single thread of control has produced a normal blockRes and the global state is up to date.
|
||||
finalizerRes = env.evaluateCompletion(ast.finalizer, strictCode);
|
||||
}
|
||||
}
|
||||
|
||||
if (finalizerRes instanceof _completions.AbruptCompletion) throw finalizerRes;
|
||||
if (finalizerRes instanceof _completions.PossiblyNormalCompletion) realm.composeWithSavedCompletion(finalizerRes);
|
||||
if (handlerRes instanceof _completions.PossiblyNormalCompletion) handlerRes = handlerRes.value;
|
||||
if (handlerRes instanceof _index2.Value) return (0, _index.UpdateEmpty)(realm, handlerRes, realm.intrinsics.undefined);
|
||||
throw handlerRes;
|
||||
|
||||
// The handler is a potential join point for all throw completions, but is easier to not do the join here because
|
||||
// it is tricky to join the joined and composed result of the throw completions with the non exceptional completions.
|
||||
// Unfortunately, things are still complicated because the handler may turn abrupt completions into normal
|
||||
// completions and the other way around. When this happens the container has to change its type.
|
||||
// We do this by call joinEffects to create a new container at every level of the recursion.
|
||||
function composeNestedThrowEffectsWithHandler(c) {
|
||||
var priorEffects = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
|
||||
var consequent = c.consequent;
|
||||
var consequentEffects = c.consequentEffects;
|
||||
priorEffects.push(consequentEffects);
|
||||
if (consequent instanceof _completions.JoinedAbruptCompletions || consequent instanceof _completions.PossiblyNormalCompletion) {
|
||||
consequentEffects = composeNestedThrowEffectsWithHandler(consequent, priorEffects);
|
||||
} else if (consequent instanceof _completions.ThrowCompletion) {
|
||||
consequentEffects = realm.evaluateForEffects(function () {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = priorEffects[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var priorEffect = _step.value;
|
||||
realm.applyEffects(priorEffect);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(ast.handler);
|
||||
return env.evaluateCompletionDeref(ast.handler, strictCode, consequent);
|
||||
});
|
||||
}
|
||||
priorEffects.pop();
|
||||
var alternate = c.alternate;
|
||||
var alternateEffects = c.alternateEffects;
|
||||
priorEffects.push(alternateEffects);
|
||||
if (alternate instanceof _completions.PossiblyNormalCompletion || alternate instanceof _completions.JoinedAbruptCompletions) {
|
||||
alternateEffects = composeNestedThrowEffectsWithHandler(alternate, priorEffects);
|
||||
} else if (alternate instanceof _completions.ThrowCompletion) {
|
||||
alternateEffects = realm.evaluateForEffects(function () {
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = priorEffects[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var priorEffect = _step2.value;
|
||||
realm.applyEffects(priorEffect);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(ast.handler);
|
||||
return env.evaluateCompletionDeref(ast.handler, strictCode, alternate);
|
||||
});
|
||||
}
|
||||
priorEffects.pop();
|
||||
return _singletons.Join.joinEffects(realm, c.joinCondition, consequentEffects, alternateEffects);
|
||||
}
|
||||
|
||||
// The finalizer is not a join point, so update each path in the completion separately.
|
||||
// Things are complicated because the finalizer may turn normal completions into abrupt completions.
|
||||
// When this happens the container has to change its type.
|
||||
// We do this by call joinEffects to create a new container at every level of the recursion.
|
||||
function composeNestedEffectsWithFinalizer(c) {
|
||||
var priorEffects = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
|
||||
var consequent = c.consequent;
|
||||
var consequentEffects = c.consequentEffects;
|
||||
priorEffects.push(consequentEffects);
|
||||
if (consequent instanceof _completions.JoinedAbruptCompletions || consequent instanceof _completions.PossiblyNormalCompletion) {
|
||||
consequentEffects = composeNestedThrowEffectsWithHandler(consequent, priorEffects);
|
||||
} else {
|
||||
consequentEffects = realm.evaluateForEffects(function () {
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = priorEffects[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var priorEffect = _step3.value;
|
||||
realm.applyEffects(priorEffect);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(ast.finalizer);
|
||||
return env.evaluateCompletionDeref(ast.finalizer, strictCode);
|
||||
});
|
||||
if (!(consequentEffects[0] instanceof _completions.AbruptCompletion)) consequentEffects[0] = consequent;
|
||||
}
|
||||
priorEffects.pop();
|
||||
var alternate = c.alternate;
|
||||
var alternateEffects = c.alternateEffects;
|
||||
priorEffects.push(alternateEffects);
|
||||
if (alternate instanceof _completions.PossiblyNormalCompletion || alternate instanceof _completions.JoinedAbruptCompletions) {
|
||||
alternateEffects = composeNestedThrowEffectsWithHandler(alternate, priorEffects);
|
||||
} else {
|
||||
alternateEffects = realm.evaluateForEffects(function () {
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator4 = priorEffects[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
||||
var priorEffect = _step4.value;
|
||||
realm.applyEffects(priorEffect);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(0, _invariant2.default)(ast.finalizer);
|
||||
return env.evaluateCompletionDeref(ast.finalizer, strictCode);
|
||||
});
|
||||
if (!(alternateEffects[0] instanceof _completions.AbruptCompletion)) alternateEffects[0] = alternate;
|
||||
}
|
||||
priorEffects.pop();
|
||||
return _singletons.Join.joinEffects(realm, c.joinCondition, consequentEffects, alternateEffects);
|
||||
}
|
||||
};
|
||||
|
||||
require("../environment.js");
|
||||
|
||||
var _completions = require("../completions.js");
|
||||
|
||||
var _index = require("../methods/index.js");
|
||||
|
||||
var _singletons = require("../singletons.js");
|
||||
|
||||
var _index2 = require("../values/index.js");
|
||||
|
||||
var _invariant = require("../invariant.js");
|
||||
|
||||
var _invariant2 = _interopRequireDefault(_invariant);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=TryStatement.js.map
|
||||
1
build/node_modules/prepack/lib/evaluators/TryStatement.js.map
generated
vendored
Normal file
1
build/node_modules/prepack/lib/evaluators/TryStatement.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user