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

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

Issue 11364213: Rename classes, methods and fields when minifying (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 5bdbfd98b0c2ca90f35c197b7fbd5bee717579f5..0ff354c896898c99aa5f5d0633d240c827429be9 100644
--- a/sdk/lib/_internal/compiler/implementation/js/printer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js/printer.dart
@@ -12,7 +12,7 @@ class Printer implements NodeVisitor {
bool inForInit = false;
bool atStatementBegin = false;
final DanglingElseVisitor danglingElseVisitor;
- final Namer namer;
+ final LocalNamer localNamer;
bool pendingSemicolon = false;
bool pendingSpace = false;
@@ -21,11 +21,11 @@ class Printer implements NodeVisitor {
this.compiler = compiler,
outBuffer = new leg.CodeBuffer(),
danglingElseVisitor = new DanglingElseVisitor(compiler),
- namer = determineRenamer(compiler.enableMinification,
- allowVariableMinification);
+ localNamer = determineRenamer(compiler.enableMinification,
+ allowVariableMinification);
- static Namer determineRenamer(bool shouldCompressOutput,
- bool allowVariableMinification) {
+ static LocalNamer determineRenamer(bool shouldCompressOutput,
+ bool allowVariableMinification) {
return (shouldCompressOutput && allowVariableMinification)
? new MinifyRenamer() : new IdentityNamer();
}
@@ -391,7 +391,7 @@ class Printer implements NodeVisitor {
visitNestedExpression(name, PRIMARY,
newInForInit: false, newAtStatementBegin: false);
}
- namer.enterScope(vars);
+ localNamer.enterScope(vars);
out("(");
if (fun.params != null) {
visitCommaSeparated(fun.params, PRIMARY,
@@ -399,7 +399,7 @@ class Printer implements NodeVisitor {
}
out(")");
blockBody(fun.body, needsSeparation: false, needsNewline: false);
- namer.leaveScope();
+ localNamer.leaveScope();
}
visitFunctionDeclaration(FunctionDeclaration declaration) {
@@ -639,7 +639,7 @@ class Printer implements NodeVisitor {
}
visitVariableUse(VariableUse ref) {
- out(namer.getName(ref.name));
+ out(localNamer.getName(ref.name));
}
visitThis(This node) {
@@ -647,11 +647,11 @@ class Printer implements NodeVisitor {
}
visitVariableDeclaration(VariableDeclaration decl) {
- out(namer.getName(decl.name));
+ out(localNamer.getName(decl.name));
}
visitParameter(Parameter param) {
- out(namer.getName(param.name));
+ out(localNamer.getName(param.name));
}
bool isDigit(int charCode) {
@@ -944,7 +944,7 @@ leg.CodeBuffer prettyPrint(Node node, leg.Compiler compiler,
}
-abstract class Namer {
+abstract class LocalNamer {
String getName(String oldName);
String declareVariable(String oldName);
String declareParameter(String oldName);
@@ -953,7 +953,7 @@ abstract class Namer {
}
-class IdentityNamer implements Namer {
+class IdentityNamer implements LocalNamer {
String getName(String oldName) => oldName;
String declareVariable(String oldName) => oldName;
String declareParameter(String oldName) => oldName;
@@ -962,7 +962,7 @@ class IdentityNamer implements Namer {
}
-class MinifyRenamer implements Namer {
+class MinifyRenamer implements LocalNamer {
final List<Map<String, String>> maps = [];
final List<int> parameterNumberStack = [];
final List<int> variableNumberStack = [];

Powered by Google App Engine
This is Rietveld 408576698