Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: pkg/compiler/lib/src/js/nodes.dart

Issue 932053002: Support for interpolated declarations in the js parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js/builder.dart ('k') | pkg/compiler/lib/src/js/printer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/nodes.dart
diff --git a/pkg/compiler/lib/src/js/nodes.dart b/pkg/compiler/lib/src/js/nodes.dart
index 92446fa8bf48b3d4faeefcfa0a2013d7b8ec4343..cc758baabc9913bfa9a06b2042720de8845d0746 100644
--- a/pkg/compiler/lib/src/js/nodes.dart
+++ b/pkg/compiler/lib/src/js/nodes.dart
@@ -69,6 +69,7 @@ abstract class NodeVisitor<T> {
T visitInterpolatedParameter(InterpolatedParameter node);
T visitInterpolatedSelector(InterpolatedSelector node);
T visitInterpolatedStatement(InterpolatedStatement node);
+ T visitInterpolatedDeclaration(InterpolatedDeclaration node);
}
class BaseVisitor<T> implements NodeVisitor<T> {
@@ -163,6 +164,9 @@ class BaseVisitor<T> implements NodeVisitor<T> {
=> visitInterpolatedNode(node);
T visitInterpolatedStatement(InterpolatedStatement node)
=> visitInterpolatedNode(node);
+ T visitInterpolatedDeclaration(InterpolatedDeclaration node) {
+ return visitInterpolatedNode(node);
+ }
// Ignore comments by default.
T visitComment(Comment node) => null;
@@ -419,7 +423,7 @@ class Try extends Statement {
}
class Catch extends Node {
- final VariableDeclaration declaration;
+ final Declaration declaration;
final Block body;
Catch(this.declaration, this.body);
@@ -484,7 +488,7 @@ class Default extends SwitchClause {
}
class FunctionDeclaration extends Statement {
- final VariableDeclaration name;
+ final Declaration name;
final Fun function;
FunctionDeclaration(this.name, this.function);
@@ -549,6 +553,10 @@ abstract class Expression extends Node {
Statement toStatement() => new ExpressionStatement(this);
}
+abstract class Declaration implements VariableReference {
+
+}
+
class LiteralExpression extends Expression {
final String template;
final List<Expression> inputs;
@@ -620,10 +628,10 @@ class Assignment extends Expression {
class VariableInitialization extends Assignment {
/** [value] may be null. */
- VariableInitialization(VariableDeclaration declaration, Expression value)
+ VariableInitialization(Declaration declaration, Expression value)
: super(declaration, value);
- VariableDeclaration get declaration => leftHandSide;
+ Declaration get declaration => leftHandSide;
accept(NodeVisitor visitor) => visitor.visitVariableInitialization(this);
@@ -798,7 +806,7 @@ class VariableUse extends VariableReference {
toString() => 'VariableUse($name)';
}
-class VariableDeclaration extends VariableReference {
+class VariableDeclaration extends VariableReference implements Declaration {
final bool allowRename;
VariableDeclaration(String name, {this.allowRename: true}) : super(name);
@@ -821,7 +829,7 @@ class This extends Parameter {
}
class NamedFunction extends Expression {
- final VariableDeclaration name;
+ final Declaration name;
final Fun function;
NamedFunction(this.name, this.function);
@@ -1093,6 +1101,26 @@ class InterpolatedStatement extends Statement with InterpolatedNode {
InterpolatedStatement _clone() => new InterpolatedStatement(nameOrPosition);
}
+class InterpolatedDeclaration extends Expression
+ with InterpolatedNode
+ implements Declaration {
+ final nameOrPosition;
+
+ InterpolatedDeclaration(this.nameOrPosition);
+
+ accept(NodeVisitor visitor) => visitor.visitInterpolatedDeclaration(this);
+ void visitChildren(NodeVisitor visitor) {}
+ InterpolatedDeclaration _clone() {
+ return new InterpolatedDeclaration(nameOrPosition);
+ }
+
+ @override
+ String get name => throw "No name for the interpolated node";
+
+ @override
+ int get precedenceLevel => PRIMARY;
+}
+
/**
* [RegExpLiteral]s, despite being called "Literal", do not inherit from
* [Literal]. Indeed, regular expressions in JavaScript have a side-effect and
« no previous file with comments | « pkg/compiler/lib/src/js/builder.dart ('k') | pkg/compiler/lib/src/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698