| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1750 SourceString getterName = send.selector.asIdentifier().source; | 1750 SourceString getterName = send.selector.asIdentifier().source; |
| 1751 Selector selector = elements.getSelector(send); | 1751 Selector selector = elements.getSelector(send); |
| 1752 Element staticInterceptor = null; | 1752 Element staticInterceptor = null; |
| 1753 if (methodInterceptionEnabled) { | 1753 if (methodInterceptionEnabled) { |
| 1754 staticInterceptor = interceptors.getStaticGetInterceptor(getterName); | 1754 staticInterceptor = interceptors.getStaticGetInterceptor(getterName); |
| 1755 } | 1755 } |
| 1756 if (staticInterceptor != null) { | 1756 if (staticInterceptor != null) { |
| 1757 HStatic target = new HStatic(staticInterceptor); | 1757 HStatic target = new HStatic(staticInterceptor); |
| 1758 add(target); | 1758 add(target); |
| 1759 List<HInstruction> inputs = <HInstruction>[target, receiver]; | 1759 List<HInstruction> inputs = <HInstruction>[target, receiver]; |
| 1760 push(new HInvokeInterceptor(selector, getterName, true, inputs)); | 1760 push(new HInvokeInterceptor(selector, getterName, true, false, inputs)); |
| 1761 } else { | 1761 } else { |
| 1762 push(new HInvokeDynamicGetter(selector, null, getterName, receiver)); | 1762 push(new HInvokeDynamicGetter(selector, null, getterName, receiver)); |
| 1763 } | 1763 } |
| 1764 } | 1764 } |
| 1765 | 1765 |
| 1766 void generateGetter(Send send, Element element) { | 1766 void generateGetter(Send send, Element element) { |
| 1767 if (Elements.isStaticOrTopLevelField(element)) { | 1767 if (Elements.isStaticOrTopLevelField(element)) { |
| 1768 if (element.kind == ElementKind.FIELD && !element.isAssignable()) { | 1768 if (element.kind == ElementKind.FIELD && !element.isAssignable()) { |
| 1769 // A static final. Get its constant value and inline it. | 1769 // A static final. Get its constant value and inline it. |
| 1770 Constant value = compiler.constantHandler.compileVariable(element); | 1770 Constant value = compiler.constantHandler.compileVariable(element); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1794 SourceString dartSetterName = send.selector.asIdentifier().source; | 1794 SourceString dartSetterName = send.selector.asIdentifier().source; |
| 1795 Selector selector = elements.getSelector(send); | 1795 Selector selector = elements.getSelector(send); |
| 1796 Element staticInterceptor = null; | 1796 Element staticInterceptor = null; |
| 1797 if (methodInterceptionEnabled) { | 1797 if (methodInterceptionEnabled) { |
| 1798 staticInterceptor = interceptors.getStaticSetInterceptor(dartSetterName); | 1798 staticInterceptor = interceptors.getStaticSetInterceptor(dartSetterName); |
| 1799 } | 1799 } |
| 1800 if (staticInterceptor != null) { | 1800 if (staticInterceptor != null) { |
| 1801 HStatic target = new HStatic(staticInterceptor); | 1801 HStatic target = new HStatic(staticInterceptor); |
| 1802 add(target); | 1802 add(target); |
| 1803 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; | 1803 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; |
| 1804 add(new HInvokeInterceptor(selector, dartSetterName, false, inputs)); | 1804 add(new HInvokeInterceptor( |
| 1805 selector, dartSetterName, false, true, inputs)); |
| 1805 } else { | 1806 } else { |
| 1806 add(new HInvokeDynamicSetter(selector, null, dartSetterName, | 1807 add(new HInvokeDynamicSetter(selector, null, dartSetterName, |
| 1807 receiver, value)); | 1808 receiver, value)); |
| 1808 } | 1809 } |
| 1809 stack.add(value); | 1810 stack.add(value); |
| 1810 } | 1811 } |
| 1811 | 1812 |
| 1812 void generateSetter(SendSet send, Element element, HInstruction value) { | 1813 void generateSetter(SendSet send, Element element, HInstruction value) { |
| 1813 if (Elements.isStaticOrTopLevelField(element)) { | 1814 if (Elements.isStaticOrTopLevelField(element)) { |
| 1814 Selector selector = elements.getSelector(send); | 1815 Selector selector = elements.getSelector(send); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 interceptor = interceptors.getStaticInterceptor(dartMethodName, | 2002 interceptor = interceptors.getStaticInterceptor(dartMethodName, |
| 2002 node.argumentCount()); | 2003 node.argumentCount()); |
| 2003 } | 2004 } |
| 2004 if (interceptor != null) { | 2005 if (interceptor != null) { |
| 2005 HStatic target = new HStatic(interceptor); | 2006 HStatic target = new HStatic(interceptor); |
| 2006 add(target); | 2007 add(target); |
| 2007 inputs.add(target); | 2008 inputs.add(target); |
| 2008 visit(node.receiver); | 2009 visit(node.receiver); |
| 2009 inputs.add(pop()); | 2010 inputs.add(pop()); |
| 2010 addGenericSendArgumentsToList(node.arguments, inputs); | 2011 addGenericSendArgumentsToList(node.arguments, inputs); |
| 2011 push(new HInvokeInterceptor(selector, dartMethodName, false, inputs)); | 2012 push(new HInvokeInterceptor( |
| 2013 selector, dartMethodName, false, false, inputs)); |
| 2012 return; | 2014 return; |
| 2013 } | 2015 } |
| 2014 | 2016 |
| 2015 if (node.receiver === null) { | 2017 if (node.receiver === null) { |
| 2016 inputs.add(localsHandler.readThis()); | 2018 inputs.add(localsHandler.readThis()); |
| 2017 } else { | 2019 } else { |
| 2018 visit(node.receiver); | 2020 visit(node.receiver); |
| 2019 inputs.add(pop()); | 2021 inputs.add(pop()); |
| 2020 } | 2022 } |
| 2021 | 2023 |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2746 // The iterator is shared between initializer, condition and body. | 2748 // The iterator is shared between initializer, condition and body. |
| 2747 HInstruction iterator; | 2749 HInstruction iterator; |
| 2748 void buildInitializer() { | 2750 void buildInitializer() { |
| 2749 SourceString iteratorName = const SourceString("iterator"); | 2751 SourceString iteratorName = const SourceString("iterator"); |
| 2750 Element interceptor = interceptors.getStaticInterceptor(iteratorName, 0); | 2752 Element interceptor = interceptors.getStaticInterceptor(iteratorName, 0); |
| 2751 assert(interceptor != null); | 2753 assert(interceptor != null); |
| 2752 HStatic target = new HStatic(interceptor); | 2754 HStatic target = new HStatic(interceptor); |
| 2753 add(target); | 2755 add(target); |
| 2754 visit(node.expression); | 2756 visit(node.expression); |
| 2755 List<HInstruction> inputs = <HInstruction>[target, pop()]; | 2757 List<HInstruction> inputs = <HInstruction>[target, pop()]; |
| 2756 iterator = new HInvokeInterceptor(selector, iteratorName, false, inputs); | 2758 iterator = new HInvokeInterceptor( |
| 2759 selector, iteratorName, false, false, inputs); |
| 2757 add(iterator); | 2760 add(iterator); |
| 2758 } | 2761 } |
| 2759 HInstruction buildCondition() { | 2762 HInstruction buildCondition() { |
| 2760 push(new HInvokeDynamicMethod( | 2763 push(new HInvokeDynamicMethod( |
| 2761 selector, const SourceString('hasNext'), <HInstruction>[iterator])); | 2764 selector, const SourceString('hasNext'), <HInstruction>[iterator])); |
| 2762 return popBoolified(); | 2765 return popBoolified(); |
| 2763 } | 2766 } |
| 2764 void buildBody() { | 2767 void buildBody() { |
| 2765 push(new HInvokeDynamicMethod( | 2768 push(new HInvokeDynamicMethod( |
| 2766 selector, const SourceString('next'), <HInstruction>[iterator])); | 2769 selector, const SourceString('next'), <HInstruction>[iterator])); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3278 <HInstruction>[target, input], | 3281 <HInstruction>[target, input], |
| 3279 HType.STRING)); | 3282 HType.STRING)); |
| 3280 return builder.pop(); | 3283 return builder.pop(); |
| 3281 } | 3284 } |
| 3282 | 3285 |
| 3283 HInstruction result() { | 3286 HInstruction result() { |
| 3284 flushLiterals(); | 3287 flushLiterals(); |
| 3285 return prefix; | 3288 return prefix; |
| 3286 } | 3289 } |
| 3287 } | 3290 } |
| OLD | NEW |