| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 String renameElement(Element element) { | 34 String renameElement(Element element) { |
| 35 assert(Elements.isStaticOrTopLevel(element) | 35 assert(Elements.isStaticOrTopLevel(element) |
| 36 || element is TypeVariableElement); | 36 || element is TypeVariableElement); |
| 37 // TODO(smok): Make sure that the new name does not conflict with existing | 37 // TODO(smok): Make sure that the new name does not conflict with existing |
| 38 // local identifiers. | 38 // local identifiers. |
| 39 // TODO(smok): We may want to reuse class static field and method names. | 39 // TODO(smok): We may want to reuse class static field and method names. |
| 40 String originalName = element.name.slowToString(); | 40 String originalName = element.name.slowToString(); |
| 41 LibraryElement library = element.getLibrary(); | 41 LibraryElement library = element.getLibrary(); |
| 42 if (isDartCoreLib(compiler, library)) { | 42 if (isDartCoreLib(compiler, library)) { |
| 43 assert(element.isTopLevel()); |
| 43 final prefix = | 44 final prefix = |
| 44 imports.putIfAbsent(library, () => generateUniqueName('p')); | 45 imports.putIfAbsent(library, () => generateUniqueName('p')); |
| 45 return '$prefix.$originalName'; | 46 return '$prefix.$originalName'; |
| 46 } | 47 } |
| 47 | 48 |
| 48 return rename(library, originalName); | 49 return rename(library, originalName); |
| 49 } | 50 } |
| 50 | 51 |
| 51 renameNodes(Collection<Node> nodes, renamer) { | 52 renameNodes(Collection<Node> nodes, renamer) { |
| 52 final comparison = compareBy((node) => node.getBeginToken().charOffset); | 53 final comparison = compareBy((node) => node.getBeginToken().charOffset); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 int length = alphabet.length; | 121 int length = alphabet.length; |
| 121 StringBuffer resultBuilder = new StringBuffer(); | 122 StringBuffer resultBuilder = new StringBuffer(); |
| 122 while (index >= length) { | 123 while (index >= length) { |
| 123 resultBuilder.add(alphabet[index % length]); | 124 resultBuilder.add(alphabet[index % length]); |
| 124 index ~/= length; | 125 index ~/= length; |
| 125 } | 126 } |
| 126 resultBuilder.add(alphabet[index]); | 127 resultBuilder.add(alphabet[index]); |
| 127 return resultBuilder.toString(); | 128 return resultBuilder.toString(); |
| 128 } | 129 } |
| 129 } | 130 } |
| OLD | NEW |