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

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

Issue 10878004: Properly rename main methods declared in imported libs. (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
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
11 PlaceholderCollector placeholderCollector, 11 PlaceholderCollector placeholderCollector,
12 Map<Node, String> renames, 12 Map<Node, String> renames,
13 Map<LibraryElement, String> imports) { 13 Map<LibraryElement, String> imports) {
14 final Map<LibraryElement, Map<String, String>> renamed 14 final Map<LibraryElement, Map<String, String>> renamed
15 = new Map<LibraryElement, Map<String, String>>(); 15 = new Map<LibraryElement, Map<String, String>>();
16 final Set<String> usedTopLevelIdentifiers = new Set<String>(); 16 final Set<String> usedTopLevelIdentifiers = new Set<String>();
17 // TODO(antonm): we should also populate this set with top-level
18 // names from core library.
19 usedTopLevelIdentifiers.add('main'); // Never rename anything to 'main'.
17 20
18 Generator topLevelGenerator = 21 Generator topLevelGenerator =
19 true ? conservativeGenerator : new MinifyingGenerator('ABCD').generate; 22 true ? conservativeGenerator : new MinifyingGenerator('ABCD').generate;
20 String generateUniqueName(name) { 23 String generateUniqueName(name) {
21 String newName = topLevelGenerator( 24 String newName = topLevelGenerator(
22 name, usedTopLevelIdentifiers.contains); 25 name, usedTopLevelIdentifiers.contains);
23 usedTopLevelIdentifiers.add(newName); 26 usedTopLevelIdentifiers.add(newName);
24 return newName; 27 return newName;
25 } 28 }
26 29
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int length = alphabet.length; 118 int length = alphabet.length;
116 StringBuffer resultBuilder = new StringBuffer(); 119 StringBuffer resultBuilder = new StringBuffer();
117 while (index >= length) { 120 while (index >= length) {
118 resultBuilder.add(alphabet[index % length]); 121 resultBuilder.add(alphabet[index % length]);
119 index ~/= length; 122 index ~/= length;
120 } 123 }
121 resultBuilder.add(alphabet[index]); 124 resultBuilder.add(alphabet[index]);
122 return resultBuilder.toString(); 125 return resultBuilder.toString();
123 } 126 }
124 } 127 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698