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

Unified Diff: pkg/js_ast/lib/src/nodes.dart

Issue 1198293002: dart2js: Use an abstract Name class for names in the generated JavaScript ast. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix tests Created 5 years, 6 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
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 8dc7f8f637ed121298fb3a59cf3d84c93002dee4..33b5c58431e6bbe5512a9d1bbb3edfa2a38bb6af 100644
--- a/pkg/js_ast/lib/src/nodes.dart
+++ b/pkg/js_ast/lib/src/nodes.dart
@@ -60,6 +60,8 @@ abstract class NodeVisitor<T> {
T visitStringConcatenation(StringConcatenation node);
+ T visitName(Name node);
+
T visitArrayInitializer(ArrayInitializer node);
T visitArrayHole(ArrayHole node);
T visitObjectInitializer(ObjectInitializer node);
@@ -160,6 +162,8 @@ class BaseVisitor<T> implements NodeVisitor<T> {
T visitStringConcatenation(StringConcatenation node) => visitLiteral(node);
+ T visitName(Name node) => visitNode(node);
+
T visitArrayInitializer(ArrayInitializer node) => visitExpression(node);
T visitArrayHole(ArrayHole node) => visitExpression(node);
T visitObjectInitializer(ObjectInitializer node) => visitExpression(node);
@@ -573,6 +577,28 @@ abstract class Declaration implements VariableReference {
}
+/// An implementation of [Name] represents a potentially late bound name in
+/// the generated ast.
+///
+/// While [Name] implements comparable, there is no requirement on the actual
+/// implementation of [compareTo] other than that it needs to be stable.
+/// In particular, there is no guarantee that implementations of [compareTo]
+/// will implement some form of lexicographic ordering like [String.compareTo].
+abstract class Name extends Literal
+ implements Declaration, Parameter, Comparable {
+ accept(NodeVisitor visitor) => visitor.visitName(this);
+
+ bool get allowRename => false;
+}
+
+class LiteralStringFromName extends LiteralString {
+ Name name;
+
+ LiteralStringFromName(this.name) : super(null);
+
+ String get value => '"${name.name}"';
+}
+
class LiteralExpression extends Expression {
final String template;
final List<Expression> inputs;

Powered by Google App Engine
This is Rietveld 408576698