45 lines
1.7 KiB
JavaScript
45 lines
1.7 KiB
JavaScript
"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
|