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 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 | 1561 |
1558 Token getBeginToken() => tryKeyword; | 1562 Token getBeginToken() => tryKeyword; |
1559 | 1563 |
1560 Token getEndToken() { | 1564 Token getEndToken() { |
1561 if (finallyBlock !== null) return finallyBlock.getEndToken(); | 1565 if (finallyBlock !== null) return finallyBlock.getEndToken(); |
1562 if (!catchBlocks.isEmpty()) return catchBlocks.getEndToken(); | 1566 if (!catchBlocks.isEmpty()) return catchBlocks.getEndToken(); |
1563 return tryBlock.getEndToken(); | 1567 return tryBlock.getEndToken(); |
1564 } | 1568 } |
1565 } | 1569 } |
1566 | 1570 |
| 1571 class Cascade extends Node { |
| 1572 final Node expression; |
| 1573 Cascade(this.expression); |
| 1574 |
| 1575 Cascade asCascade() => this; |
| 1576 accept(Visitor visitor) => visitor.visitCascade(this); |
| 1577 |
| 1578 void visitChildren(Visitor visitor) { |
| 1579 expression.accept(visitor); |
| 1580 } |
| 1581 |
| 1582 Token getBeginToken() => expression.getBeginToken(); |
| 1583 |
| 1584 Token getEndToken() => expression.getEndToken(); |
| 1585 } |
| 1586 |
| 1587 class CascadeReceiver extends Node { |
| 1588 final Node expression; |
| 1589 final Token cascadeOperator; |
| 1590 CascadeReceiver(this.expression, this.cascadeOperator); |
| 1591 |
| 1592 CascadeReceiver asCascadeReceiver() => this; |
| 1593 accept(Visitor visitor) => visitor.visitCascadeReceiver(this); |
| 1594 |
| 1595 void visitChildren(Visitor visitor) { |
| 1596 expression.accept(visitor); |
| 1597 } |
| 1598 |
| 1599 Token getBeginToken() => expression.getBeginToken(); |
| 1600 |
| 1601 Token getEndToken() => expression.getEndToken(); |
| 1602 } |
| 1603 |
1567 class CatchBlock extends Node { | 1604 class CatchBlock extends Node { |
1568 final NodeList formals; | 1605 final NodeList formals; |
1569 final Block block; | 1606 final Block block; |
1570 | 1607 |
1571 final catchKeyword; | 1608 final catchKeyword; |
1572 | 1609 |
1573 CatchBlock(this.formals, this.block, this.catchKeyword); | 1610 CatchBlock(this.formals, this.block, this.catchKeyword); |
1574 | 1611 |
1575 CatchBlock asCatchBlock() => this; | 1612 CatchBlock asCatchBlock() => this; |
1576 | 1613 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 * argument). | 1680 * argument). |
1644 * | 1681 * |
1645 * TODO(ahe): This method is controversial, the team needs to discuss | 1682 * TODO(ahe): This method is controversial, the team needs to discuss |
1646 * if top-level methods are acceptable and what naming conventions to | 1683 * if top-level methods are acceptable and what naming conventions to |
1647 * use. | 1684 * use. |
1648 */ | 1685 */ |
1649 initializerDo(Node node, f(Node node)) { | 1686 initializerDo(Node node, f(Node node)) { |
1650 SendSet send = node.asSendSet(); | 1687 SendSet send = node.asSendSet(); |
1651 if (send !== null) return f(send.arguments.head); | 1688 if (send !== null) return f(send.arguments.head); |
1652 } | 1689 } |
OLD | NEW |