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

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 8c1f5f3627ed1d946f63a63b36e4c5939774a76a..7f4e956f36bfed285d588b73e3ed0c4953379d69 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,
Roman 2012/08/29 08:40:09 I think in this context it's more like 'forbiddenM
Anton Muhin 2012/08/29 09:43:46 I've started with forbidden as well, but actually
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 =
Roman 2012/08/29 08:40:09 This can be inlined into makeGenerator
Anton Muhin 2012/08/29 09:43:46 But why? I'd rather use the same generator.
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));

Powered by Google App Engine
This is Rietveld 408576698