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

Unified Diff: lib/src/js/printer.dart

Issue 1099813006: fixes #146, JS globals were not understood by the renamer (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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
« lib/src/codegen/js_names.dart ('K') | « lib/src/codegen/js_names.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/js/printer.dart
diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart
index 0ccb48de2fdbc5d6bf29cf3df19d8644293cc97c..337cc092ddc6703681111ff48d365c11638b1660 100644
--- a/lib/src/js/printer.dart
+++ b/lib/src/js/printer.dart
@@ -1385,3 +1385,40 @@ class MinifyRenamer implements LocalNamer {
return newName;
}
}
+
+/// Like [BaseVisitor], but calls [declare] for [Identifier] declarations, and
+/// [visitIdentifier] otherwise.
+abstract class VariableDeclarationVisitor<T> extends BaseVisitor<T> {
+ declare(Identifier node);
+
+ visitFunctionExpression(FunctionExpression node) {
+ for (Identifier param in node.params) declare(param);
+ node.body.accept(this);
+ }
+
+ visitVariableInitialization(VariableInitialization node) {
+ declare(node.declaration);
+ if (node.value != null) node.value.accept(this);
+ }
+
+ visitCatch(Catch node) {
+ declare(node.declaration);
+ node.body.accept(this);
+ }
+
+ visitFunctionDeclaration(FunctionDeclaration node) {
+ declare(node.name);
+ node.function.accept(this);
+ }
+
+ visitNamedFunction(NamedFunction node) {
+ declare(node.name);
+ node.function.accept(this);
+ }
+
+ visitClassExpression(ClassExpression node) {
+ declare(node.name);
+ if (node.heritage != null) node.heritage.accept(this);
+ for (Method element in node.methods) element.accept(this);
+ }
+}
« lib/src/codegen/js_names.dart ('K') | « lib/src/codegen/js_names.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698