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

Unified Diff: lib/compiler/implementation/js/printer.dart

Issue 10831365: Don't put parenthesis to LiteralExpression (ie foreign expressions) when the expression starts a st… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/js/printer.dart
===================================================================
--- lib/compiler/implementation/js/printer.dart (revision 10872)
+++ lib/compiler/implementation/js/printer.dart (working copy)
@@ -37,10 +37,12 @@
lastAddedString = str;
}
}
+
void outLn(String str) {
out(str);
lineOut();
}
+
void outIndent(String str) { indent(); out(str); }
void outIndentLn(String str) { indent(); outLn(str); }
void indent() {
@@ -752,13 +754,15 @@
if (parts.length != inputs.length + 1) {
compiler.internalError('Wrong number of arguments for JS: $template');
}
- out("(");
+ // Save [atStatementBegin] because visiting the parts might change it.
+ bool beginStatement = atStatementBegin;
+ if (!beginStatement) out("(");
out(parts[0]);
for (int i = 0; i < inputs.length; i++) {
visit(inputs[i]);
out(parts[i + 1]);
}
- out(")");
+ if (!beginStatement) out(")");
}
visitLiteralStatement(LiteralStatement node) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698