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

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

Issue 11795002: Revert "Retry "Emit more stuff via ASTs"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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: sdk/lib/_internal/compiler/implementation/js/printer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js/printer.dart b/sdk/lib/_internal/compiler/implementation/js/printer.dart
index 1cdfbf977d261038b16aa2db2738d62b738b044e..048dc71a00d20065768637dcd62e8c6dc5638a64 100644
--- a/sdk/lib/_internal/compiler/implementation/js/printer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js/printer.dart
@@ -31,17 +31,12 @@ class Printer implements NodeVisitor {
? new MinifyRenamer() : new IdentityNamer();
}
- /// Always emit a newline, even under `enableMinification`.
- void forceLine() {
- out("\n");
- }
- /// Emits a newline for readability.
- void lineOut() {
- if (!shouldCompressOutput) forceLine();
- }
void spaceOut() {
if (!shouldCompressOutput) out(" ");
}
+ void lineOut() {
+ if (!shouldCompressOutput) out("\n");
+ }
String lastAddedString = null;
int get lastCharCode {
@@ -75,8 +70,7 @@ class Printer implements NodeVisitor {
if (shouldCompressOutput) {
pendingSemicolon = true;
} else {
- out(";");
- forceLine();
+ out(";\n");
}
}
@@ -678,10 +672,8 @@ class Printer implements NodeVisitor {
return false;
}
}
- // TODO(floitsch): normally we should also check that the field is not a
- // reserved word. We don't generate fields with reserved word names except
- // for 'super'.
- if (field == '"super"') return false;
+ // TODO(floitsch): normally we should also check that the field is not
+ // a reserved word.
return true;
}
@@ -766,28 +758,15 @@ class Printer implements NodeVisitor {
}
visitObjectInitializer(ObjectInitializer node) {
- // Print all the properties on one line until we see a function-valued
- // property. Ideally, we would use a proper pretty-printer to make the
- // decision based on layout.
- bool onePerLine = false;
- List<Property> properties = node.properties;
out("{");
- ++indentLevel;
+ List<Property> properties = node.properties;
for (int i = 0; i < properties.length; i++) {
- Expression value = properties[i].value;
- if (value is Fun || value is NamedFunction) onePerLine = true;
if (i != 0) {
out(",");
- if (!onePerLine) spaceOut();
- }
- if (onePerLine) {
- forceLine();
- indent();
+ spaceOut();
}
visitProperty(properties[i]);
}
- --indentLevel;
- if (onePerLine) lineOut();
out("}");
}

Powered by Google App Engine
This is Rietveld 408576698