OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'ast.dart'; |
| 6 |
| 7 /// The interface for visitors of the boolean selector AST. |
| 8 abstract class Visitor<T> { |
| 9 T visitVariable(VariableNode node); |
| 10 T visitNot(NotNode node); |
| 11 T visitOr(OrNode node); |
| 12 T visitAnd(AndNode node); |
| 13 T visitConditional(ConditionalNode node); |
| 14 } |
| 15 |
| 16 /// An abstract superclass for side-effect-based visitors. |
| 17 /// |
| 18 /// The default implementations of this visitor's methods just traverse the AST |
| 19 /// and do nothing with it. |
| 20 abstract class RecursiveVisitor implements Visitor { |
| 21 const RecursiveVisitor(); |
| 22 |
| 23 void visitVariable(VariableNode node) {} |
| 24 |
| 25 void visitNot(NotNode node) { |
| 26 node.child.accept(this); |
| 27 } |
| 28 |
| 29 void visitOr(OrNode node) { |
| 30 node.left.accept(this); |
| 31 node.right.accept(this); |
| 32 } |
| 33 |
| 34 void visitAnd(AndNode node) { |
| 35 node.left.accept(this); |
| 36 node.right.accept(this); |
| 37 } |
| 38 |
| 39 void visitConditional(ConditionalNode node) { |
| 40 node.condition.accept(this); |
| 41 node.whenTrue.accept(this); |
| 42 node.whenFalse.accept(this); |
| 43 } |
| 44 } |
OLD | NEW |