UNPKG

prepack

Version:

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

51 lines (34 loc) 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; var _singletons = require("../singletons.js"); var _strict = _interopRequireDefault(require("../utils/strict.js")); var t = _interopRequireWildcard(require("@babel/types")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } 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 14.2.16 function _default(ast, strictCode, env, realm) { let 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. let strict = strictCode || (0, _strict.default)(ast.body); // 2. Let scope be the LexicalEnvironment of the running execution context. let scope = env; // 3. Let parameters be CoveredFormalsList of ArrowParameters. let parameters = ast.params; // 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). let closure = _singletons.Functions.FunctionCreate(realm, "arrow", parameters, ConciseBody, scope, strict); closure.loc = ast.loc; // 5. Return closure. return closure; } //# sourceMappingURL=ArrowFunctionExpression.js.map