Ends the current VariableEnvironment, returning a list of statements that should be emitted at the start of the current scope. NOTE: This is the equivalent of `transformContext.endLexicalEnvironment` in Strada.
()
| 115 | // |
| 116 | // NOTE: This is the equivalent of `transformContext.endLexicalEnvironment` in Strada. |
| 117 | func (c *EmitContext) EndVariableEnvironment() []*ast.Statement { |
| 118 | scope := c.varScopeStack.Pop() |
| 119 | var statements []*ast.Statement |
| 120 | if len(scope.functions) > 0 { |
| 121 | statements = slices.Clone(scope.functions) |
| 122 | } |
| 123 | if len(scope.variables) > 0 { |
| 124 | varDeclList := c.Factory.NewVariableDeclarationList(c.Factory.NewNodeList(scope.variables), ast.NodeFlagsNone) |
| 125 | varStatement := c.Factory.NewVariableStatement(nil /*modifiers*/, varDeclList) |
| 126 | c.SetEmitFlags(varStatement, EFCustomPrologue) |
| 127 | statements = append(statements, varStatement) |
| 128 | } |
| 129 | if len(scope.initializationStatements) > 0 { |
| 130 | statements = append(statements, scope.initializationStatements...) |
| 131 | } |
| 132 | return append(statements, c.EndLexicalEnvironment()...) |
| 133 | } |
| 134 | |
| 135 | // Invokes c.EndVariableEnvironment() and merges the results into `statements` |
| 136 | func (c *EmitContext) EndAndMergeVariableEnvironmentList(statements *ast.StatementList) *ast.StatementList { |
no test coverage detected