MCPcopy Create free account
hub / github.com/microsoft/typescript-go / EndLexicalEnvironment

Method EndLexicalEnvironment

internal/printer/emitcontext.go:197–207  ·  view source on GitHub ↗

Ends the current EndLexicalEnvironment, 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. NOTE: This is *not* the same as `endLexicalEnvironment` in Strada as that method is in

()

Source from the content-addressed store, hash-verified

195// NOTE: This is the equivalent of `transformContext.endLexicalEnvironment` in Strada.
196// NOTE: This is *not* the same as `endLexicalEnvironment` in Strada as that method is incorrectly named.
197func (c *EmitContext) EndLexicalEnvironment() []*ast.Statement {
198 scope := c.letScopeStack.Pop()
199 var statements []*ast.Statement
200 if len(scope.variables) > 0 {
201 varDeclList := c.Factory.NewVariableDeclarationList(c.Factory.NewNodeList(scope.variables), ast.NodeFlagsLet)
202 varStatement := c.Factory.NewVariableStatement(nil /*modifiers*/, varDeclList)
203 c.SetEmitFlags(varStatement, EFCustomPrologue)
204 statements = append(statements, varStatement)
205 }
206 return statements
207}
208
209// Invokes c.EndLexicalEnvironment() and merges the results into `statements`
210func (c *EmitContext) EndAndMergeLexicalEnvironmentList(statements *ast.StatementList) *ast.StatementList {

Callers 3

VisitIterationBodyMethod · 0.95

Calls 7

SetEmitFlagsMethod · 0.95
lenFunction · 0.85
PopMethod · 0.80
NewNodeListMethod · 0.80
NewVariableStatementMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected