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

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

Issue 18670003: Remove support for conflicting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * Assigns JavaScript identifiers to Dart variables, class-names and members. 8 * Assigns JavaScript identifiers to Dart variables, class-names and members.
9 */ 9 */
10 class Namer implements ClosureNamer { 10 class Namer implements ClosureNamer {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // TODO(erikcorry): Fix this with other manglings to avoid clashes. 310 // TODO(erikcorry): Fix this with other manglings to avoid clashes.
311 return '_lib$libraryName\$$nameString'; 311 return '_lib$libraryName\$$nameString';
312 } 312 }
313 313
314 String instanceMethodName(FunctionElement element) { 314 String instanceMethodName(FunctionElement element) {
315 SourceString elementName = element.name; 315 SourceString elementName = element.name;
316 SourceString name = operatorNameToIdentifier(elementName); 316 SourceString name = operatorNameToIdentifier(elementName);
317 if (name != elementName) return getMappedOperatorName(name.slowToString()); 317 if (name != elementName) return getMappedOperatorName(name.slowToString());
318 318
319 LibraryElement library = element.getLibrary(); 319 LibraryElement library = element.getLibrary();
320 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { 320 if (element.isGenerativeConstructorBody()) {
321 ConstructorBodyElement bodyElement = element; 321 name = Elements.reconstructConstructorNameSourceString(element);
ahe 2013/07/11 10:09:42 Can we get rid of this?
Johnni Winther 2013/07/11 13:09:19 It requires changes to reflection. Added a TODO.
322 name = bodyElement.constructor.name;
323 } 322 }
324 FunctionSignature signature = element.computeSignature(compiler); 323 FunctionSignature signature = element.computeSignature(compiler);
325 String methodName = 324 String methodName =
326 '${privateName(library, name)}\$${signature.parameterCount}'; 325 '${privateName(library, name)}\$${signature.parameterCount}';
327 if (signature.optionalParametersAreNamed && 326 if (signature.optionalParametersAreNamed &&
328 !signature.optionalParameters.isEmpty) { 327 !signature.optionalParameters.isEmpty) {
329 StringBuffer buffer = new StringBuffer(); 328 StringBuffer buffer = new StringBuffer();
330 signature.orderedOptionalParameters.forEach((Element element) { 329 signature.orderedOptionalParameters.forEach((Element element) {
331 buffer.write('\$${safeName(element.name.slowToString())}'); 330 buffer.write('\$${safeName(element.name.slowToString())}');
332 }); 331 });
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 static const String LIBRARY_PREFIX = "lib"; 508 static const String LIBRARY_PREFIX = "lib";
510 509
511 /** 510 /**
512 * Returns a preferred JS-id for the given top-level or static element. 511 * Returns a preferred JS-id for the given top-level or static element.
513 * The returned id is guaranteed to be a valid JS-id. 512 * The returned id is guaranteed to be a valid JS-id.
514 */ 513 */
515 String _computeGuess(Element element) { 514 String _computeGuess(Element element) {
516 assert(!element.isInstanceMember()); 515 assert(!element.isInstanceMember());
517 String name; 516 String name;
518 if (element.isGenerativeConstructor()) { 517 if (element.isGenerativeConstructor()) {
519 if (element.name == element.getEnclosingClass().name) { 518 name = "${element.getEnclosingClass().name.slowToString()}\$"
520 // Keep the class name for the class and not the factory. 519 "${element.name.slowToString()}";
521 name = "${element.name.slowToString()}\$"; 520 } else if (element.isFactoryConstructor()) {
522 } else { 521 // TODO(johnniwinther): Change factory name encoding as to not include
523 name = element.name.slowToString(); 522 // the class-name twice.
524 } 523 String className = element.getEnclosingClass().name.slowToString();
524 name = '${className}_${Elements.reconstructConstructorName(element)}';
525 } else if (Elements.isStaticOrTopLevel(element)) { 525 } else if (Elements.isStaticOrTopLevel(element)) {
526 if (element.isMember()) { 526 if (element.isMember()) {
527 ClassElement enclosingClass = element.getEnclosingClass(); 527 ClassElement enclosingClass = element.getEnclosingClass();
528 name = "${enclosingClass.name.slowToString()}_" 528 name = "${enclosingClass.name.slowToString()}_"
529 "${element.name.slowToString()}"; 529 "${element.name.slowToString()}";
530 } else { 530 } else {
531 name = element.name.slowToString(); 531 name = element.name.slowToString();
532 } 532 }
533 } else if (element.isLibrary()) { 533 } else if (element.isLibrary()) {
534 name = LIBRARY_PREFIX; 534 name = LIBRARY_PREFIX;
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 if (!first) { 1250 if (!first) {
1251 sb.write('_'); 1251 sb.write('_');
1252 } 1252 }
1253 sb.write('_'); 1253 sb.write('_');
1254 visit(link.head); 1254 visit(link.head);
1255 first = true; 1255 first = true;
1256 } 1256 }
1257 } 1257 }
1258 } 1258 }
1259 } 1259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698