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

Side by Side Diff: lib/compiler/implementation/dart_backend/renamer.dart

Issue 10861029: Properly rename type variables. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698