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; | 658 Element jsArrayLength; |
660 Element jsStringLength; | 659 Element jsStringLength; |
661 Element getInterceptorMethod; | 660 Element getInterceptorMethod; |
662 bool _interceptorsAreInitialized = false; | 661 bool _interceptorsAreInitialized = false; |
663 | 662 |
664 final Namer namer; | 663 final Namer namer; |
665 | 664 |
666 /** | 665 /** |
667 * Interface used to determine if an object has the JavaScript | 666 * Interface used to determine if an object has the JavaScript |
668 * indexing behavior. The interface is only visible to specific | 667 * indexing behavior. The interface is only visible to specific |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 jsFunctionClass = | 781 jsFunctionClass = |
783 compiler.findInterceptor(const SourceString('JSFunction')); | 782 compiler.findInterceptor(const SourceString('JSFunction')); |
784 jsBoolClass = | 783 jsBoolClass = |
785 compiler.findInterceptor(const SourceString('JSBool')); | 784 compiler.findInterceptor(const SourceString('JSBool')); |
786 jsArrayClass.ensureResolved(compiler); | 785 jsArrayClass.ensureResolved(compiler); |
787 jsArrayLength = | 786 jsArrayLength = |
788 jsArrayClass.lookupLocalMember(const SourceString('length')); | 787 jsArrayClass.lookupLocalMember(const SourceString('length')); |
789 jsStringClass.ensureResolved(compiler); | 788 jsStringClass.ensureResolved(compiler); |
790 jsStringLength = | 789 jsStringLength = |
791 jsStringClass.lookupLocalMember(const SourceString('length')); | 790 jsStringClass.lookupLocalMember(const SourceString('length')); |
792 listImplementation = | |
793 compiler.coreLibrary.find(const SourceString('ListImplementation')); | |
794 } | 791 } |
795 | 792 |
796 void addInterceptors(ClassElement cls) { | 793 void addInterceptors(ClassElement cls) { |
797 cls.ensureResolved(compiler); | 794 cls.ensureResolved(compiler); |
798 cls.forEachMember((ClassElement classElement, Element member) { | 795 cls.forEachMember((ClassElement classElement, Element member) { |
799 Set<Element> set = interceptedElements.putIfAbsent( | 796 Set<Element> set = interceptedElements.putIfAbsent( |
800 member.name, () => new Set<Element>()); | 797 member.name, () => new Set<Element>()); |
801 set.add(member); | 798 set.add(member); |
802 }, | 799 }, |
803 includeSuperMembers: true); | 800 includeSuperMembers: true); |
(...skipping 13 matching lines...) Expand all Loading... |
817 enqueuer.registerInstantiatedClass(jsNullClass); | 814 enqueuer.registerInstantiatedClass(jsNullClass); |
818 } | 815 } |
819 if (jsFunctionClass != null) { | 816 if (jsFunctionClass != null) { |
820 addInterceptors(jsFunctionClass); | 817 addInterceptors(jsFunctionClass); |
821 enqueuer.registerInstantiatedClass(jsFunctionClass); | 818 enqueuer.registerInstantiatedClass(jsFunctionClass); |
822 } | 819 } |
823 enqueuer.addToWorkList(getInterceptorMethod); | 820 enqueuer.addToWorkList(getInterceptorMethod); |
824 } | 821 } |
825 if (cls == compiler.stringClass) { | 822 if (cls == compiler.stringClass) { |
826 result = jsStringClass; | 823 result = jsStringClass; |
827 } else if (cls == compiler.listClass || cls == listImplementation) { | 824 } else if (cls == compiler.listClass) { |
828 result = jsArrayClass; | 825 result = jsArrayClass; |
829 } else if (cls == compiler.intClass) { | 826 } else if (cls == compiler.intClass) { |
830 result = jsIntClass; | 827 result = jsIntClass; |
831 } else if (cls == compiler.doubleClass) { | 828 } else if (cls == compiler.doubleClass) { |
832 result = jsDoubleClass; | 829 result = jsDoubleClass; |
833 } else if (cls == compiler.functionClass) { | 830 } else if (cls == compiler.functionClass) { |
834 result = jsFunctionClass; | 831 result = jsFunctionClass; |
835 } else if (cls == compiler.boolClass) { | 832 } else if (cls == compiler.boolClass) { |
836 result = jsBoolClass; | 833 result = jsBoolClass; |
837 } | 834 } |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 print("Inferred return types:"); | 1100 print("Inferred return types:"); |
1104 print("----------------------"); | 1101 print("----------------------"); |
1105 dumpReturnTypes(); | 1102 dumpReturnTypes(); |
1106 print(""); | 1103 print(""); |
1107 print("Inferred field types:"); | 1104 print("Inferred field types:"); |
1108 print("------------------------"); | 1105 print("------------------------"); |
1109 fieldTypes.dump(); | 1106 fieldTypes.dump(); |
1110 print(""); | 1107 print(""); |
1111 } | 1108 } |
1112 } | 1109 } |
OLD | NEW |