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

Side by Side Diff: lib/compiler/implementation/namer.dart

Issue 10223002: Use JsNames.getValid instead of implementing another (broken) version of it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * Assigns JavaScript identifiers to Dart variables, class-names and members. 6 * Assigns JavaScript identifiers to Dart variables, class-names and members.
7 */ 7 */
8 class Namer { 8 class Namer {
9 final Compiler compiler; 9 final Compiler compiler;
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 List<SourceString> names = selector.getOrderedNamedArguments(); 57 List<SourceString> names = selector.getOrderedNamedArguments();
58 for (SourceString argumentName in names) { 58 for (SourceString argumentName in names) {
59 buffer.add(@'$'); 59 buffer.add(@'$');
60 argumentName.printOn(buffer); 60 argumentName.printOn(buffer);
61 } 61 }
62 return '${privateName(lib, name)}\$${selector.argumentCount}$buffer'; 62 return '${privateName(lib, name)}\$${selector.argumentCount}$buffer';
63 } 63 }
64 64
65 String instanceFieldName(LibraryElement lib, SourceString name) { 65 String instanceFieldName(LibraryElement lib, SourceString name) {
66 String proposedName = privateName(lib, name); 66 String proposedName = privateName(lib, name);
67 if (jsReserved.contains(proposedName)) { 67 return JsNames.getValid(proposedName);
68 return '$proposedName\$';
69 }
70 return proposedName;
71 } 68 }
72 69
73 String setterName(LibraryElement lib, SourceString name) { 70 String setterName(LibraryElement lib, SourceString name) {
74 return 'set\$${privateName(lib, name)}'; 71 return 'set\$${privateName(lib, name)}';
75 } 72 }
76 73
77 String getterName(LibraryElement lib, SourceString name) { 74 String getterName(LibraryElement lib, SourceString name) {
78 return 'get\$${privateName(lib, name)}'; 75 return 'get\$${privateName(lib, name)}';
79 } 76 }
80 77
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 206 }
210 207
211 String safeName(String name) { 208 String safeName(String name) {
212 if (jsReserved.contains(name) || name.startsWith('\$')) { 209 if (jsReserved.contains(name) || name.startsWith('\$')) {
213 name = "\$$name"; 210 name = "\$$name";
214 assert(!jsReserved.contains(name)); 211 assert(!jsReserved.contains(name));
215 } 212 }
216 return name; 213 return name;
217 } 214 }
218 } 215 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698