| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2620 } | 2620 } |
| 2621 | 2621 |
| 2622 static ir.Class _containingClass(ir.TreeNode node) { | 2622 static ir.Class _containingClass(ir.TreeNode node) { |
| 2623 while (node != null) { | 2623 while (node != null) { |
| 2624 if (node is ir.Class) return node; | 2624 if (node is ir.Class) return node; |
| 2625 node = node.parent; | 2625 node = node.parent; |
| 2626 } | 2626 } |
| 2627 return null; | 2627 return null; |
| 2628 } | 2628 } |
| 2629 | 2629 |
| 2630 @override | 2630 HInstruction _buildInvokeSuper( |
| 2631 void visitSuperMethodInvocation(ir.SuperMethodInvocation invocation) { | 2631 ir.Expression invocation, List<HInstruction> arguments) { |
| 2632 // Invocation is either a method invocation or a property get/set. |
| 2633 // TODO(efortuna): Common interface? |
| 2634 // TODO(efortuna): Add source information. |
| 2632 Selector selector = astAdapter.getSelector(invocation); | 2635 Selector selector = astAdapter.getSelector(invocation); |
| 2633 List<HInstruction> arguments = _visitArgumentsForStaticTarget( | |
| 2634 invocation.interfaceTarget.function, invocation.arguments); | |
| 2635 HInstruction receiver = localsHandler.readThis(); | 2636 HInstruction receiver = localsHandler.readThis(); |
| 2636 ir.Class surroundingClass = _containingClass(invocation); | 2637 ir.Class surroundingClass = _containingClass(invocation); |
| 2637 | 2638 |
| 2638 List<HInstruction> inputs = <HInstruction>[]; | 2639 List<HInstruction> inputs = <HInstruction>[]; |
| 2639 if (astAdapter.isIntercepted(invocation)) { | 2640 if (astAdapter.isIntercepted(invocation)) { |
| 2640 inputs.add(_interceptorFor(receiver)); | 2641 inputs.add(_interceptorFor(receiver)); |
| 2641 } | 2642 } |
| 2642 inputs.add(receiver); | 2643 inputs.add(receiver); |
| 2643 inputs.addAll(arguments); | 2644 inputs.addAll(arguments); |
| 2644 | 2645 |
| 2646 ir.Member interfaceTarget = invocation is ir.SuperMethodInvocation ? |
| 2647 (invocation as ir.SuperMethodInvocation).interfaceTarget : |
| 2648 (invocation as ir.SuperPropertyGet).interfaceTarget; |
| 2649 |
| 2645 HInstruction instruction = new HInvokeSuper( | 2650 HInstruction instruction = new HInvokeSuper( |
| 2646 astAdapter.getMethod(invocation.interfaceTarget), | 2651 astAdapter.getMember(interfaceTarget), |
| 2647 astAdapter.getClass(surroundingClass), | 2652 astAdapter.getClass(surroundingClass), |
| 2648 selector, | 2653 selector, |
| 2649 inputs, | 2654 inputs, |
| 2650 astAdapter.returnTypeOf(invocation.interfaceTarget), | 2655 astAdapter.returnTypeOf(interfaceTarget), |
| 2651 null, | 2656 null, |
| 2652 isSetter: selector.isSetter || selector.isIndexSet); | 2657 isSetter: selector.isSetter || selector.isIndexSet); |
| 2653 instruction.sideEffects = | 2658 instruction.sideEffects = |
| 2654 closedWorld.getSideEffectsOfSelector(selector, null); | 2659 closedWorld.getSideEffectsOfSelector(selector, null); |
| 2655 push(instruction); | 2660 push(instruction); |
| 2661 return instruction; |
| 2656 } | 2662 } |
| 2657 | 2663 |
| 2658 @override | 2664 @override |
| 2665 void visitSuperPropertyGet(ir.SuperPropertyGet propertyGet) { |
| 2666 _buildInvokeSuper(propertyGet, const <HInstruction>[]); |
| 2667 } |
| 2668 |
| 2669 @override |
| 2670 void visitSuperMethodInvocation(ir.SuperMethodInvocation invocation) { |
| 2671 List<HInstruction> arguments = _visitArgumentsForStaticTarget( |
| 2672 invocation.interfaceTarget.function, invocation.arguments); |
| 2673 _buildInvokeSuper(invocation, arguments); |
| 2674 } |
| 2675 |
| 2676 @override |
| 2659 void visitConstructorInvocation(ir.ConstructorInvocation invocation) { | 2677 void visitConstructorInvocation(ir.ConstructorInvocation invocation) { |
| 2660 ir.Constructor target = invocation.target; | 2678 ir.Constructor target = invocation.target; |
| 2661 // TODO(sra): For JS-interop targets, process arguments differently. | 2679 // TODO(sra): For JS-interop targets, process arguments differently. |
| 2662 List<HInstruction> arguments = | 2680 List<HInstruction> arguments = |
| 2663 _visitArgumentsForStaticTarget(target.function, invocation.arguments); | 2681 _visitArgumentsForStaticTarget(target.function, invocation.arguments); |
| 2664 TypeMask typeMask = new TypeMask.nonNullExact( | 2682 TypeMask typeMask = new TypeMask.nonNullExact( |
| 2665 astAdapter.getClass(target.enclosingClass), closedWorld); | 2683 astAdapter.getClass(target.enclosingClass), closedWorld); |
| 2666 _pushStaticInvocation(target, arguments, typeMask); | 2684 _pushStaticInvocation(target, arguments, typeMask); |
| 2667 } | 2685 } |
| 2668 | 2686 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 enterBlock.setBlockFlow( | 3108 enterBlock.setBlockFlow( |
| 3091 new HTryBlockInformation( | 3109 new HTryBlockInformation( |
| 3092 kernelBuilder.wrapStatementGraph(bodyGraph), | 3110 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3093 exception, | 3111 exception, |
| 3094 kernelBuilder.wrapStatementGraph(catchGraph), | 3112 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3095 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3113 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3096 exitBlock); | 3114 exitBlock); |
| 3097 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3115 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3098 } | 3116 } |
| 3099 } | 3117 } |
| OLD | NEW |