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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 /** | 7 /** |
8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
9 * from the given element. | 9 * from the given element. |
10 */ | 10 */ |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 * Generate "is tests" for [cls]: itself, and the "is tests" for the | 913 * Generate "is tests" for [cls]: itself, and the "is tests" for the |
914 * classes it implements. We don't need to add the "is tests" of the | 914 * classes it implements. We don't need to add the "is tests" of the |
915 * super class because they will be inherited at runtime. | 915 * super class because they will be inherited at runtime. |
916 */ | 916 */ |
917 void generateIsTestsOn(ClassElement cls, | 917 void generateIsTestsOn(ClassElement cls, |
918 void emitIsTest(ClassElement element)) { | 918 void emitIsTest(ClassElement element)) { |
919 if (checkedClasses.contains(cls)) { | 919 if (checkedClasses.contains(cls)) { |
920 emitIsTest(cls); | 920 emitIsTest(cls); |
921 } | 921 } |
922 Set<Element> generated = new Set<Element>(); | 922 Set<Element> generated = new Set<Element>(); |
| 923 // A class that defines a [:call:] method implicitly implements |
| 924 // [Function]. |
| 925 if (checkedClasses.contains(compiler.functionClass) |
| 926 && cls.lookupLocalMember(Compiler.CALL_OPERATOR_NAME) != null) { |
| 927 generateInterfacesIsTests(compiler.functionClass, emitIsTest, generated); |
| 928 } |
923 for (DartType interfaceType in cls.interfaces) { | 929 for (DartType interfaceType in cls.interfaces) { |
924 generateInterfacesIsTests(interfaceType.element, emitIsTest, generated); | 930 generateInterfacesIsTests(interfaceType.element, emitIsTest, generated); |
925 } | 931 } |
926 } | 932 } |
927 | 933 |
928 /** | 934 /** |
929 * Generate "is tests" where [cls] is being implemented. | 935 * Generate "is tests" where [cls] is being implemented. |
930 */ | 936 */ |
931 void generateInterfacesIsTests(ClassElement cls, | 937 void generateInterfacesIsTests(ClassElement cls, |
932 void emitIsTest(ClassElement element), | 938 void emitIsTest(ClassElement element), |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 const String HOOKS_API_USAGE = """ | 1667 const String HOOKS_API_USAGE = """ |
1662 // Generated by dart2js, the Dart to JavaScript compiler. | 1668 // Generated by dart2js, the Dart to JavaScript compiler. |
1663 // The code supports the following hooks: | 1669 // The code supports the following hooks: |
1664 // dartPrint(message) - if this function is defined it is called | 1670 // dartPrint(message) - if this function is defined it is called |
1665 // instead of the Dart [print] method. | 1671 // instead of the Dart [print] method. |
1666 // dartMainRunner(main) - if this function is defined, the Dart [main] | 1672 // dartMainRunner(main) - if this function is defined, the Dart [main] |
1667 // method will not be invoked directly. | 1673 // method will not be invoked directly. |
1668 // Instead, a closure that will invoke [main] is | 1674 // Instead, a closure that will invoke [main] is |
1669 // passed to [dartMainRunner]. | 1675 // passed to [dartMainRunner]. |
1670 """; | 1676 """; |
OLD | NEW |