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); |
11 | 11 |
| 12 R visitAssert(Assert node) => visitStatement(node); |
12 R visitAsyncForIn(AsyncForIn node) => visitLoop(node); | 13 R visitAsyncForIn(AsyncForIn node) => visitLoop(node); |
13 R visitAsyncModifier(AsyncModifier node) => visitNode(node); | 14 R visitAsyncModifier(AsyncModifier node) => visitNode(node); |
14 R visitAwait(Await node) => visitExpression(node); | 15 R visitAwait(Await node) => visitExpression(node); |
15 R visitBlock(Block node) => visitStatement(node); | 16 R visitBlock(Block node) => visitStatement(node); |
16 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node); | 17 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node); |
17 R visitCascade(Cascade node) => visitExpression(node); | 18 R visitCascade(Cascade node) => visitExpression(node); |
18 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node); | 19 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node); |
19 R visitCaseMatch(CaseMatch node) => visitNode(node); | 20 R visitCaseMatch(CaseMatch node) => visitNode(node); |
20 R visitCatchBlock(CatchBlock node) => visitNode(node); | 21 R visitCatchBlock(CatchBlock node) => visitNode(node); |
21 R visitClassNode(ClassNode node) => visitNode(node); | 22 R visitClassNode(ClassNode node) => visitNode(node); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 toDebugString() { | 140 toDebugString() { |
140 return PrettyPrinter.prettyPrint(this); | 141 return PrettyPrinter.prettyPrint(this); |
141 } | 142 } |
142 | 143 |
143 String getObjectDescription() => super.toString(); | 144 String getObjectDescription() => super.toString(); |
144 | 145 |
145 Token getBeginToken(); | 146 Token getBeginToken(); |
146 | 147 |
147 Token getEndToken(); | 148 Token getEndToken(); |
148 | 149 |
| 150 Assert asAssert() => null; |
149 AsyncModifier asAsyncModifier() => null; | 151 AsyncModifier asAsyncModifier() => null; |
150 Await asAwait() => null; | 152 Await asAwait() => null; |
151 Block asBlock() => null; | 153 Block asBlock() => null; |
152 BreakStatement asBreakStatement() => null; | 154 BreakStatement asBreakStatement() => null; |
153 Cascade asCascade() => null; | 155 Cascade asCascade() => null; |
154 CascadeReceiver asCascadeReceiver() => null; | 156 CascadeReceiver asCascadeReceiver() => null; |
155 CaseMatch asCaseMatch() => null; | 157 CaseMatch asCaseMatch() => null; |
156 CatchBlock asCatchBlock() => null; | 158 CatchBlock asCatchBlock() => null; |
157 ClassNode asClassNode() => null; | 159 ClassNode asClassNode() => null; |
158 Combinator asCombinator() => null; | 160 Combinator asCombinator() => null; |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 | 1206 |
1205 visitChildren(Visitor visitor) { | 1207 visitChildren(Visitor visitor) { |
1206 expression.accept(visitor); | 1208 expression.accept(visitor); |
1207 } | 1209 } |
1208 | 1210 |
1209 Token getBeginToken() => awaitToken; | 1211 Token getBeginToken() => awaitToken; |
1210 | 1212 |
1211 Token getEndToken() => expression.getEndToken(); | 1213 Token getEndToken() => expression.getEndToken(); |
1212 } | 1214 } |
1213 | 1215 |
| 1216 class Assert extends Statement { |
| 1217 final Token assertToken; |
| 1218 final Expression condition; |
| 1219 /** Message may be `null`. */ |
| 1220 final Expression message; |
| 1221 final Token semicolonToken; |
| 1222 |
| 1223 Assert(this.assertToken, this.condition, this.message, this.semicolonToken); |
| 1224 |
| 1225 Assert asAssert() => this; |
| 1226 |
| 1227 bool get hasMessage => message != null; |
| 1228 |
| 1229 accept(Visitor visitor) => visitor.visitAssert(this); |
| 1230 |
| 1231 visitChildren(Visitor visitor) { |
| 1232 condition.accept(visitor); |
| 1233 if (message != null) message.accept(visitor); |
| 1234 } |
| 1235 |
| 1236 Token getBeginToken() => assertToken; |
| 1237 Token getEndToken() => semicolonToken; |
| 1238 } |
| 1239 |
1214 class Rethrow extends Statement { | 1240 class Rethrow extends Statement { |
1215 final Token throwToken; | 1241 final Token throwToken; |
1216 final Token endToken; | 1242 final Token endToken; |
1217 | 1243 |
1218 Rethrow(this.throwToken, this.endToken); | 1244 Rethrow(this.throwToken, this.endToken); |
1219 | 1245 |
1220 Rethrow asRethrow() => this; | 1246 Rethrow asRethrow() => this; |
1221 | 1247 |
1222 accept(Visitor visitor) => visitor.visitRethrow(this); | 1248 accept(Visitor visitor) => visitor.visitRethrow(this); |
1223 visitChildren(Visitor visitor) { } | 1249 visitChildren(Visitor visitor) { } |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 | 2373 |
2348 // VariableDefinitions. | 2374 // VariableDefinitions. |
2349 get metadata => null; | 2375 get metadata => null; |
2350 get type => null; | 2376 get type => null; |
2351 | 2377 |
2352 // Typedef. | 2378 // Typedef. |
2353 get typeParameters => null; | 2379 get typeParameters => null; |
2354 get formals => null; | 2380 get formals => null; |
2355 get typedefKeyword => null; | 2381 get typedefKeyword => null; |
2356 } | 2382 } |
OLD | NEW |