| 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 interface Visitor<R> { | 5 interface Visitor<R> { |
| 6 R visitBlock(Block node); | 6 R visitBlock(Block node); |
| 7 R visitBreakStatement(BreakStatement node); | 7 R visitBreakStatement(BreakStatement node); |
| 8 R visitCascade(Cascade node); |
| 9 R visitCascadeReceiver(CascadeReceiver node); |
| 8 R visitCatchBlock(CatchBlock node); | 10 R visitCatchBlock(CatchBlock node); |
| 9 R visitClassNode(ClassNode node); | 11 R visitClassNode(ClassNode node); |
| 10 R visitConditional(Conditional node); | 12 R visitConditional(Conditional node); |
| 11 R visitContinueStatement(ContinueStatement node); | 13 R visitContinueStatement(ContinueStatement node); |
| 12 R visitDoWhile(DoWhile node); | 14 R visitDoWhile(DoWhile node); |
| 13 R visitEmptyStatement(EmptyStatement node); | 15 R visitEmptyStatement(EmptyStatement node); |
| 14 R visitExpressionStatement(ExpressionStatement node); | 16 R visitExpressionStatement(ExpressionStatement node); |
| 15 R visitFor(For node); | 17 R visitFor(For node); |
| 16 R visitForIn(ForIn node); | 18 R visitForIn(ForIn node); |
| 17 R visitFunctionDeclaration(FunctionDeclaration node); | 19 R visitFunctionDeclaration(FunctionDeclaration node); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>'; | 103 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>'; |
| 102 } | 104 } |
| 103 } | 105 } |
| 104 | 106 |
| 105 abstract Token getBeginToken(); | 107 abstract Token getBeginToken(); |
| 106 | 108 |
| 107 abstract Token getEndToken(); | 109 abstract Token getEndToken(); |
| 108 | 110 |
| 109 Block asBlock() => null; | 111 Block asBlock() => null; |
| 110 BreakStatement asBreakStatement() => null; | 112 BreakStatement asBreakStatement() => null; |
| 113 Cascade asCascade() => null; |
| 114 CascadeReceiver asCascadeReceiver() => null; |
| 111 CatchBlock asCatchBlock() => null; | 115 CatchBlock asCatchBlock() => null; |
| 112 ClassNode asClassNode() => null; | 116 ClassNode asClassNode() => null; |
| 113 Conditional asConditional() => null; | 117 Conditional asConditional() => null; |
| 114 ContinueStatement asContinueStatement() => null; | 118 ContinueStatement asContinueStatement() => null; |
| 115 DoWhile asDoWhile() => null; | 119 DoWhile asDoWhile() => null; |
| 116 EmptyStatement asEmptyStatement() => null; | 120 EmptyStatement asEmptyStatement() => null; |
| 117 Expression asExpression() => null; | 121 Expression asExpression() => null; |
| 118 ExpressionStatement asExpressionStatement() => null; | 122 ExpressionStatement asExpressionStatement() => null; |
| 119 For asFor() => null; | 123 For asFor() => null; |
| 120 ForIn asForIn() => null; | 124 ForIn asForIn() => null; |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 | 1558 |
| 1555 Token getBeginToken() => tryKeyword; | 1559 Token getBeginToken() => tryKeyword; |
| 1556 | 1560 |
| 1557 Token getEndToken() { | 1561 Token getEndToken() { |
| 1558 if (finallyBlock !== null) return finallyBlock.getEndToken(); | 1562 if (finallyBlock !== null) return finallyBlock.getEndToken(); |
| 1559 if (!catchBlocks.isEmpty()) return catchBlocks.getEndToken(); | 1563 if (!catchBlocks.isEmpty()) return catchBlocks.getEndToken(); |
| 1560 return tryBlock.getEndToken(); | 1564 return tryBlock.getEndToken(); |
| 1561 } | 1565 } |
| 1562 } | 1566 } |
| 1563 | 1567 |
| 1568 class Cascade extends Node { |
| 1569 final Node expression; |
| 1570 Cascade(this.expression); |
| 1571 |
| 1572 Cascade asCascade() => this; |
| 1573 accept(Visitor visitor) => visitor.visitCascade(this); |
| 1574 |
| 1575 void visitChildren(Visitor visitor) { |
| 1576 expression.accept(visitor); |
| 1577 } |
| 1578 |
| 1579 Token getBeginToken() => expression.getBeginToken(); |
| 1580 |
| 1581 Token getEndToken() => expression.getEndToken(); |
| 1582 } |
| 1583 |
| 1584 class CascadeReceiver extends Node { |
| 1585 final Node expression; |
| 1586 final Token cascadeOperator; |
| 1587 CascadeReceiver(this.expression, this.cascadeOperator); |
| 1588 |
| 1589 CascadeReceiver asCascadeReceiver() => this; |
| 1590 accept(Visitor visitor) => visitor.visitCascadeReceiver(this); |
| 1591 |
| 1592 void visitChildren(Visitor visitor) { |
| 1593 expression.accept(visitor); |
| 1594 } |
| 1595 |
| 1596 Token getBeginToken() => expression.getBeginToken(); |
| 1597 |
| 1598 Token getEndToken() => expression.getEndToken(); |
| 1599 } |
| 1600 |
| 1564 class CatchBlock extends Node { | 1601 class CatchBlock extends Node { |
| 1565 final NodeList formals; | 1602 final NodeList formals; |
| 1566 final Block block; | 1603 final Block block; |
| 1567 | 1604 |
| 1568 final catchKeyword; | 1605 final catchKeyword; |
| 1569 | 1606 |
| 1570 CatchBlock(this.formals, this.block, this.catchKeyword); | 1607 CatchBlock(this.formals, this.block, this.catchKeyword); |
| 1571 | 1608 |
| 1572 CatchBlock asCatchBlock() => this; | 1609 CatchBlock asCatchBlock() => this; |
| 1573 | 1610 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 * argument). | 1677 * argument). |
| 1641 * | 1678 * |
| 1642 * TODO(ahe): This method is controversial, the team needs to discuss | 1679 * TODO(ahe): This method is controversial, the team needs to discuss |
| 1643 * if top-level methods are acceptable and what naming conventions to | 1680 * if top-level methods are acceptable and what naming conventions to |
| 1644 * use. | 1681 * use. |
| 1645 */ | 1682 */ |
| 1646 initializerDo(Node node, f(Node node)) { | 1683 initializerDo(Node node, f(Node node)) { |
| 1647 SendSet send = node.asSendSet(); | 1684 SendSet send = node.asSendSet(); |
| 1648 if (send !== null) return f(send.arguments.head); | 1685 if (send !== null) return f(send.arguments.head); |
| 1649 } | 1686 } |
| OLD | NEW |