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

Unified Diff: pkg/js_ast/lib/src/printer.dart

Issue 1212613009: dart2js: Implement frequency based naming. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Reserve reserved names :) 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 | « pkg/js_ast/lib/src/nodes.dart ('k') | tests/compiler/dart2js/token_naming_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/js_ast/lib/src/printer.dart
diff --git a/pkg/js_ast/lib/src/printer.dart b/pkg/js_ast/lib/src/printer.dart
index ff757b4cbd90d87ec1863be0751e3c695f2e6ad4..94cec32f28548dafcc48ce024f3bd34d1be333ef 100644
--- a/pkg/js_ast/lib/src/printer.dart
+++ b/pkg/js_ast/lib/src/printer.dart
@@ -5,15 +5,21 @@
part of js_ast;
+typedef String Renamer(Name);
+
class JavaScriptPrintingOptions {
final bool shouldCompressOutput;
final bool minifyLocalVariables;
final bool preferSemicolonToNewlineInMinifiedOutput;
+ final Renamer renamerForNames;
JavaScriptPrintingOptions(
{this.shouldCompressOutput: false,
this.minifyLocalVariables: false,
- this.preferSemicolonToNewlineInMinifiedOutput: false});
+ this.preferSemicolonToNewlineInMinifiedOutput: false,
+ this.renamerForNames: identityRenamer});
+
+ static String identityRenamer(Name name) => name.name;
}
@@ -930,7 +936,7 @@ class Printer implements NodeVisitor {
} else if (selector is Name) {
if (access.receiver is LiteralNumber) out(" ", isWhitespace: true);
out(".");
- out(selector.name);
+ selector.accept(this);
return;
}
out("[");
@@ -998,7 +1004,7 @@ class Printer implements NodeVisitor {
@override
visitName(Name node) {
- out(node.name);
+ out(options.renamerForNames(node));
}
@override
« no previous file with comments | « pkg/js_ast/lib/src/nodes.dart ('k') | tests/compiler/dart2js/token_naming_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698