| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of js_ast; | 5 part of js_ast; |
| 6 | 6 |
| 7 abstract class NodeVisitor<T> { | 7 abstract class NodeVisitor<T> { |
| 8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
| 9 | 9 |
| 10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 Program _clone() => new Program(body); | 271 Program _clone() => new Program(body); |
| 272 } | 272 } |
| 273 | 273 |
| 274 abstract class Statement extends Node { | 274 abstract class Statement extends Node { |
| 275 Statement toStatement() => this; | 275 Statement toStatement() => this; |
| 276 Statement toReturn() => new Block([this, new Return()]); | 276 Statement toReturn() => new Block([this, new Return()]); |
| 277 } | 277 } |
| 278 | 278 |
| 279 class Block extends Statement { | 279 class Block extends Statement { |
| 280 final List<Statement> statements; | 280 final List<Statement> statements; |
| 281 Block(this.statements) { | 281 |
| 282 /// True to preserve this [Block] for scoping reasons. |
| 283 final bool isScope; |
| 284 |
| 285 Block(this.statements, {this.isScope: false}) { |
| 282 assert(!statements.any((s) => s is! Statement)); | 286 assert(!statements.any((s) => s is! Statement)); |
| 283 } | 287 } |
| 284 Block.empty() : this.statements = <Statement>[]; | 288 Block.empty() : this.statements = <Statement>[]; |
| 285 | 289 |
| 286 accept(NodeVisitor visitor) => visitor.visitBlock(this); | 290 accept(NodeVisitor visitor) => visitor.visitBlock(this); |
| 287 void visitChildren(NodeVisitor visitor) { | 291 void visitChildren(NodeVisitor visitor) { |
| 288 for (Statement statement in statements) statement.accept(visitor); | 292 for (Statement statement in statements) statement.accept(visitor); |
| 289 } | 293 } |
| 290 Block _clone() => new Block(statements); | 294 Block _clone() => new Block(statements); |
| 291 } | 295 } |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 final Expression expression; | 1567 final Expression expression; |
| 1564 | 1568 |
| 1565 CommentExpression(this.comment, this.expression); | 1569 CommentExpression(this.comment, this.expression); |
| 1566 | 1570 |
| 1567 int get precedenceLevel => PRIMARY; | 1571 int get precedenceLevel => PRIMARY; |
| 1568 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); | 1572 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); |
| 1569 CommentExpression _clone() => new CommentExpression(comment, expression); | 1573 CommentExpression _clone() => new CommentExpression(comment, expression); |
| 1570 | 1574 |
| 1571 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); | 1575 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); |
| 1572 } | 1576 } |
| OLD | NEW |