Index: pkg/js_ast/lib/src/nodes.dart |
diff --git a/pkg/js_ast/lib/src/nodes.dart b/pkg/js_ast/lib/src/nodes.dart |
index 7c8293e8d9e5ae5896583167499a28236375793f..5b71db99826efee3db2570cf3b1a7af963e27aec 100644 |
--- a/pkg/js_ast/lib/src/nodes.dart |
+++ b/pkg/js_ast/lib/src/nodes.dart |
@@ -49,11 +49,17 @@ abstract class NodeVisitor<T> { |
T visitNamedFunction(NamedFunction node); |
T visitFun(Fun node); |
+ T visitTokenExpression(TokenExpression node); |
+ T visitTokenNumber(TokenNumber node); |
+ T visitTokenString(TokenString node); |
+ |
T visitLiteralBool(LiteralBool node); |
T visitLiteralString(LiteralString node); |
T visitLiteralNumber(LiteralNumber node); |
T visitLiteralNull(LiteralNull node); |
+ T visitStringConcatenation(StringConcatenation node); |
+ |
T visitArrayInitializer(ArrayInitializer node); |
T visitArrayHole(ArrayHole node); |
T visitObjectInitializer(ObjectInitializer node); |
@@ -139,6 +145,12 @@ class BaseVisitor<T> implements NodeVisitor<T> { |
T visitNamedFunction(NamedFunction node) => visitExpression(node); |
T visitFun(Fun node) => visitExpression(node); |
+ T visitToken(Token node) => visitExpression(node); |
+ |
+ T visitTokenExpression(TokenExpression node) => visitExpression(node); |
+ T visitTokenNumber(TokenNumber node) => visitToken(node); |
+ T visitTokenString(TokenString node) => visitToken(node); |
+ |
T visitLiteral(Literal node) => visitExpression(node); |
T visitLiteralBool(LiteralBool node) => visitLiteral(node); |
@@ -146,6 +158,8 @@ class BaseVisitor<T> implements NodeVisitor<T> { |
T visitLiteralNumber(LiteralNumber node) => visitLiteral(node); |
T visitLiteralNull(LiteralNull node) => visitLiteral(node); |
+ T visitStringConcatenation(StringConcatenation node) => visitLiteral(node); |
+ |
T visitArrayInitializer(ArrayInitializer node) => visitExpression(node); |
T visitArrayHole(ArrayHole node) => visitExpression(node); |
T visitObjectInitializer(ObjectInitializer node) => visitExpression(node); |
@@ -916,6 +930,30 @@ class PropertyAccess extends Expression { |
int get precedenceLevel => CALL; |
} |
+abstract class Token extends Literal { |
sra1
2015/05/27 19:38:51
These are abstract classes that are overridden.
De
herhut
2015/06/09 11:10:00
Well, this is only one use (the current use) of th
|
+ void visitChildren(NodeVisitor visitor) {} |
+ |
+ Token _clone() => this; |
+} |
+ |
+abstract class TokenNumber extends Token { |
+ accept(NodeVisitor visitor) => visitor.visitTokenNumber(this); |
+ |
+ int get value; |
+} |
+ |
+abstract class TokenString extends Token { |
+ accept(NodeVisitor visitor) => visitor.visitTokenString(this); |
+ |
+ String get value; |
+} |
+ |
+abstract class TokenExpression extends Token { |
sra1
2015/05/27 19:38:51
What is a TokenExpression?
DeferredExpression?
herhut
2015/06/09 11:10:00
Done.
|
+ accept(NodeVisitor visitor) => visitor.visitTokenExpression(this); |
+ |
+ Expression get value; |
sra1
2015/05/27 19:38:51
What is the precedence?
PRIMARY is almost certainl
herhut
2015/06/09 11:10:00
It actually was correct for the current usage but
|
+} |
+ |
abstract class Literal extends Expression { |
void visitChildren(NodeVisitor visitor) {} |
@@ -946,7 +984,7 @@ class LiteralString extends Literal { |
* Constructs a LiteralString from a string value. |
* |
* The constructor does not add the required quotes. If [value] is not |
- * surrounded by quotes and property escaped, the resulting object is invalid |
+ * surrounded by quotes and properly escaped, the resulting object is invalid |
* as a JS value. |
* |
* TODO(sra): Introduce variants for known valid strings that don't allocate a |
@@ -958,6 +996,25 @@ class LiteralString extends Literal { |
LiteralString _clone() => new LiteralString(value); |
} |
+class StringConcatenation extends Literal { |
+ final List<Literal> parts; |
+ |
+ /** |
+ * Constructs a StringConcatenation from a list of Literal elements. |
+ * The constructor does not add surrounding quotes to the resulting |
+ * concatenated string. |
+ */ |
+ StringConcatenation(this.parts); |
+ |
+ accept(NodeVisitor visitor) => visitor.visitStringConcatenation(this); |
+ |
+ void visitChildren(NodeVisitor visitor) { |
+ for (Literal part in parts) part.accept(visitor); |
+ } |
+ |
+ StringConcatenation _clone() => new StringConcatenation(this.parts); |
+} |
+ |
class LiteralNumber extends Literal { |
final String value; // Must be a valid JavaScript number literal. |
@@ -1161,7 +1218,6 @@ class Await extends Expression { |
accept(NodeVisitor visitor) => visitor.visitAwait(this); |
void visitChildren(NodeVisitor visitor) => expression.accept(visitor); |
Await _clone() => new Await(expression); |
- |
} |
/** |