UNPKG

prepack

Version:

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

63 lines (42 loc) 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; var _environment = require("../environment.js"); var _index = require("../values/index.js"); var _index2 = require("../methods/index.js"); var _singletons = require("../singletons.js"); var _SuperProperty = _interopRequireDefault(require("./SuperProperty")); 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. */ /* strict-local */ // ECMA262 12.3.2.1 function _default(ast, strictCode, env, realm) { if (ast.object.type === "Super") { return (0, _SuperProperty.default)(ast, strictCode, env, realm); } // 1. Let baseReference be the result of evaluating MemberExpression. let baseReference = env.evaluate(ast.object, strictCode); // 2. Let baseValue be ? GetValue(baseReference). let baseValue = _singletons.Environment.GetValue(realm, baseReference); let propertyNameValue; if (ast.computed === true) { // 3. Let propertyNameReference be the result of evaluating Expression. let 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). let bv = (0, _index2.RequireObjectCoercible)(realm, baseValue, ast.object.loc); // 6. Let propertyKey be ? ToPropertyKey(propertyNameValue). let 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. let 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); } //# sourceMappingURL=MemberExpression.js.map