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

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

Issue 10868020: [dart2dart] In renamer only add import prefix for top-level elements. (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 22 matching lines...) Expand all
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
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 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/placeholder_collector.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698