Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 * A function element that represents a closure call. The signature is copied | 6 * A function element that represents a closure call. The signature is copied |
| 7 * from the given element. | 7 * from the given element. |
| 8 */ | 8 */ |
| 9 class ClosureInvocationElement extends FunctionElement { | 9 class ClosureInvocationElement extends FunctionElement { |
| 10 ClosureInvocationElement(SourceString name, | 10 ClosureInvocationElement(SourceString name, |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 // syntax. | 689 // syntax. |
| 690 buffer.add(' "super": "$superName"'); | 690 buffer.add(' "super": "$superName"'); |
| 691 if (!checkedSetters.isEmpty()) { | 691 if (!checkedSetters.isEmpty()) { |
| 692 buffer.add(',\n'); | 692 buffer.add(',\n'); |
| 693 buffer.add('${Strings.join(checkedSetters, ",\n")}'); | 693 buffer.add('${Strings.join(checkedSetters, ",\n")}'); |
| 694 } | 694 } |
| 695 emitInstanceMembers(classElement, buffer, true); | 695 emitInstanceMembers(classElement, buffer, true); |
| 696 buffer.add('\n};\n\n'); | 696 buffer.add('\n};\n\n'); |
| 697 } | 697 } |
| 698 | 698 |
| 699 void generateTypeTests(ClassElement cls, | 699 void generateTypeTests(ClassElement cls, |
|
Lasse Reichstein Nielsen
2012/09/19 09:52:10
Is this generating type-test support on cls, or fo
ngeoffray
2012/09/19 10:14:39
Type-test support. I changed the method name.
| |
| 700 void generateTypeTest(ClassElement element)) { | 700 void generateTypeTest(ClassElement element)) { |
| 701 if (checkedClasses.contains(cls)) { | 701 if (checkedClasses.contains(cls)) { |
| 702 generateTypeTest(cls); | 702 generateTypeTest(cls); |
| 703 } | 703 } |
| 704 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>()); | 704 Set<Element> generated = new Set<Element>(); |
| 705 for (DartType interfaceType in cls.interfaces) { | |
| 706 generateInterfacesIsTests( | |
|
Lasse Reichstein Nielsen
2012/09/19 09:52:10
Why is it called "IsTests" in the called function'
ngeoffray
2012/09/19 10:14:39
Renamed everything to IsTest instead of TypeTest.
| |
| 707 interfaceType.element, generateTypeTest, generated); | |
| 708 } | |
| 705 } | 709 } |
| 706 | 710 |
| 707 void generateInterfacesIsTests(ClassElement cls, | 711 void generateInterfacesIsTests(ClassElement cls, |
|
Lasse Reichstein Nielsen
2012/09/19 09:52:10
Please document what the function does.
And the fu
ngeoffray
2012/09/19 10:14:39
Done.
| |
| 708 void generateTypeTest(ClassElement element), | 712 void generateTypeTest(ClassElement element), |
| 709 Set<Element> alreadyGenerated) { | 713 Set<Element> alreadyGenerated) { |
| 714 void tryEmitTest(ClassElement cls) { | |
| 715 if (!alreadyGenerated.contains(cls) && checkedClasses.contains(cls)) { | |
| 716 alreadyGenerated.add(cls); | |
| 717 generateTypeTest(cls); | |
| 718 } | |
| 719 }; | |
| 720 | |
| 710 for (DartType interfaceType in cls.interfaces) { | 721 for (DartType interfaceType in cls.interfaces) { |
| 711 Element element = interfaceType.element; | 722 Element element = interfaceType.element; |
| 712 if (!alreadyGenerated.contains(element) && | 723 tryEmitTest(element); |
| 713 checkedClasses.contains(element)) { | |
| 714 alreadyGenerated.add(element); | |
| 715 generateTypeTest(element); | |
| 716 } | |
| 717 generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated); | 724 generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated); |
| 725 } | |
| 718 | 726 |
| 719 // Since [element] is implemented by [cls], we need to also emit | 727 // We need to also emit |
|
Lasse Reichstein Nielsen
2012/09/19 09:52:10
Fix linebreaking. Put quotes around "is-checks" or
ngeoffray
2012/09/19 10:14:39
Done.
| |
| 720 // is checks for the superclass and its supertypes. | 728 // is checks for the superclass and its supertypes. |
| 721 ClassElement superclass = element.superclass; | 729 ClassElement superclass = cls.superclass; |
| 722 if (!alreadyGenerated.contains(superclass) && | 730 if (superclass != null) { |
| 723 checkedClasses.contains(superclass)) { | 731 tryEmitTest(superclass); |
| 724 alreadyGenerated.add(superclass); | |
| 725 generateTypeTest(superclass); | |
| 726 } | |
| 727 generateInterfacesIsTests(superclass, generateTypeTest, alreadyGenerated); | 732 generateInterfacesIsTests(superclass, generateTypeTest, alreadyGenerated); |
| 728 } | 733 } |
| 729 } | 734 } |
| 730 | 735 |
| 731 void emitClasses(CodeBuffer buffer) { | 736 void emitClasses(CodeBuffer buffer) { |
| 732 // Compute the required type checks to know which classes need a | 737 // Compute the required type checks to know which classes need a |
| 733 // 'is$' method. | 738 // 'is$' method. |
| 734 computeRequiredTypeChecks(); | 739 computeRequiredTypeChecks(); |
| 735 Set<ClassElement> instantiatedClasses = | 740 Set<ClassElement> instantiatedClasses = |
| 736 compiler.codegenWorld.instantiatedClasses; | 741 compiler.codegenWorld.instantiatedClasses; |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1361 const String HOOKS_API_USAGE = """ | 1366 const String HOOKS_API_USAGE = """ |
| 1362 // Generated by dart2js, the Dart to JavaScript compiler. | 1367 // Generated by dart2js, the Dart to JavaScript compiler. |
| 1363 // The code supports the following hooks: | 1368 // The code supports the following hooks: |
| 1364 // dartPrint(message) - if this function is defined it is called | 1369 // dartPrint(message) - if this function is defined it is called |
| 1365 // instead of the Dart [print] method. | 1370 // instead of the Dart [print] method. |
| 1366 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1371 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 1367 // method will not be invoked directly. | 1372 // method will not be invoked directly. |
| 1368 // Instead, a closure that will invoke [main] is | 1373 // Instead, a closure that will invoke [main] is |
| 1369 // passed to [dartMainRunner]. | 1374 // passed to [dartMainRunner]. |
| 1370 """; | 1375 """; |
| OLD | NEW |