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

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

Issue 10970038: Convert raw strings in compiler (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 Function get _compareNodes => 5 Function get _compareNodes =>
6 compareBy((n) => n.getBeginToken().charOffset); 6 compareBy((n) => n.getBeginToken().charOffset);
7 7
8 typedef String _Renamer(Renamable renamable); 8 typedef String _Renamer(Renamable renamable);
9 abstract class Renamable { 9 abstract class Renamable {
10 const int RENAMABLE_TYPE_ELEMENT = 1; 10 const int RENAMABLE_TYPE_ELEMENT = 1;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 String newName = originalName; 251 String newName = originalName;
252 while (isForbidden(newName)) { 252 while (isForbidden(newName)) {
253 newName = 'p_$newName'; 253 newName = 'p_$newName';
254 } 254 }
255 return newName; 255 return newName;
256 } 256 }
257 257
258 /** Always tries to generate the most compact identifier. */ 258 /** Always tries to generate the most compact identifier. */
259 class MinifyingGenerator { 259 class MinifyingGenerator {
260 static const String firstCharAlphabet = 260 static const String firstCharAlphabet =
261 @'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 261 r'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
262 static const String otherCharsAlphabet = 262 static const String otherCharsAlphabet =
263 @'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$'; 263 r'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$';
264 int nextIdIndex; 264 int nextIdIndex;
265 265
266 MinifyingGenerator() : nextIdIndex = 0; 266 MinifyingGenerator() : nextIdIndex = 0;
267 267
268 String generate(bool isForbidden(String name)) { 268 String generate(bool isForbidden(String name)) {
269 String newName; 269 String newName;
270 do { 270 do {
271 newName = getNextId(); 271 newName = getNextId();
272 } while(isForbidden(newName)); 272 } while(isForbidden(newName));
273 return newName; 273 return newName;
(...skipping 14 matching lines...) Expand all
288 index ~/= firstCharAlphabet.length; 288 index ~/= firstCharAlphabet.length;
289 int length = otherCharsAlphabet.length; 289 int length = otherCharsAlphabet.length;
290 while (index >= length) { 290 while (index >= length) {
291 resultBuilder.add(otherCharsAlphabet[index % length]); 291 resultBuilder.add(otherCharsAlphabet[index % length]);
292 index ~/= length; 292 index ~/= length;
293 } 293 }
294 resultBuilder.add(otherCharsAlphabet[index]); 294 resultBuilder.add(otherCharsAlphabet[index]);
295 return resultBuilder.toString(); 295 return resultBuilder.toString();
296 } 296 }
297 } 297 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698