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

Unified Diff: lib/src/js/printer.dart

Issue 1183033004: js_ast: implement rest/spread parsing (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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
« no previous file with comments | « lib/src/js/precedence.dart ('k') | lib/src/js/template.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/js/printer.dart
diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart
index 7f75634e91d6fe0c1d7fb9d9a8742f767d03875e..d5cf9e1ef54845859a3778df3d0eb7b2198985de 100644
--- a/lib/src/js/printer.dart
+++ b/lib/src/js/printer.dart
@@ -623,7 +623,7 @@ class Printer implements NodeVisitor {
newInForInit: inForInit, newAtStatementBegin: false);
inNewTarget = false;
out("(");
- visitCommaSeparated(node.arguments, ASSIGNMENT,
+ visitCommaSeparated(node.arguments, SPREAD,
newInForInit: false, newAtStatementBegin: false);
out(")");
}
@@ -633,7 +633,7 @@ class Printer implements NodeVisitor {
newInForInit: inForInit,
newAtStatementBegin: atStatementBegin);
out("(");
- visitCommaSeparated(call.arguments, ASSIGNMENT,
+ visitCommaSeparated(call.arguments, SPREAD,
newInForInit: false, newAtStatementBegin: false);
out(")");
}
@@ -764,10 +764,12 @@ class Printer implements NodeVisitor {
default:
out(op);
}
- visitNestedExpression(unary.argument, UNARY,
+ visitNestedExpression(unary.argument, unary.precedenceLevel,
newInForInit: inForInit, newAtStatementBegin: false);
}
+ visitSpread(Spread unary) => visitPrefix(unary);
+
visitPostfix(Postfix postfix) {
visitNestedExpression(postfix.argument, LEFT_HAND_SIDE,
newInForInit: inForInit,
@@ -787,6 +789,11 @@ class Printer implements NodeVisitor {
out(localNamer.getName(node));
}
+ visitRestParameter(RestParameter node) {
+ out('...');
+ visitIdentifier(node.parameter);
+ }
+
bool isDigit(int charCode) {
return charCodes.$0 <= charCode && charCode <= charCodes.$9;
}
@@ -846,11 +853,11 @@ class Printer implements NodeVisitor {
visitArrowFun(ArrowFun fun) {
localNamer.enterScope(fun);
if (fun.params.length == 1) {
- visitNestedExpression(fun.params.single, PRIMARY,
+ visitNestedExpression(fun.params.single, SPREAD,
newInForInit: false, newAtStatementBegin: false);
} else {
out("(");
- visitCommaSeparated(fun.params, PRIMARY,
+ visitCommaSeparated(fun.params, SPREAD,
newInForInit: false, newAtStatementBegin: false);
out(")");
}
@@ -1032,7 +1039,7 @@ class Printer implements NodeVisitor {
localNamer.enterScope(fun);
out("(");
if (fun.params != null) {
- visitCommaSeparated(fun.params, PRIMARY,
+ visitCommaSeparated(fun.params, SPREAD,
newInForInit: false, newAtStatementBegin: false);
}
out(")");
@@ -1419,7 +1426,9 @@ abstract class VariableDeclarationVisitor<T> extends BaseVisitor<T> {
declare(Identifier node);
visitFunctionExpression(FunctionExpression node) {
- for (Identifier param in node.params) declare(param);
+ for (var p in node.params) {
+ declare(p is RestParameter ? p.parameter : p);
+ }
node.body.accept(this);
}
« no previous file with comments | « lib/src/js/precedence.dart ('k') | lib/src/js/template.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698