MCPcopy Index your code
hub / github.com/nodejs/node / endLexicalEnvironment

Function endLexicalEnvironment

test/fixtures/snapshot/typescript.js:109812–109856  ·  view source on GitHub ↗

* Ends a lexical environment. The previous set of hoisted declarations are restored and * any hoisted declarations added in this environment are returned.

()

Source from the content-addressed store, hash-verified

109810 * any hoisted declarations added in this environment are returned.
109811 */
109812 function endLexicalEnvironment() {
109813 ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization.");
109814 ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed.");
109815 ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
109816 var statements;
109817 if (lexicalEnvironmentVariableDeclarations ||
109818 lexicalEnvironmentFunctionDeclarations ||
109819 lexicalEnvironmentStatements) {
109820 if (lexicalEnvironmentFunctionDeclarations) {
109821 statements = __spreadArray([], lexicalEnvironmentFunctionDeclarations, true);
109822 }
109823 if (lexicalEnvironmentVariableDeclarations) {
109824 var statement = factory.createVariableStatement(
109825 /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
109826 ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */);
109827 if (!statements) {
109828 statements = [statement];
109829 }
109830 else {
109831 statements.push(statement);
109832 }
109833 }
109834 if (lexicalEnvironmentStatements) {
109835 if (!statements) {
109836 statements = __spreadArray([], lexicalEnvironmentStatements, true);
109837 }
109838 else {
109839 statements = __spreadArray(__spreadArray([], statements, true), lexicalEnvironmentStatements, true);
109840 }
109841 }
109842 }
109843 // Restore the previous lexical environment.
109844 lexicalEnvironmentStackOffset--;
109845 lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
109846 lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
109847 lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
109848 lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
109849 if (lexicalEnvironmentStackOffset === 0) {
109850 lexicalEnvironmentVariableDeclarationsStack = [];
109851 lexicalEnvironmentFunctionDeclarationsStack = [];
109852 lexicalEnvironmentStatementsStack = [];
109853 lexicalEnvironmentFlagsStack = [];
109854 }
109855 return statements;
109856 }
109857 function setLexicalEnvironmentFlags(flags, value) {
109858 lexicalEnvironmentFlags = value ?
109859 lexicalEnvironmentFlags | flags :

Calls 2

assertMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…