prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
41 lines (31 loc) • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (ast, strictCode, env, realm) {
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
let oldEnv = realm.getRunningContext().lexicalEnvironment;
// 2. Let blockEnv be NewDeclarativeEnvironment(oldEnv).
let blockEnv = _singletons.Environment.NewDeclarativeEnvironment(realm, oldEnv);
// 3. Perform BlockDeclarationInstantiation(StatementList, blockEnv).
_singletons.Environment.BlockDeclarationInstantiation(realm, strictCode, ast.body, blockEnv);
// 4. Set the running execution context's LexicalEnvironment to blockEnv.
realm.getRunningContext().lexicalEnvironment = blockEnv;
try {
// 5. Let blockValue be the result of evaluating StatementList.
let blockValue;
if (ast.directives) {
for (let directive of ast.directives) {
blockValue = new _index.StringValue(realm, directive.value.value);
}
}
return _singletons.Functions.EvaluateStatements(ast.body, blockValue, strictCode, blockEnv, realm);
} finally {
// 6. Set the running execution context's LexicalEnvironment to oldEnv.
realm.getRunningContext().lexicalEnvironment = oldEnv;
realm.onDestroyScope(blockEnv);
}
};
var _index = require("../values/index.js");
var _singletons = require("../singletons.js");
//# sourceMappingURL=BlockStatement.js.map