Index: lib/src/backend/platform_selector/ast.dart |
diff --git a/lib/src/backend/platform_selector/ast.dart b/lib/src/backend/platform_selector/ast.dart |
index d1eb0aac16f50b30f33a9256e171cb48dd405313..c76fe18096598fa13056f6b41525607b6b3e461f 100644 |
--- a/lib/src/backend/platform_selector/ast.dart |
+++ b/lib/src/backend/platform_selector/ast.dart |
@@ -6,6 +6,8 @@ library unittest.backend.platform_selector.ast; |
import 'package:source_span/source_span.dart'; |
+import 'visitor.dart'; |
+ |
/// The superclass of nodes in the platform selector abstract syntax tree. |
abstract class Node { |
/// The span indicating where this node came from. |
@@ -16,6 +18,9 @@ abstract class Node { |
/// |
/// This may be `null` for nodes without source information. |
FileSpan get span; |
+ |
+ /// Calls the appropriate [Visitor] method on [this] and returns the result. |
+ accept(Visitor visitor); |
} |
/// A single variable. |
@@ -27,6 +32,8 @@ class VariableNode implements Node { |
VariableNode(this.name, [this.span]); |
+ accept(Visitor visitor) => visitor.visitVariable(this); |
+ |
String toString() => name; |
} |
@@ -39,6 +46,8 @@ class NotNode implements Node { |
NotNode(this.child, [this.span]); |
+ accept(Visitor visitor) => visitor.visitNot(this); |
+ |
String toString() => child is VariableNode || child is NotNode |
? "!$child" |
: "!($child)"; |
@@ -56,6 +65,8 @@ class OrNode implements Node { |
OrNode(this.left, this.right); |
+ accept(Visitor visitor) => visitor.visitOr(this); |
+ |
String toString() { |
var string1 = left is AndNode || left is ConditionalNode |
? "($left)" |
@@ -80,6 +91,8 @@ class AndNode implements Node { |
AndNode(this.left, this.right); |
+ accept(Visitor visitor) => visitor.visitAnd(this); |
+ |
String toString() { |
var string1 = left is OrNode || left is ConditionalNode |
? "($left)" |
@@ -107,6 +120,8 @@ class ConditionalNode implements Node { |
ConditionalNode(this.condition, this.whenTrue, this.whenFalse); |
+ accept(Visitor visitor) => visitor.visitConditional(this); |
+ |
String toString() { |
var conditionString = |
condition is ConditionalNode ? "($condition)" : condition; |