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 tree; | 5 part of tree; |
6 | 6 |
7 abstract class Visitor<R> { | 7 abstract class Visitor<R> { |
8 const Visitor(); | 8 const Visitor(); |
9 | 9 |
10 R visitNode(Node node); | 10 R visitNode(Node node); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 R visitSend(Send node) => visitExpression(node); | 65 R visitSend(Send node) => visitExpression(node); |
66 R visitSendSet(SendSet node) => visitSend(node); | 66 R visitSendSet(SendSet node) => visitSend(node); |
67 R visitStatement(Statement node) => visitNode(node); | 67 R visitStatement(Statement node) => visitNode(node); |
68 R visitStringNode(StringNode node) => visitExpression(node); | 68 R visitStringNode(StringNode node) => visitExpression(node); |
69 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); | 69 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); |
70 R visitStringInterpolationPart(StringInterpolationPart node) { | 70 R visitStringInterpolationPart(StringInterpolationPart node) { |
71 return visitNode(node); | 71 return visitNode(node); |
72 } | 72 } |
73 R visitSwitchCase(SwitchCase node) => visitNode(node); | 73 R visitSwitchCase(SwitchCase node) => visitNode(node); |
74 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); | 74 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); |
75 R visitThrow(Throw node) => visitStatement(node); | 75 R visitThrow(Throw node) => visitExpression(node); |
76 R visitTryStatement(TryStatement node) => visitStatement(node); | 76 R visitTryStatement(TryStatement node) => visitStatement(node); |
77 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); | 77 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); |
78 R visitTypedef(Typedef node) => visitNode(node); | 78 R visitTypedef(Typedef node) => visitNode(node); |
79 R visitTypeVariable(TypeVariable node) => visitNode(node); | 79 R visitTypeVariable(TypeVariable node) => visitNode(node); |
80 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); | 80 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); |
81 R visitWhile(While node) => visitLoop(node); | 81 R visitWhile(While node) => visitLoop(node); |
82 } | 82 } |
83 | 83 |
84 Token firstBeginToken(Node first, Node second) { | 84 Token firstBeginToken(Node first, Node second) { |
85 Token token = null; | 85 Token token = null; |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 | 933 |
934 visitChildren(Visitor visitor) { | 934 visitChildren(Visitor visitor) { |
935 if (expression != null) expression.accept(visitor); | 935 if (expression != null) expression.accept(visitor); |
936 } | 936 } |
937 | 937 |
938 Token getBeginToken() => expression.getBeginToken(); | 938 Token getBeginToken() => expression.getBeginToken(); |
939 | 939 |
940 Token getEndToken() => endToken; | 940 Token getEndToken() => endToken; |
941 } | 941 } |
942 | 942 |
943 class Throw extends Statement { | 943 class Throw extends Expression { |
944 final Expression expression; | 944 final Expression expression; |
945 | 945 |
946 final Token throwToken; | 946 final Token throwToken; |
947 final Token endToken; | 947 final Token endToken; |
948 | 948 |
949 Throw(this.expression, this.throwToken, this.endToken); | 949 Throw(this.expression, this.throwToken, this.endToken); |
950 | 950 |
951 Throw asThrow() => this; | 951 Throw asThrow() => this; |
952 | 952 |
953 accept(Visitor visitor) => visitor.visitThrow(this); | 953 accept(Visitor visitor) => visitor.visitThrow(this); |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 * argument). | 1998 * argument). |
1999 * | 1999 * |
2000 * TODO(ahe): This method is controversial, the team needs to discuss | 2000 * TODO(ahe): This method is controversial, the team needs to discuss |
2001 * if top-level methods are acceptable and what naming conventions to | 2001 * if top-level methods are acceptable and what naming conventions to |
2002 * use. | 2002 * use. |
2003 */ | 2003 */ |
2004 initializerDo(Node node, f(Node node)) { | 2004 initializerDo(Node node, f(Node node)) { |
2005 SendSet send = node.asSendSet(); | 2005 SendSet send = node.asSendSet(); |
2006 if (send != null) return f(send.arguments.head); | 2006 if (send != null) return f(send.arguments.head); |
2007 } | 2007 } |
OLD | NEW |