| OLD | NEW | 
|    1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file |    1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 
|    2 // for details. All rights reserved. Use of this source code is governed by a |    2 // for details. All rights reserved. Use of this source code is governed by a | 
|    3 // BSD-style license that can be found in the LICENSE file. |    3 // BSD-style license that can be found in the LICENSE file. | 
|    4  |    4  | 
|    5 /** |    5 /** | 
|    6  * Renames only top-level elements that would let to ambiguity if not renamed. |    6  * Renames only top-level elements that would let to ambiguity if not renamed. | 
|    7  * TODO(smok): Make sure that top-level fields are correctly renamed. |    7  * TODO(smok): Make sure that top-level fields are correctly renamed. | 
|    8  */ |    8  */ | 
|    9 void renamePlaceholders( |    9 void renamePlaceholders( | 
|   10     Compiler compiler, |   10     Compiler compiler, | 
|   11     PlaceholderCollector placeholderCollector, |   11     PlaceholderCollector placeholderCollector, | 
|   12     Map<Node, String> renames, |   12     Map<Node, String> renames, | 
|   13     Map<LibraryElement, String> imports) { |   13     Map<LibraryElement, String> imports) { | 
|   14   final Map<LibraryElement, Map<String, String>> renamed |   14   final Map<LibraryElement, Map<String, String>> renamed | 
|   15       = new Map<LibraryElement, Map<String, String>>(); |   15       = new Map<LibraryElement, Map<String, String>>(); | 
|   16   final Set<String> usedTopLevelIdentifiers = new Set<String>(); |   16   final Set<String> usedTopLevelIdentifiers = new Set<String>(); | 
|   17   int privateNameCounter = 0; |   17   int privateNameCounter = 0; | 
|   18  |   18  | 
|   19   String getName(LibraryElement library, String originalName, renamer) => |   19   String getName(LibraryElement library, String originalName, renamer) => | 
|   20       renamed.putIfAbsent(library, () => <String>{}) |   20       renamed.putIfAbsent(library, () => <String, String>{}) | 
|   21           .putIfAbsent(originalName, renamer); |   21           .putIfAbsent(originalName, renamer); | 
|   22  |   22  | 
|   23   String renamePrivateIdentifier(LibraryElement library, String id) => |   23   String renamePrivateIdentifier(LibraryElement library, String id) => | 
|   24       getName(library, id, () => '_${privateNameCounter++}${id}'); |   24       getName(library, id, () => '_${privateNameCounter++}${id}'); | 
|   25  |   25  | 
|   26   Generator topLevelGenerator = |   26   Generator topLevelGenerator = | 
|   27       true ? conservativeGenerator : new MinifyingGenerator('ABCD').generate; |   27       true ? conservativeGenerator : new MinifyingGenerator('ABCD').generate; | 
|   28   String generateUniqueName(name) { |   28   String generateUniqueName(name) { | 
|   29     String newName = topLevelGenerator( |   29     String newName = topLevelGenerator( | 
|   30         name, usedTopLevelIdentifiers.contains); |   30         name, usedTopLevelIdentifiers.contains); | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  121     int length = alphabet.length; |  121     int length = alphabet.length; | 
|  122     StringBuffer resultBuilder = new StringBuffer(); |  122     StringBuffer resultBuilder = new StringBuffer(); | 
|  123     while (index >= length) { |  123     while (index >= length) { | 
|  124       resultBuilder.add(alphabet[index % length]); |  124       resultBuilder.add(alphabet[index % length]); | 
|  125       index ~/= length; |  125       index ~/= length; | 
|  126     } |  126     } | 
|  127     resultBuilder.add(alphabet[index]); |  127     resultBuilder.add(alphabet[index]); | 
|  128     return resultBuilder.toString(); |  128     return resultBuilder.toString(); | 
|  129   } |  129   } | 
|  130 } |  130 } | 
| OLD | NEW |