Index: mojo/public/dart/third_party/test/lib/src/backend/platform_selector/visitor.dart |
diff --git a/mojo/public/dart/third_party/test/lib/src/backend/platform_selector/visitor.dart b/mojo/public/dart/third_party/test/lib/src/backend/platform_selector/visitor.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..67d95b976f8f00b24c983e52e0503fa7fcd62d05 |
--- /dev/null |
+++ b/mojo/public/dart/third_party/test/lib/src/backend/platform_selector/visitor.dart |
@@ -0,0 +1,46 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library test.backend.platform_selector.visitor; |
+ |
+import 'ast.dart'; |
+ |
+/// The interface for visitors of the platform selector AST. |
+abstract class Visitor<T> { |
+ T visitVariable(VariableNode node); |
+ T visitNot(NotNode node); |
+ T visitOr(OrNode node); |
+ T visitAnd(AndNode node); |
+ T visitConditional(ConditionalNode node); |
+} |
+ |
+/// An abstract superclass for side-effect-based visitors. |
+/// |
+/// The default implementations of this visitor's methods just traverse the AST |
+/// and do nothing with it. |
+abstract class RecursiveVisitor implements Visitor { |
+ const RecursiveVisitor(); |
+ |
+ void visitVariable(VariableNode node) {} |
+ |
+ void visitNot(NotNode node) { |
+ node.child.accept(this); |
+ } |
+ |
+ void visitOr(OrNode node) { |
+ node.left.accept(this); |
+ node.right.accept(this); |
+ } |
+ |
+ void visitAnd(AndNode node) { |
+ node.left.accept(this); |
+ node.right.accept(this); |
+ } |
+ |
+ void visitConditional(ConditionalNode node) { |
+ node.condition.accept(this); |
+ node.whenTrue.accept(this); |
+ node.whenFalse.accept(this); |
+ } |
+} |