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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) | 704 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) |
705 : new CodeEmitterTask(compiler, namer, generateSourceMap); | 705 : new CodeEmitterTask(compiler, namer, generateSourceMap); |
706 builder = new SsaBuilderTask(this); | 706 builder = new SsaBuilderTask(this); |
707 optimizer = new SsaOptimizerTask(this); | 707 optimizer = new SsaOptimizerTask(this); |
708 generator = new SsaCodeGeneratorTask(this); | 708 generator = new SsaCodeGeneratorTask(this); |
709 argumentTypes = new ArgumentTypesRegistry(this); | 709 argumentTypes = new ArgumentTypesRegistry(this); |
710 fieldTypes = new FieldTypesRegistry(this); | 710 fieldTypes = new FieldTypesRegistry(this); |
711 } | 711 } |
712 | 712 |
713 bool isInterceptorClass(Element element) { | 713 bool isInterceptorClass(Element element) { |
| 714 if (element == null) return false; |
714 return element == jsStringClass; | 715 return element == jsStringClass; |
715 } | 716 } |
716 | 717 |
717 void addInterceptedSelector(Selector selector) { | 718 void addInterceptedSelector(Selector selector) { |
718 usedInterceptors.add(selector); | 719 usedInterceptors.add(selector); |
719 } | 720 } |
720 | 721 |
721 bool shouldInterceptSelector(Selector selector) { | 722 bool shouldInterceptSelector(Selector selector) { |
722 List<Element> intercepted = interceptedElements[selector.name]; | 723 List<Element> intercepted = interceptedElements[selector.name]; |
723 if (intercepted == null) return false; | 724 if (intercepted == null) return false; |
724 for (Element element in intercepted) { | 725 for (Element element in intercepted) { |
725 if (selector.applies(element, compiler)) return true; | 726 if (selector.applies(element, compiler)) return true; |
726 } | 727 } |
727 return false; | 728 return false; |
728 } | 729 } |
729 | 730 |
| 731 void initializeInterceptorElements() { |
| 732 objectInterceptorClass = |
| 733 compiler.findInterceptor(const SourceString('ObjectInterceptor')); |
| 734 getInterceptorMethod = |
| 735 compiler.findInterceptor(const SourceString('getInterceptor')); |
| 736 } |
| 737 |
730 | 738 |
731 void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) { | 739 void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) { |
732 ClassElement result = null; | 740 ClassElement result = null; |
733 if (cls == compiler.stringClass) { | 741 if (cls == compiler.stringClass) { |
734 if (jsStringClass == null) { | 742 if (jsStringClass == null) { |
735 jsStringClass = | 743 jsStringClass = |
736 compiler.findInterceptor(const SourceString('JSString')); | 744 compiler.findInterceptor(const SourceString('JSString')); |
737 objectInterceptorClass = | 745 initializeInterceptorElements(); |
738 compiler.findInterceptor(const SourceString('ObjectInterceptor')); | |
739 getInterceptorMethod = | |
740 compiler.findInterceptor(const SourceString('getInterceptor')); | |
741 } | 746 } |
742 result = jsStringClass; | 747 result = jsStringClass; |
743 } | 748 } |
744 | 749 |
745 if (result == null) return; | 750 if (result == null) return; |
746 | 751 |
747 result.forEachMember((_, Element member) { | 752 result.forEachMember((_, Element member) { |
748 List<Element> list = interceptedElements.putIfAbsent( | 753 List<Element> list = interceptedElements.putIfAbsent( |
749 member.name, () => new List<Element>()); | 754 member.name, () => new List<Element>()); |
750 list.add(member); | 755 list.add(member); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 print("Inferred return types:"); | 1020 print("Inferred return types:"); |
1016 print("----------------------"); | 1021 print("----------------------"); |
1017 dumpReturnTypes(); | 1022 dumpReturnTypes(); |
1018 print(""); | 1023 print(""); |
1019 print("Inferred field types:"); | 1024 print("Inferred field types:"); |
1020 print("------------------------"); | 1025 print("------------------------"); |
1021 fieldTypes.dump(); | 1026 fieldTypes.dump(); |
1022 print(""); | 1027 print(""); |
1023 } | 1028 } |
1024 } | 1029 } |
OLD | NEW |