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

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

Issue 10179001: Use shorter names for constructor arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make sure mangling is correct and update tests. 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 | « lib/compiler/implementation/emitter.dart ('k') | tests/language/src/Naming2Test.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) 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 StringBuffer buffer = new StringBuffer(); 56 StringBuffer buffer = new StringBuffer();
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 return privateName(lib, name); 66 String proposedName = privateName(lib, name);
67 if (jsReserved.contains(proposedName)) {
68 return '$proposedName\$';
ngeoffray 2012/04/23 18:38:15 This code very much looks like JsName.getValid, sh
floitsch 2012/04/25 08:42:24 Thanks. Addressed in CL 10223002.
69 }
70 return proposedName;
67 } 71 }
68 72
69 String setterName(LibraryElement lib, SourceString name) { 73 String setterName(LibraryElement lib, SourceString name) {
70 return 'set\$${privateName(lib, name)}'; 74 return 'set\$${privateName(lib, name)}';
71 } 75 }
72 76
73 String getterName(LibraryElement lib, SourceString name) { 77 String getterName(LibraryElement lib, SourceString name) {
74 return 'get\$${privateName(lib, name)}'; 78 return 'get\$${privateName(lib, name)}';
75 } 79 }
76 80
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 209 }
206 210
207 String safeName(String name) { 211 String safeName(String name) {
208 if (jsReserved.contains(name) || name.startsWith('\$')) { 212 if (jsReserved.contains(name) || name.startsWith('\$')) {
209 name = "\$$name"; 213 name = "\$$name";
210 assert(!jsReserved.contains(name)); 214 assert(!jsReserved.contains(name));
211 } 215 }
212 return name; 216 return name;
213 } 217 }
214 } 218 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/emitter.dart ('k') | tests/language/src/Naming2Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698