OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.ast.visitor; | 4 library kernel.ast.visitor; |
5 | 5 |
6 import 'ast.dart'; | 6 import 'ast.dart'; |
7 | 7 |
8 abstract class ExpressionVisitor<R> { | 8 abstract class ExpressionVisitor<R> { |
9 R defaultExpression(Expression node) => null; | 9 R defaultExpression(Expression node) => null; |
10 R defaultBasicLiteral(BasicLiteral node) => defaultExpression(node); | 10 R defaultBasicLiteral(BasicLiteral node) => defaultExpression(node); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 class MemberReferenceVisitor<R> { | 229 class MemberReferenceVisitor<R> { |
230 R defaultMemberReference(Member node) => null; | 230 R defaultMemberReference(Member node) => null; |
231 | 231 |
232 R visitFieldReference(Field node) => defaultMemberReference(node); | 232 R visitFieldReference(Field node) => defaultMemberReference(node); |
233 R visitConstructorReference(Constructor node) => defaultMemberReference(node); | 233 R visitConstructorReference(Constructor node) => defaultMemberReference(node); |
234 R visitProcedureReference(Procedure node) => defaultMemberReference(node); | 234 R visitProcedureReference(Procedure node) => defaultMemberReference(node); |
235 } | 235 } |
236 | 236 |
237 class Visitor<R> extends TreeVisitor<R> | 237 class Visitor<R> extends TreeVisitor<R> |
238 implements | 238 implements DartTypeVisitor<R>, MemberReferenceVisitor<R> { |
239 DartTypeVisitor<R>, | |
240 MemberReferenceVisitor<R> { | |
241 /// The catch-all case, except for references. | 239 /// The catch-all case, except for references. |
242 R defaultNode(Node node) => null; | 240 R defaultNode(Node node) => null; |
243 R defaultTreeNode(TreeNode node) => defaultNode(node); | 241 R defaultTreeNode(TreeNode node) => defaultNode(node); |
244 | 242 |
245 /// Inferred values | 243 /// Inferred values |
246 R visitInferredValue(InferredValue node) => defaultNode(node); | 244 R visitInferredValue(InferredValue node) => defaultNode(node); |
247 | 245 |
248 // DartTypes | 246 // DartTypes |
249 R defaultDartType(DartType node) => defaultNode(node); | 247 R defaultDartType(DartType node) => defaultNode(node); |
250 R visitInvalidType(InvalidType node) => defaultDartType(node); | 248 R visitInvalidType(InvalidType node) => defaultDartType(node); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 /// By default, recursion stops at this point. | 304 /// By default, recursion stops at this point. |
307 DartType visitDartType(DartType node) => node; | 305 DartType visitDartType(DartType node) => node; |
308 | 306 |
309 Supertype visitSupertype(Supertype node) => node; | 307 Supertype visitSupertype(Supertype node) => node; |
310 | 308 |
311 TreeNode defaultTreeNode(TreeNode node) { | 309 TreeNode defaultTreeNode(TreeNode node) { |
312 node.transformChildren(this); | 310 node.transformChildren(this); |
313 return node; | 311 return node; |
314 } | 312 } |
315 } | 313 } |
OLD | NEW |