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

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

Issue 10870008: dart2dart Rename statics as globals. (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 14 matching lines...) Expand all
25 name, usedTopLevelIdentifiers.contains); 25 name, usedTopLevelIdentifiers.contains);
26 usedTopLevelIdentifiers.add(newName); 26 usedTopLevelIdentifiers.add(newName);
27 return newName; 27 return newName;
28 } 28 }
29 29
30 rename(library, originalName) => 30 rename(library, originalName) =>
31 renamed.putIfAbsent(library, () => <String>{}) 31 renamed.putIfAbsent(library, () => <String>{})
32 .putIfAbsent(originalName, () => generateUniqueName(originalName)); 32 .putIfAbsent(originalName, () => generateUniqueName(originalName));
33 33
34 String renameElement(Element element) { 34 String renameElement(Element element) {
35 assert(element.isTopLevel() || element is TypeVariableElement); 35 assert(Elements.isStaticOrTopLevel(element)
36 || element is TypeVariableElement);
36 // 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
37 // local identifiers. 38 // local identifiers.
39 // TODO(smok): We may want to reuse class static field and method names.
38 String originalName = element.name.slowToString(); 40 String originalName = element.name.slowToString();
39 LibraryElement library = element.getLibrary(); 41 LibraryElement library = element.getLibrary();
40 if (isDartCoreLib(compiler, library)) { 42 if (isDartCoreLib(compiler, library)) {
41 final prefix = 43 final prefix =
42 imports.putIfAbsent(library, () => generateUniqueName('p')); 44 imports.putIfAbsent(library, () => generateUniqueName('p'));
43 return '$prefix.$originalName'; 45 return '$prefix.$originalName';
44 } 46 }
45 47
46 return rename(library, originalName); 48 return rename(library, originalName);
47 } 49 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 int length = alphabet.length; 120 int length = alphabet.length;
119 StringBuffer resultBuilder = new StringBuffer(); 121 StringBuffer resultBuilder = new StringBuffer();
120 while (index >= length) { 122 while (index >= length) {
121 resultBuilder.add(alphabet[index % length]); 123 resultBuilder.add(alphabet[index % length]);
122 index ~/= length; 124 index ~/= length;
123 } 125 }
124 resultBuilder.add(alphabet[index]); 126 resultBuilder.add(alphabet[index]);
125 return resultBuilder.toString(); 127 return resultBuilder.toString();
126 } 128 }
127 } 129 }
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