first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

View 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