| 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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 assert(selector.isGetter()); | 1760 assert(selector.isGetter()); |
| 1761 SourceString getterName = selector.name; | 1761 SourceString getterName = selector.name; |
| 1762 Element staticInterceptor = null; | 1762 Element staticInterceptor = null; |
| 1763 if (methodInterceptionEnabled) { | 1763 if (methodInterceptionEnabled) { |
| 1764 staticInterceptor = interceptors.getStaticGetInterceptor(getterName); | 1764 staticInterceptor = interceptors.getStaticGetInterceptor(getterName); |
| 1765 } | 1765 } |
| 1766 if (staticInterceptor != null) { | 1766 if (staticInterceptor != null) { |
| 1767 HStatic target = new HStatic(staticInterceptor); | 1767 HStatic target = new HStatic(staticInterceptor); |
| 1768 add(target); | 1768 add(target); |
| 1769 List<HInstruction> inputs = <HInstruction>[target, receiver]; | 1769 List<HInstruction> inputs = <HInstruction>[target, receiver]; |
| 1770 push(new HInvokeInterceptor(selector, getterName, inputs, getter: true)); | 1770 push(new HInvokeInterceptor(selector, inputs)); |
| 1771 } else { | 1771 } else { |
| 1772 push(new HInvokeDynamicGetter(selector, null, receiver)); | 1772 push(new HInvokeDynamicGetter(selector, null, receiver)); |
| 1773 } | 1773 } |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 void generateGetter(Send send, Element element) { | 1776 void generateGetter(Send send, Element element) { |
| 1777 if (Elements.isStaticOrTopLevelField(element)) { | 1777 if (Elements.isStaticOrTopLevelField(element)) { |
| 1778 if (element.kind == ElementKind.FIELD && !element.isAssignable()) { | 1778 if (element.kind == ElementKind.FIELD && !element.isAssignable()) { |
| 1779 // A static final. Get its constant value and inline it. | 1779 // A static final. Get its constant value and inline it. |
| 1780 Constant value = compiler.constantHandler.compileVariable(element); | 1780 Constant value = compiler.constantHandler.compileVariable(element); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1805 assert(selector.isSetter()); | 1805 assert(selector.isSetter()); |
| 1806 SourceString setterName = selector.name; | 1806 SourceString setterName = selector.name; |
| 1807 Element staticInterceptor = null; | 1807 Element staticInterceptor = null; |
| 1808 if (methodInterceptionEnabled) { | 1808 if (methodInterceptionEnabled) { |
| 1809 staticInterceptor = interceptors.getStaticSetInterceptor(setterName); | 1809 staticInterceptor = interceptors.getStaticSetInterceptor(setterName); |
| 1810 } | 1810 } |
| 1811 if (staticInterceptor != null) { | 1811 if (staticInterceptor != null) { |
| 1812 HStatic target = new HStatic(staticInterceptor); | 1812 HStatic target = new HStatic(staticInterceptor); |
| 1813 add(target); | 1813 add(target); |
| 1814 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; | 1814 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; |
| 1815 add(new HInvokeInterceptor( | 1815 add(new HInvokeInterceptor(selector, inputs)); |
| 1816 selector, setterName, inputs, setter: true)); | |
| 1817 } else { | 1816 } else { |
| 1818 add(new HInvokeDynamicSetter(selector, null, receiver, value)); | 1817 add(new HInvokeDynamicSetter(selector, null, receiver, value)); |
| 1819 } | 1818 } |
| 1820 stack.add(value); | 1819 stack.add(value); |
| 1821 } | 1820 } |
| 1822 | 1821 |
| 1823 void generateSetter(SendSet send, Element element, HInstruction value) { | 1822 void generateSetter(SendSet send, Element element, HInstruction value) { |
| 1824 if (Elements.isStaticOrTopLevelField(element)) { | 1823 if (Elements.isStaticOrTopLevelField(element)) { |
| 1825 if (element.kind == ElementKind.SETTER) { | 1824 if (element.kind == ElementKind.SETTER) { |
| 1826 HStatic target = new HStatic(element); | 1825 HStatic target = new HStatic(element); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 interceptor = interceptors.getStaticInterceptor(dartMethodName, | 2043 interceptor = interceptors.getStaticInterceptor(dartMethodName, |
| 2045 node.argumentCount()); | 2044 node.argumentCount()); |
| 2046 } | 2045 } |
| 2047 if (interceptor != null) { | 2046 if (interceptor != null) { |
| 2048 HStatic target = new HStatic(interceptor); | 2047 HStatic target = new HStatic(interceptor); |
| 2049 add(target); | 2048 add(target); |
| 2050 inputs.add(target); | 2049 inputs.add(target); |
| 2051 visit(node.receiver); | 2050 visit(node.receiver); |
| 2052 inputs.add(pop()); | 2051 inputs.add(pop()); |
| 2053 addGenericSendArgumentsToList(node.arguments, inputs); | 2052 addGenericSendArgumentsToList(node.arguments, inputs); |
| 2054 push(new HInvokeInterceptor(selector, dartMethodName, inputs)); | 2053 push(new HInvokeInterceptor(selector, inputs)); |
| 2055 return; | 2054 return; |
| 2056 } | 2055 } |
| 2057 | 2056 |
| 2058 if (node.receiver === null) { | 2057 if (node.receiver === null) { |
| 2059 inputs.add(localsHandler.readThis()); | 2058 inputs.add(localsHandler.readThis()); |
| 2060 } else { | 2059 } else { |
| 2061 visit(node.receiver); | 2060 visit(node.receiver); |
| 2062 inputs.add(pop()); | 2061 inputs.add(pop()); |
| 2063 } | 2062 } |
| 2064 | 2063 |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 new HSubGraphBlockInformation(elseBranch.graph)); | 3646 new HSubGraphBlockInformation(elseBranch.graph)); |
| 3648 | 3647 |
| 3649 HBasicBlock conditionStartBlock = conditionBranch.block; | 3648 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 3650 conditionStartBlock.setBlockFlow(info, joinBlock); | 3649 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 3651 SubGraph conditionGraph = conditionBranch.graph; | 3650 SubGraph conditionGraph = conditionBranch.graph; |
| 3652 HIf branch = conditionGraph.end.last; | 3651 HIf branch = conditionGraph.end.last; |
| 3653 assert(branch is HIf); | 3652 assert(branch is HIf); |
| 3654 branch.blockInformation = conditionStartBlock.blockFlow; | 3653 branch.blockInformation = conditionStartBlock.blockFlow; |
| 3655 } | 3654 } |
| 3656 } | 3655 } |
| OLD | NEW |