(body *ast.Statement, visitor *ast.NodeVisitor)
| 917 | } |
| 918 | |
| 919 | func (c *EmitContext) VisitIterationBody(body *ast.Statement, visitor *ast.NodeVisitor) *ast.Statement { |
| 920 | if body == nil { |
| 921 | return nil |
| 922 | } |
| 923 | |
| 924 | c.StartLexicalEnvironment() |
| 925 | updated := c.VisitEmbeddedStatement(body, visitor) |
| 926 | if updated == nil { |
| 927 | panic("Expected visitor to return a statement.") |
| 928 | } |
| 929 | |
| 930 | statements := c.EndLexicalEnvironment() |
| 931 | if len(statements) > 0 { |
| 932 | if ast.IsBlock(updated) { |
| 933 | statements = append(statements, updated.Statements()...) |
| 934 | statementsList := c.Factory.NewNodeList(statements) |
| 935 | statementsList.Loc = updated.StatementList().Loc |
| 936 | return c.Factory.UpdateBlock(updated.AsBlock(), statementsList, updated.AsBlock().MultiLine) |
| 937 | } |
| 938 | statements = append(statements, updated) |
| 939 | return c.Factory.NewBlock(c.Factory.NewNodeList(statements), true /*multiLine*/) |
| 940 | } |
| 941 | |
| 942 | return updated |
| 943 | } |
| 944 | |
| 945 | func (c *EmitContext) VisitEmbeddedStatement(node *ast.Statement, visitor *ast.NodeVisitor) *ast.Statement { |
| 946 | if node == nil { |
no test coverage detected