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 ssa; | 5 part of ssa; |
6 | 6 |
7 class Interceptors { | 7 class Interceptors { |
8 Compiler compiler; | 8 Compiler compiler; |
9 Interceptors(Compiler this.compiler); | 9 Interceptors(Compiler this.compiler); |
10 | 10 |
(...skipping 3839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3850 // E <declaredIdentifier> = $iter.next(); | 3850 // E <declaredIdentifier> = $iter.next(); |
3851 // <body> | 3851 // <body> |
3852 // } | 3852 // } |
3853 | 3853 |
3854 // The iterator is shared between initializer, condition and body. | 3854 // The iterator is shared between initializer, condition and body. |
3855 HInstruction iterator; | 3855 HInstruction iterator; |
3856 void buildInitializer() { | 3856 void buildInitializer() { |
3857 SourceString iteratorName = const SourceString("iterator"); | 3857 SourceString iteratorName = const SourceString("iterator"); |
3858 Selector selector = | 3858 Selector selector = |
3859 new Selector.call(iteratorName, work.element.getLibrary(), 0); | 3859 new Selector.call(iteratorName, work.element.getLibrary(), 0); |
3860 Element interceptor = interceptors.getStaticInterceptor(selector); | 3860 Element element = interceptors.getStaticInterceptor(selector); |
3861 assert(interceptor != null); | |
3862 visit(node.expression); | 3861 visit(node.expression); |
3863 pushInvokeHelper1(interceptor, pop()); | 3862 HInstruction receiver = pop(); |
3864 iterator = pop(); | 3863 pushInvokeHelper1(element, receiver); |
| 3864 HInstruction interceptor = pop(); |
| 3865 iterator = new HInvokeDynamicMethod( |
| 3866 selector, <HInstruction>[interceptor, receiver]); |
| 3867 add(iterator); |
3865 } | 3868 } |
3866 HInstruction buildCondition() { | 3869 HInstruction buildCondition() { |
3867 SourceString name = const SourceString('hasNext'); | 3870 SourceString name = const SourceString('hasNext'); |
3868 Selector selector = new Selector.getter(name, work.element.getLibrary()); | 3871 Selector selector = new Selector.getter(name, work.element.getLibrary()); |
3869 if (interceptors.getStaticInterceptor(selector) != null) { | 3872 if (interceptors.getStaticInterceptor(selector) != null) { |
3870 compiler.internalError("hasNext getter must not be intercepted", | 3873 compiler.internalError("hasNext getter must not be intercepted", |
3871 node: node); | 3874 node: node); |
3872 } | 3875 } |
3873 bool hasGetter = compiler.world.hasAnyUserDefinedGetter(selector); | 3876 bool hasGetter = compiler.world.hasAnyUserDefinedGetter(selector); |
3874 push(new HInvokeDynamicGetter(selector, null, iterator, !hasGetter)); | 3877 push(new HInvokeDynamicGetter(selector, null, iterator, !hasGetter)); |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4942 new HSubGraphBlockInformation(elseBranch.graph)); | 4945 new HSubGraphBlockInformation(elseBranch.graph)); |
4943 | 4946 |
4944 HBasicBlock conditionStartBlock = conditionBranch.block; | 4947 HBasicBlock conditionStartBlock = conditionBranch.block; |
4945 conditionStartBlock.setBlockFlow(info, joinBlock); | 4948 conditionStartBlock.setBlockFlow(info, joinBlock); |
4946 SubGraph conditionGraph = conditionBranch.graph; | 4949 SubGraph conditionGraph = conditionBranch.graph; |
4947 HIf branch = conditionGraph.end.last; | 4950 HIf branch = conditionGraph.end.last; |
4948 assert(branch is HIf); | 4951 assert(branch is HIf); |
4949 branch.blockInformation = conditionStartBlock.blockFlow; | 4952 branch.blockInformation = conditionStartBlock.blockFlow; |
4950 } | 4953 } |
4951 } | 4954 } |
OLD | NEW |