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

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

Issue 10860036: Few tweaks to the generated code to avoid eg parenthesis. (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 | « lib/compiler/implementation/js/nodes.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | 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 10937)
+++ lib/compiler/implementation/js/printer.dart (working copy)
@@ -278,7 +278,6 @@
visitTry(Try node) {
outIndent("try");
blockBody(node.body, needsSeparation: true, needsNewline: false);
- spaceOut();
if (node.catchPart !== null) {
visit(node.catchPart);
}
@@ -642,7 +641,7 @@
LiteralString selectorString = selector;
String fieldWithQuotes = selectorString.value;
if (isValidJavaScriptId(fieldWithQuotes)) {
- if (isDigit(lastCharCode)) out(" ");
+ if (access.receiver is LiteralNumber) out(" ");
out(".");
out(fieldWithQuotes.substring(1, fieldWithQuotes.length - 1));
return;
@@ -754,15 +753,13 @@
if (parts.length != inputs.length + 1) {
compiler.internalError('Wrong number of arguments for JS: $template');
}
- // Save [atStatementBegin] because visiting the parts might change it.
- bool beginStatement = atStatementBegin;
- if (!beginStatement) out("(");
+ // Code that uses JS must take care of operator precedences, and
+ // put parenthesis if needed.
out(parts[0]);
for (int i = 0; i < inputs.length; i++) {
visit(inputs[i]);
out(parts[i + 1]);
}
- if (!beginStatement) out(")");
}
visitLiteralStatement(LiteralStatement node) {
« no previous file with comments | « lib/compiler/implementation/js/nodes.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698