UNPKG

prepack

Version:

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

63 lines (45 loc) 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; var _index = require("../values/index.js"); var _completions = require("../completions.js"); var _invariant = _interopRequireDefault(require("../invariant.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. */ // ECAM262 13.15.7 function _default(ast, strictCode, env, realm, thrownValue) { (0, _invariant.default)(thrownValue instanceof _completions.ThrowCompletion, "Metadata isn't a throw completion"); // 1. Let oldEnv be the running execution context's LexicalEnvironment. let oldEnv = realm.getRunningContext().lexicalEnvironment; // 2. Let catchEnv be NewDeclarativeEnvironment(oldEnv). let catchEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv); // 3. Let catchEnvRec be catchEnv's EnvironmentRecord. let catchEnvRec = catchEnv.environmentRecord; // 4. For each element argName of the BoundNames of CatchParameter, do for (let argName of _singletons.Environment.BoundNames(realm, ast.param)) { // a. Perform ! catchEnvRec.CreateMutableBinding(argName, false). catchEnvRec.CreateMutableBinding(argName, false); } // 5. Set the running execution context's LexicalEnvironment to catchEnv. 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. let B = catchEnv.evaluate(ast.body, strictCode); (0, _invariant.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); } } //# sourceMappingURL=CatchClause.js.map