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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/container_builder.dart

Issue 418223010: Revert "Library functions can never be constructors." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | sdk/lib/_internal/compiler/implementation/js_emitter/js_emitter.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /// This class should morph into something that makes it easy to build 7 /// This class should morph into something that makes it easy to build
8 /// JavaScript representations of libraries, class-sides, and instance-sides. 8 /// JavaScript representations of libraries, class-sides, and instance-sides.
9 /// Initially, it is just a placeholder for code that is moved from 9 /// Initially, it is just a placeholder for code that is moved from
10 /// [CodeEmitterTask]. 10 /// [CodeEmitterTask].
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 backend.constants.addCompileTimeConstantForEmission(constant); 522 backend.constants.addCompileTimeConstantForEmission(constant);
523 return task.metadataEmitter.reifyMetadata(annotation); 523 return task.metadataEmitter.reifyMetadata(annotation);
524 }); 524 });
525 expressions.add( 525 expressions.add(
526 new jsAst.ArrayInitializer.from(metadataIndices.map(js.number))); 526 new jsAst.ArrayInitializer.from(metadataIndices.map(js.number)));
527 } 527 }
528 }); 528 });
529 } 529 }
530 if (canBeReflected) { 530 if (canBeReflected) {
531 jsAst.LiteralString reflectionName; 531 jsAst.LiteralString reflectionName;
532 jsAst.LiteralString redirectionTarget = null;
533 if (member.isConstructor) { 532 if (member.isConstructor) {
534 ConstructorElement constructor = member;
535 // TODO(floitsch): is the call to getReflectionName necessary for its
536 // side effect? The variable `reflectionNameString` itself is unused.
537 String reflectionNameString = task.getReflectionName(member, name); 533 String reflectionNameString = task.getReflectionName(member, name);
538 if (constructor.isRedirectingFactory) { 534 reflectionName =
539 reflectionName = 535 new jsAst.LiteralString(
540 new jsAst.LiteralString( 536 '"new ${Elements.reconstructConstructorName(member)}"');
541 '"new-> ${Elements.reconstructConstructorName(member)}"');
542 ConstructorElement effectiveTarget = constructor.effectiveTarget;
543 Element targetClass = effectiveTarget.enclosingClass;
544 String constructorName = effectiveTarget.name;
545 redirectionTarget = js.string("${namer.getNameOfClass(targetClass)}\$"
546 "$constructorName");
547 } else {
548 reflectionName =
549 new jsAst.LiteralString(
550 '"new ${Elements.reconstructConstructorName(member)}"');
551 }
552 } else { 537 } else {
553 reflectionName = js.string(member.name); 538 reflectionName = js.string(member.name);
554 } 539 }
555 expressions.add(reflectionName); 540 expressions
556 if (redirectionTarget != null) expressions.add(redirectionTarget); 541 ..add(reflectionName)
557 expressions.addAll( 542 ..addAll(task.metadataEmitter.computeMetadata(member).map(js.number));
558 task.metadataEmitter.computeMetadata(member).map(js.number));
559 } else if (isClosure && canBeApplied) { 543 } else if (isClosure && canBeApplied) {
560 expressions.add(js.string(member.name)); 544 expressions.add(js.string(member.name));
561 } 545 }
562 jsAst.ArrayInitializer arrayInit = 546 jsAst.ArrayInitializer arrayInit =
563 new jsAst.ArrayInitializer.from(expressions); 547 new jsAst.ArrayInitializer.from(expressions);
564 builder.addProperty(name, arrayInit); 548 builder.addProperty(name, arrayInit);
565 compiler.dumpInfoTask.registerElementAst(member, arrayInit); 549 compiler.dumpInfoTask.registerElementAst(member, arrayInit);
566 } 550 }
567 551
568 void addMemberField(VariableElement member, ClassBuilder builder) { 552 void addMemberField(VariableElement member, ClassBuilder builder) {
569 // For now, do nothing. 553 // For now, do nothing.
570 } 554 }
571 } 555 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js_emitter/js_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698