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

Unified Diff: lib/compiler/implementation/dart_backend/renamer.dart

Issue 10887012: Rename members and named constructors. (Closed) Base URL: https://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
Index: lib/compiler/implementation/dart_backend/renamer.dart
diff --git a/lib/compiler/implementation/dart_backend/renamer.dart b/lib/compiler/implementation/dart_backend/renamer.dart
index 64d5cd07e57630b5422993017514d2e3320e9f9b..f944ca524f7da6510bf6517dcb9e9448ccd56c82 100644
--- a/lib/compiler/implementation/dart_backend/renamer.dart
+++ b/lib/compiler/implementation/dart_backend/renamer.dart
@@ -11,24 +11,25 @@ void renamePlaceholders(
PlaceholderCollector placeholderCollector,
Map<Node, String> renames,
Map<LibraryElement, String> imports,
+ Set<String> fixedMemberNames,
bool minify,
bool cutDeclarationTypes) {
final Map<LibraryElement, Map<String, String>> renamed
= new Map<LibraryElement, Map<String, String>>();
- final Set<String> usedTopLevelIdentifiers = new Set<String>();
- // TODO(antonm): we should also populate this set with top-level
- // names from core library.
- usedTopLevelIdentifiers.add('main'); // Never rename anything to 'main'.
-
Generator topLevelGenerator =
minify ? new MinifyingGenerator('ABCDEFGHIJKLMNOPQRSTUVWXYZ').generate
: conservativeGenerator;
- String generateUniqueName(name) {
- String newName = topLevelGenerator(
- name, usedTopLevelIdentifiers.contains);
- usedTopLevelIdentifiers.add(newName);
+ makeGenerator(usedIdentifierSet) => (name) {
+ String newName = topLevelGenerator(name, usedIdentifierSet.contains);
+ usedIdentifierSet.add(newName);
return newName;
- }
+ };
+
+ final usedTopLevelIdentifiers = new Set<String>();
+ // TODO(antonm): we should also populate this set with top-level
+ // names from core library.
+ usedTopLevelIdentifiers.add('main'); // Never rename anything to 'main'.
+ final generateUniqueName = makeGenerator(usedTopLevelIdentifiers);
rename(library, originalName) =>
renamed.putIfAbsent(library, () => <String>{})
@@ -107,6 +108,16 @@ void renamePlaceholders(
renames[placeholder.typeNode] = placeholder.requiresVar ? 'var' : '';
}
}
+
+ final usedMemberIdentifiers = new Set<String>.from(fixedMemberNames);
+ // Do not rename members to top-levels, that allows to avoid renaming
+ // members to constructors.
+ usedMemberIdentifiers.addAll(usedTopLevelIdentifiers);
+ final generateMemberIdentifier = makeGenerator(usedMemberIdentifiers);
+ placeholderCollector.memberPlaceholders.forEach((identifier, nodes) {
+ final newIdentifier = generateMemberIdentifier(identifier);
+ renameNodes(nodes, (_) => newIdentifier);
+ });
}
typedef String Generator(String originalName, bool isForbidden(String name));
« no previous file with comments | « lib/compiler/implementation/dart_backend/placeholder_collector.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698