Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart |
| index 6dc9ad873e019493f9c62a3cfd808c0c340f0ee0..3a2ca15783242da935b87b55836de3b973a0ad9e 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart |
| @@ -67,7 +67,8 @@ void renamePlaceholders( |
| Map<Node, String> renames, |
| Map<LibraryElement, String> imports, |
| Set<String> fixedMemberNames, |
| - bool cutDeclarationTypes) { |
| + bool cutDeclarationTypes, |
| + {uniqueGlobalNaming: false}) { |
| final Map<LibraryElement, Map<String, String>> renamed |
| = new Map<LibraryElement, Map<String, String>>(); |
| @@ -178,24 +179,33 @@ void renamePlaceholders( |
| rename = makeRenamer(generateUniqueName); |
| renameElement = makeElementRenamer(rename, generateUniqueName); |
| - // Build a sorted (by usage) list of local nodes that will be renamed to |
| - // the same identifier. So the top-used local variables in all functions |
| - // will be renamed first and will all share the same new identifier. |
| - List<Set<Node>> allSortedLocals = new List<Set<Node>>(); |
| - for (var functionScope in placeholderCollector.functionScopes.values) { |
| - // Add current sorted local identifiers to the whole sorted list |
| - // of all local identifiers for all functions. |
| - List<LocalPlaceholder> currentSortedPlaceholders = |
| - sorted(functionScope.localPlaceholders, |
| - compareBy((LocalPlaceholder ph) => -ph.nodes.length)); |
| - List<Set<Node>> currentSortedNodes = |
| - currentSortedPlaceholders.map((ph) => ph.nodes).toList(); |
| - // Make room in all sorted locals list for new stuff. |
| - while (currentSortedNodes.length > allSortedLocals.length) { |
| - allSortedLocals.add(new Set<Node>()); |
| + List<Set<Node>> allLocals = new List<Set<Node>>(); |
| + // If we are using the mirror_helper library we need all names to be |
| + // globally unique. |
| + if(uniqueGlobalNaming) { |
|
ahe
2013/08/16 18:39:26
Missing space after if.
zarah
2013/08/28 10:19:29
Done.
|
| + for (var functionScope in placeholderCollector.functionScopes.values) { |
| + functionScope.localPlaceholders.forEach( |
| + (ph) => allLocals.add(new Set<Node>()..addAll(ph.nodes))); |
|
ahe
2013/08/16 18:39:26
ph.nodes.toSet()?
zarah
2013/08/28 10:19:29
Done.
|
| } |
| - for (int i = 0; i < currentSortedNodes.length; i++) { |
| - allSortedLocals[i].addAll(currentSortedNodes[i]); |
| + } else { |
| + // Build a sorted (by usage) list of local nodes that will be renamed to |
| + // the same identifier. So the top-used local variables in all functions |
| + // will be renamed first and will all share the same new identifier. |
| + for (var functionScope in placeholderCollector.functionScopes.values) { |
| + // Add current sorted local identifiers to the whole sorted list |
| + // of all local identifiers for all functions. |
| + List<LocalPlaceholder> currentSortedPlaceholders = |
| + sorted(functionScope.localPlaceholders, |
| + compareBy((LocalPlaceholder ph) => -ph.nodes.length)); |
| + List<Set<Node>> currentSortedNodes = |
| + currentSortedPlaceholders.map((ph) => ph.nodes).toList(); |
| + // Make room in all sorted locals list for new stuff. |
| + while (currentSortedNodes.length > allLocals.length) { |
| + allLocals.add(new Set<Node>()); |
| + } |
| + for (int i = 0; i < currentSortedNodes.length; i++) { |
| + allLocals[i].addAll(currentSortedNodes[i]); |
| + } |
| } |
| } |
| @@ -217,7 +227,7 @@ void renamePlaceholders( |
| renamables.add( |
| new MemberRenamable(memberName, identifiers, memberRenamer)); |
| }); |
| - for (Set<Node> localIdentifiers in allSortedLocals) { |
| + for (Set<Node> localIdentifiers in allLocals) { |
| renamables.add(new LocalRenamable(localIdentifiers, localRenamer)); |
| } |
| renamables.sort((Renamable renamable1, Renamable renamable2) => |