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

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

Issue 11191078: Make hashCode a getter and not a method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. 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) 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // We sometimes handle continue targets differently from break targets, 75 // We sometimes handle continue targets differently from break targets,
76 // so we have special continue-only labels. 76 // so we have special continue-only labels.
77 String continueLabelName(LabelElement label) { 77 String continueLabelName(LabelElement label) {
78 return 'c\$${label.labelName}\$${label.target.nestingLevel}'; 78 return 'c\$${label.labelName}\$${label.target.nestingLevel}';
79 } 79 }
80 80
81 String implicitContinueLabelName(TargetElement target) { 81 String implicitContinueLabelName(TargetElement target) {
82 return 'c\$${target.nestingLevel}'; 82 return 'c\$${target.nestingLevel}';
83 } 83 }
84 84
85 /**
86 * If the [name] is not private returns [:name.slowToString():]. Otherwise
87 * mangles the [name] so that each library has a unique name.
88 */
85 String privateName(LibraryElement lib, SourceString name) { 89 String privateName(LibraryElement lib, SourceString name) {
86 if (name.isPrivate()) { 90 if (name.isPrivate()) {
87 String nameString = name.slowToString(); 91 String nameString = name.slowToString();
88 // The first library asking for a short private name wins. 92 // The first library asking for a short private name wins.
89 LibraryElement owner = 93 LibraryElement owner =
90 shortPrivateNameOwners.putIfAbsent(nameString, () => lib); 94 shortPrivateNameOwners.putIfAbsent(nameString, () => lib);
91 // If a private name could clash with a mangled private name we don't 95 // If a private name could clash with a mangled private name we don't
92 // use the short name. For example a private name "_lib3_foo" would 96 // use the short name. For example a private name "_lib3_foo" would
93 // clash with "_foo" from "lib3". 97 // clash with "_foo" from "lib3".
94 if (identical(owner, lib) && !nameString.startsWith('_$LIBRARY_PREFIX')) { 98 if (identical(owner, lib) && !nameString.startsWith('_$LIBRARY_PREFIX')) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return safeName('$libName\$$clsName\$$instanceName'); 160 return safeName('$libName\$$clsName\$$instanceName');
157 } 161 }
158 162
159 String setterName(LibraryElement lib, SourceString name) { 163 String setterName(LibraryElement lib, SourceString name) {
160 // We dynamically create setters from the field-name. The setter name must 164 // We dynamically create setters from the field-name. The setter name must
161 // therefore be derived from the instance field-name. 165 // therefore be derived from the instance field-name.
162 String fieldName = safeName(privateName(lib, name)); 166 String fieldName = safeName(privateName(lib, name));
163 return 'set\$$fieldName'; 167 return 'set\$$fieldName';
164 } 168 }
165 169
170 String publicGetterName(SourceString name) {
171 // We dynamically create getters from the field-name. The getter name must
172 // therefore be derived from the instance field-name.
173 String fieldName = safeName(name.slowToString());
174 return 'get\$$fieldName';
175 }
176
166 String getterName(LibraryElement lib, SourceString name) { 177 String getterName(LibraryElement lib, SourceString name) {
167 // We dynamically create getters from the field-name. The getter name must 178 // We dynamically create getters from the field-name. The getter name must
168 // therefore be derived from the instance field-name. 179 // therefore be derived from the instance field-name.
169 String fieldName = safeName(privateName(lib, name)); 180 String fieldName = safeName(privateName(lib, name));
170 return 'get\$$fieldName'; 181 return 'get\$$fieldName';
171 } 182 }
172 183
173 String getFreshGlobalName(String proposedName) { 184 String getFreshGlobalName(String proposedName) {
174 String name = proposedName; 185 String name = proposedName;
175 int count = usedGlobals[name]; 186 int count = usedGlobals[name];
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 322 }
312 323
313 String safeName(String name) { 324 String safeName(String name) {
314 if (jsReserved.contains(name) || name.startsWith('\$')) { 325 if (jsReserved.contains(name) || name.startsWith('\$')) {
315 name = "\$$name"; 326 name = "\$$name";
316 assert(!jsReserved.contains(name)); 327 assert(!jsReserved.contains(name));
317 } 328 }
318 return name; 329 return name;
319 } 330 }
320 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698