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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 R visitNewExpression(NewExpression node) => visitExpression(node); | 57 R visitNewExpression(NewExpression node) => visitExpression(node); |
58 R visitNodeList(NodeList node) => visitNode(node); | 58 R visitNodeList(NodeList node) => visitNode(node); |
59 R visitOperator(Operator node) => visitIdentifier(node); | 59 R visitOperator(Operator node) => visitIdentifier(node); |
60 R visitParenthesizedExpression(ParenthesizedExpression node) { | 60 R visitParenthesizedExpression(ParenthesizedExpression node) { |
61 return visitExpression(node); | 61 return visitExpression(node); |
62 } | 62 } |
63 R visitPart(Part node) => visitLibraryTag(node); | 63 R visitPart(Part node) => visitLibraryTag(node); |
64 R visitPartOf(PartOf node) => visitNode(node); | 64 R visitPartOf(PartOf node) => visitNode(node); |
65 R visitPostfix(Postfix node) => visitNodeList(node); | 65 R visitPostfix(Postfix node) => visitNodeList(node); |
66 R visitPrefix(Prefix node) => visitNodeList(node); | 66 R visitPrefix(Prefix node) => visitNodeList(node); |
| 67 R visitRethrow(Rethrow node) => visitStatement(node); |
67 R visitReturn(Return node) => visitStatement(node); | 68 R visitReturn(Return node) => visitStatement(node); |
68 R visitScriptTag(ScriptTag node) => visitNode(node); | 69 R visitScriptTag(ScriptTag node) => visitNode(node); |
69 R visitSend(Send node) => visitExpression(node); | 70 R visitSend(Send node) => visitExpression(node); |
70 R visitSendSet(SendSet node) => visitSend(node); | 71 R visitSendSet(SendSet node) => visitSend(node); |
71 R visitStatement(Statement node) => visitNode(node); | 72 R visitStatement(Statement node) => visitNode(node); |
72 R visitStringNode(StringNode node) => visitExpression(node); | 73 R visitStringNode(StringNode node) => visitExpression(node); |
73 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); | 74 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); |
74 R visitStringInterpolationPart(StringInterpolationPart node) { | 75 R visitStringInterpolationPart(StringInterpolationPart node) { |
75 return visitNode(node); | 76 return visitNode(node); |
76 } | 77 } |
77 R visitSwitchCase(SwitchCase node) => visitNode(node); | 78 R visitSwitchCase(SwitchCase node) => visitNode(node); |
78 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); | 79 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); |
79 R visitThrow(Throw node) => visitStatement(node); | 80 R visitThrow(Throw node) => visitExpression(node); |
80 R visitTryStatement(TryStatement node) => visitStatement(node); | 81 R visitTryStatement(TryStatement node) => visitStatement(node); |
81 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); | 82 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); |
82 R visitTypedef(Typedef node) => visitNode(node); | 83 R visitTypedef(Typedef node) => visitNode(node); |
83 R visitTypeVariable(TypeVariable node) => visitNode(node); | 84 R visitTypeVariable(TypeVariable node) => visitNode(node); |
84 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); | 85 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); |
85 R visitWhile(While node) => visitLoop(node); | 86 R visitWhile(While node) => visitLoop(node); |
86 } | 87 } |
87 | 88 |
88 Token firstBeginToken(Node first, Node second) { | 89 Token firstBeginToken(Node first, Node second) { |
89 Token token = null; | 90 Token token = null; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 LiteralString asLiteralString() => null; | 172 LiteralString asLiteralString() => null; |
172 MixinApplication asMixinApplication() => null; | 173 MixinApplication asMixinApplication() => null; |
173 Modifiers asModifiers() => null; | 174 Modifiers asModifiers() => null; |
174 NamedArgument asNamedArgument() => null; | 175 NamedArgument asNamedArgument() => null; |
175 NamedMixinApplication asNamedMixinApplication() => null; | 176 NamedMixinApplication asNamedMixinApplication() => null; |
176 NodeList asNodeList() => null; | 177 NodeList asNodeList() => null; |
177 Operator asOperator() => null; | 178 Operator asOperator() => null; |
178 ParenthesizedExpression asParenthesizedExpression() => null; | 179 ParenthesizedExpression asParenthesizedExpression() => null; |
179 Part asPart() => null; | 180 Part asPart() => null; |
180 PartOf asPartOf() => null; | 181 PartOf asPartOf() => null; |
| 182 Rethrow asRethrow() => null; |
181 Return asReturn() => null; | 183 Return asReturn() => null; |
182 ScriptTag asScriptTag() => null; | 184 ScriptTag asScriptTag() => null; |
183 Send asSend() => null; | 185 Send asSend() => null; |
184 SendSet asSendSet() => null; | 186 SendSet asSendSet() => null; |
185 Statement asStatement() => null; | 187 Statement asStatement() => null; |
186 StringInterpolation asStringInterpolation() => null; | 188 StringInterpolation asStringInterpolation() => null; |
187 StringInterpolationPart asStringInterpolationPart() => null; | 189 StringInterpolationPart asStringInterpolationPart() => null; |
188 StringJuxtaposition asStringJuxtaposition() => null; | 190 StringJuxtaposition asStringJuxtaposition() => null; |
189 StringNode asStringNode() => null; | 191 StringNode asStringNode() => null; |
190 SwitchCase asSwitchCase() => null; | 192 SwitchCase asSwitchCase() => null; |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 | 999 |
998 visitChildren(Visitor visitor) { | 1000 visitChildren(Visitor visitor) { |
999 if (expression != null) expression.accept(visitor); | 1001 if (expression != null) expression.accept(visitor); |
1000 } | 1002 } |
1001 | 1003 |
1002 Token getBeginToken() => expression.getBeginToken(); | 1004 Token getBeginToken() => expression.getBeginToken(); |
1003 | 1005 |
1004 Token getEndToken() => endToken; | 1006 Token getEndToken() => endToken; |
1005 } | 1007 } |
1006 | 1008 |
1007 class Throw extends Statement { | 1009 class Throw extends Expression { |
1008 final Expression expression; | 1010 final Expression expression; |
1009 | 1011 |
1010 final Token throwToken; | 1012 final Token throwToken; |
1011 final Token endToken; | 1013 final Token endToken; |
1012 | 1014 |
1013 Throw(this.expression, this.throwToken, this.endToken); | 1015 Throw(this.expression, this.throwToken, this.endToken); |
1014 | 1016 |
1015 Throw asThrow() => this; | 1017 Throw asThrow() => this; |
1016 | 1018 |
1017 accept(Visitor visitor) => visitor.visitThrow(this); | 1019 accept(Visitor visitor) => visitor.visitThrow(this); |
1018 | 1020 |
1019 visitChildren(Visitor visitor) { | 1021 visitChildren(Visitor visitor) { |
1020 if (expression != null) expression.accept(visitor); | 1022 expression.accept(visitor); |
1021 } | 1023 } |
1022 | 1024 |
1023 Token getBeginToken() => throwToken; | 1025 Token getBeginToken() => throwToken; |
1024 | 1026 |
1025 Token getEndToken() => endToken; | 1027 Token getEndToken() => endToken; |
1026 } | 1028 } |
1027 | 1029 |
| 1030 class Rethrow extends Statement { |
| 1031 final Token throwToken; |
| 1032 final Token endToken; |
| 1033 |
| 1034 Rethrow(this.throwToken, this.endToken); |
| 1035 |
| 1036 Rethrow asRethrow() => this; |
| 1037 |
| 1038 accept(Visitor visitor) => visitor.visitRethrow(this); |
| 1039 visitChildren(Visitor visitor) { } |
| 1040 |
| 1041 Token getBeginToken() => throwToken; |
| 1042 Token getEndToken() => endToken; |
| 1043 } |
| 1044 |
1028 class TypeAnnotation extends Node { | 1045 class TypeAnnotation extends Node { |
1029 final Expression typeName; | 1046 final Expression typeName; |
1030 final NodeList typeArguments; | 1047 final NodeList typeArguments; |
1031 | 1048 |
1032 TypeAnnotation(Expression this.typeName, NodeList this.typeArguments); | 1049 TypeAnnotation(Expression this.typeName, NodeList this.typeArguments); |
1033 | 1050 |
1034 TypeAnnotation asTypeAnnotation() => this; | 1051 TypeAnnotation asTypeAnnotation() => this; |
1035 | 1052 |
1036 accept(Visitor visitor) => visitor.visitTypeAnnotation(this); | 1053 accept(Visitor visitor) => visitor.visitTypeAnnotation(this); |
1037 | 1054 |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 * argument). | 2088 * argument). |
2072 * | 2089 * |
2073 * TODO(ahe): This method is controversial, the team needs to discuss | 2090 * TODO(ahe): This method is controversial, the team needs to discuss |
2074 * if top-level methods are acceptable and what naming conventions to | 2091 * if top-level methods are acceptable and what naming conventions to |
2075 * use. | 2092 * use. |
2076 */ | 2093 */ |
2077 initializerDo(Node node, f(Node node)) { | 2094 initializerDo(Node node, f(Node node)) { |
2078 SendSet send = node.asSendSet(); | 2095 SendSet send = node.asSendSet(); |
2079 if (send != null) return f(send.arguments.head); | 2096 if (send != null) return f(send.arguments.head); |
2080 } | 2097 } |
OLD | NEW |