| 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, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 name, usedTopLevelIdentifiers.contains); | 22 name, usedTopLevelIdentifiers.contains); |
| 23 usedTopLevelIdentifiers.add(newName); | 23 usedTopLevelIdentifiers.add(newName); |
| 24 return newName; | 24 return newName; |
| 25 } | 25 } |
| 26 | 26 |
| 27 rename(library, originalName) => | 27 rename(library, originalName) => |
| 28 renamed.putIfAbsent(library, () => <String>{}) | 28 renamed.putIfAbsent(library, () => <String>{}) |
| 29 .putIfAbsent(originalName, () => generateUniqueName(originalName)); | 29 .putIfAbsent(originalName, () => generateUniqueName(originalName)); |
| 30 | 30 |
| 31 String renameElement(Element element) { | 31 String renameElement(Element element) { |
| 32 assert(element.isTopLevel()); | 32 assert(element.isTopLevel() || element is TypeVariableElement); |
| 33 // TODO(smok): Make sure that the new name does not conflict with existing | 33 // TODO(smok): Make sure that the new name does not conflict with existing |
| 34 // local identifiers. | 34 // local identifiers. |
| 35 String originalName = element.name.slowToString(); | 35 String originalName = element.name.slowToString(); |
| 36 LibraryElement library = element.getLibrary(); | 36 LibraryElement library = element.getLibrary(); |
| 37 if (isDartCoreLib(compiler, library)) { | 37 if (isDartCoreLib(compiler, library)) { |
| 38 final prefix = | 38 final prefix = |
| 39 imports.putIfAbsent(library, () => generateUniqueName('p')); | 39 imports.putIfAbsent(library, () => generateUniqueName('p')); |
| 40 return '$prefix.$originalName'; | 40 return '$prefix.$originalName'; |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int length = alphabet.length; | 115 int length = alphabet.length; |
| 116 StringBuffer resultBuilder = new StringBuffer(); | 116 StringBuffer resultBuilder = new StringBuffer(); |
| 117 while (index >= length) { | 117 while (index >= length) { |
| 118 resultBuilder.add(alphabet[index % length]); | 118 resultBuilder.add(alphabet[index % length]); |
| 119 index ~/= length; | 119 index ~/= length; |
| 120 } | 120 } |
| 121 resultBuilder.add(alphabet[index]); | 121 resultBuilder.add(alphabet[index]); |
| 122 return resultBuilder.toString(); | 122 return resultBuilder.toString(); |
| 123 } | 123 } |
| 124 } | 124 } |
| OLD | NEW |