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

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

Issue 10827424: Do not create placeholders for elements that won't be later renamed. (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 20 matching lines...) Expand all
31 usedTopLevelIdentifiers.add(newName); 31 usedTopLevelIdentifiers.add(newName);
32 return newName; 32 return newName;
33 } 33 }
34 34
35 String renameElement(Element element) { 35 String renameElement(Element element) {
36 assert(element.isTopLevel()); 36 assert(element.isTopLevel());
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 String originalName = element.name.slowToString(); 39 String originalName = element.name.slowToString();
40 LibraryElement library = element.getLibrary(); 40 LibraryElement library = element.getLibrary();
41 if (library === compiler.coreLibrary
42 || element == compiler.mainApp.find(Compiler.MAIN)) return originalName;
43 if (isDartCoreLib(compiler, library)) { 41 if (isDartCoreLib(compiler, library)) {
44 final prefix = 42 final prefix =
45 imports.putIfAbsent(library, () => generateUniqueName('p')); 43 imports.putIfAbsent(library, () => generateUniqueName('p'));
46 return '$prefix.$originalName'; 44 return '$prefix.$originalName';
47 } 45 }
48 46
49 return getName(library, originalName, 47 return getName(library, originalName,
50 () => generateUniqueName(originalName)); 48 () => generateUniqueName(originalName));
51 } 49 }
52 50
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 int length = alphabet.length; 119 int length = alphabet.length;
122 StringBuffer resultBuilder = new StringBuffer(); 120 StringBuffer resultBuilder = new StringBuffer();
123 while (index >= length) { 121 while (index >= length) {
124 resultBuilder.add(alphabet[index % length]); 122 resultBuilder.add(alphabet[index % length]);
125 index ~/= length; 123 index ~/= length;
126 } 124 }
127 resultBuilder.add(alphabet[index]); 125 resultBuilder.add(alphabet[index]);
128 return resultBuilder.toString(); 126 return resultBuilder.toString();
129 } 127 }
130 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698