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

Unified Diff: pkg/js_ast/lib/src/builder.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/builder.dart
diff --git a/pkg/js_ast/lib/src/builder.dart b/pkg/js_ast/lib/src/builder.dart
index b58041d161e71e4431225cccbdfe7e6e0d8f6309..076ff65bb62ee4108eb004c41c6d660088123bce 100644
--- a/pkg/js_ast/lib/src/builder.dart
+++ b/pkg/js_ast/lib/src/builder.dart
@@ -352,6 +352,14 @@ class JsBuilder {
return new _InterleaveIterable(list, separator);
}
+ LiteralString quoteName(Name name, {allowNull: false}) {
+ if (name == null) {
+ assert(allowNull);
+ return new LiteralString('""');
+ }
+ return new LiteralStringFromName(name);
+ }
+
LiteralNumber number(num value) => new LiteralNumber('$value');
LiteralBool boolean(bool value) => new LiteralBool(value);
@@ -365,22 +373,30 @@ class JsBuilder {
Comment comment(String text) => new Comment(text);
Call propertyCall(Expression receiver,
- String fieldName,
- List<Expression> arguments) {
- return new Call(new PropertyAccess.field(receiver, fieldName), arguments);
+ Expression fieldName,
+ List<Expression> arguments) {
+ return new Call(new PropertyAccess(receiver, fieldName), arguments);
}
}
LiteralString string(String value) => js.string(value);
+LiteralString quoteName(Name name, {allowNull: false}) {
+ return js.quoteName(name, allowNull: allowNull);
+}
LiteralString stringPart(String value) => js.stringPart(value);
Iterable<Literal> joinLiterals(Iterable<Literal> list, Literal separator) {
return js.joinLiterals(list, separator);
}
+StringConcatenation concatenateStrings(Iterable<Literal> parts,
+ {addQuotes: false}) {
+ return js.concatenateStrings(parts, addQuotes: addQuotes);
+}
+
LiteralNumber number(num value) => js.number(value);
ArrayInitializer numArray(Iterable<int> list) => js.numArray(list);
ArrayInitializer stringArray(Iterable<String> list) => js.stringArray(list);
Call propertyCall(Expression receiver,
- String fieldName,
+ Expression fieldName,
List<Expression> arguments) {
return js.propertyCall(receiver, fieldName, arguments);
}

Powered by Google App Engine
This is Rietveld 408576698