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 typedef void Recompile(Element element); | 7 typedef void Recompile(Element element); |
8 | 8 |
9 class ReturnInfo { | 9 class ReturnInfo { |
10 HType returnType; | 10 HType returnType; |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 | 648 |
649 ClassElement jsStringClass; | 649 ClassElement jsStringClass; |
650 ClassElement jsArrayClass; | 650 ClassElement jsArrayClass; |
651 ClassElement jsNumberClass; | 651 ClassElement jsNumberClass; |
652 ClassElement jsIntClass; | 652 ClassElement jsIntClass; |
653 ClassElement jsDoubleClass; | 653 ClassElement jsDoubleClass; |
654 ClassElement jsFunctionClass; | 654 ClassElement jsFunctionClass; |
655 ClassElement jsNullClass; | 655 ClassElement jsNullClass; |
656 ClassElement jsBoolClass; | 656 ClassElement jsBoolClass; |
657 ClassElement objectInterceptorClass; | 657 ClassElement objectInterceptorClass; |
| 658 ClassElement listImplementation; |
| 659 Element jsArrayLength; |
| 660 Element jsStringLength; |
658 Element getInterceptorMethod; | 661 Element getInterceptorMethod; |
659 bool _interceptorsAreInitialized = false; | 662 bool _interceptorsAreInitialized = false; |
660 | 663 |
661 final Namer namer; | 664 final Namer namer; |
662 | 665 |
663 /** | 666 /** |
664 * Interface used to determine if an object has the JavaScript | 667 * Interface used to determine if an object has the JavaScript |
665 * indexing behavior. The interface is only visible to specific | 668 * indexing behavior. The interface is only visible to specific |
666 * libraries. | 669 * libraries. |
667 */ | 670 */ |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 jsIntClass = | 767 jsIntClass = |
765 compiler.findInterceptor(const SourceString('JSInt')); | 768 compiler.findInterceptor(const SourceString('JSInt')); |
766 jsDoubleClass = | 769 jsDoubleClass = |
767 compiler.findInterceptor(const SourceString('JSDouble')); | 770 compiler.findInterceptor(const SourceString('JSDouble')); |
768 jsNullClass = | 771 jsNullClass = |
769 compiler.findInterceptor(const SourceString('JSNull')); | 772 compiler.findInterceptor(const SourceString('JSNull')); |
770 jsFunctionClass = | 773 jsFunctionClass = |
771 compiler.findInterceptor(const SourceString('JSFunction')); | 774 compiler.findInterceptor(const SourceString('JSFunction')); |
772 jsBoolClass = | 775 jsBoolClass = |
773 compiler.findInterceptor(const SourceString('JSBool')); | 776 compiler.findInterceptor(const SourceString('JSBool')); |
| 777 jsArrayClass.ensureResolved(compiler); |
| 778 jsArrayLength = |
| 779 jsArrayClass.lookupLocalMember(const SourceString('length')); |
| 780 jsStringClass.ensureResolved(compiler); |
| 781 jsStringLength = |
| 782 jsStringClass.lookupLocalMember(const SourceString('length')); |
| 783 listImplementation = |
| 784 compiler.coreLibrary.find(const SourceString('ListImplementation')); |
774 } | 785 } |
775 | 786 |
776 void addInterceptors(ClassElement cls) { | 787 void addInterceptors(ClassElement cls) { |
777 cls.ensureResolved(compiler); | 788 cls.ensureResolved(compiler); |
778 cls.forEachMember((ClassElement classElement, Element member) { | 789 cls.forEachMember((ClassElement classElement, Element member) { |
779 // TODO(ngeoffray): Support interceptors on Object methods. | 790 // TODO(ngeoffray): Support interceptors on Object methods. |
780 if (classElement == compiler.objectClass) return; | 791 if (classElement == compiler.objectClass) return; |
781 List<Element> list = interceptedElements.putIfAbsent( | 792 List<Element> list = interceptedElements.putIfAbsent( |
782 member.name, () => new List<Element>()); | 793 member.name, () => new List<Element>()); |
783 list.add(member); | 794 list.add(member); |
(...skipping 13 matching lines...) Expand all Loading... |
797 addInterceptors(jsNullClass); | 808 addInterceptors(jsNullClass); |
798 enqueuer.registerInstantiatedClass(jsNullClass); | 809 enqueuer.registerInstantiatedClass(jsNullClass); |
799 } | 810 } |
800 if (jsFunctionClass != null) { | 811 if (jsFunctionClass != null) { |
801 addInterceptors(jsFunctionClass); | 812 addInterceptors(jsFunctionClass); |
802 enqueuer.registerInstantiatedClass(jsFunctionClass); | 813 enqueuer.registerInstantiatedClass(jsFunctionClass); |
803 } | 814 } |
804 } | 815 } |
805 if (cls == compiler.stringClass) { | 816 if (cls == compiler.stringClass) { |
806 result = jsStringClass; | 817 result = jsStringClass; |
807 } else if (cls == compiler.listClass) { | 818 } else if (cls == compiler.listClass || cls == listImplementation) { |
808 result = jsArrayClass; | 819 result = jsArrayClass; |
809 } else if (cls == compiler.intClass) { | 820 } else if (cls == compiler.intClass) { |
810 result = jsIntClass; | 821 result = jsIntClass; |
811 } else if (cls == compiler.doubleClass) { | 822 } else if (cls == compiler.doubleClass) { |
812 result = jsDoubleClass; | 823 result = jsDoubleClass; |
813 } else if (cls == compiler.functionClass) { | 824 } else if (cls == compiler.functionClass) { |
814 result = jsFunctionClass; | 825 result = jsFunctionClass; |
815 } else if (cls == compiler.boolClass) { | 826 } else if (cls == compiler.boolClass) { |
816 result = jsBoolClass; | 827 result = jsBoolClass; |
817 } | 828 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 print("Inferred return types:"); | 1098 print("Inferred return types:"); |
1088 print("----------------------"); | 1099 print("----------------------"); |
1089 dumpReturnTypes(); | 1100 dumpReturnTypes(); |
1090 print(""); | 1101 print(""); |
1091 print("Inferred field types:"); | 1102 print("Inferred field types:"); |
1092 print("------------------------"); | 1103 print("------------------------"); |
1093 fieldTypes.dump(); | 1104 fieldTypes.dump(); |
1094 print(""); | 1105 print(""); |
1095 } | 1106 } |
1096 } | 1107 } |
OLD | NEW |