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; | 9 import '../common/codegen.dart' show CodegenRegistry; |
10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 localsHandler.updateLocal(parameter, argument); | 587 localsHandler.updateLocal(parameter, argument); |
588 } | 588 } |
589 | 589 |
590 constructor.function.positionalParameters.forEach(handleParameter); | 590 constructor.function.positionalParameters.forEach(handleParameter); |
591 constructor.function.namedParameters.toList() | 591 constructor.function.namedParameters.toList() |
592 ..sort(namedOrdering) | 592 ..sort(namedOrdering) |
593 ..forEach(handleParameter); | 593 ..forEach(handleParameter); |
594 | 594 |
595 // Set the locals handler state as if we were inlining the constructor. | 595 // Set the locals handler state as if we were inlining the constructor. |
596 ConstructorEntity astElement = _elementMap.getConstructor(constructor); | 596 ConstructorEntity astElement = _elementMap.getConstructor(constructor); |
597 ClosureClassMap oldClosureData = localsHandler.closureData; | 597 ClosureRepresentationInfo oldClosureData = localsHandler.closureData; |
598 ClosureClassMap newClosureData = | 598 ClosureRepresentationInfo newClosureData = |
599 closureToClassMapper.getMemberMap(astElement); | 599 closureToClassMapper.getClosureRepresentationInfo(astElement); |
600 if (astElement is ConstructorElement) { | 600 if (astElement is ConstructorElement) { |
601 // TODO(johnniwinther): Support constructor (body) entities. | 601 // TODO(johnniwinther): Support constructor (body) entities. |
602 ResolvedAst resolvedAst = astElement.resolvedAst; | 602 ResolvedAst resolvedAst = astElement.resolvedAst; |
603 localsHandler.closureData = newClosureData; | 603 localsHandler.closureData = newClosureData; |
604 if (resolvedAst.kind == ResolvedAstKind.PARSED) { | 604 if (resolvedAst.kind == ResolvedAstKind.PARSED) { |
605 // TODO(efortuna): Take out the test below for null once we are no | 605 // TODO(efortuna): Take out the test below for null once we are no |
606 // longer dealing with the ClosureClassMap interface directly. | 606 // longer dealing with the ClosureClassMap interface directly. |
607 if (newClosureData.capturingScopes[resolvedAst.node] != null) { | 607 if (newClosureData.capturingScopes[resolvedAst.node] != null) { |
608 localsHandler.enterScope( | 608 localsHandler.enterScope( |
609 newClosureData.capturingScopes[resolvedAst.node], | 609 newClosureData.capturingScopes[resolvedAst.node], |
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)); | 2828 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)); |
2829 } else { | 2829 } else { |
2830 push(new HInvokeDynamicMethod( | 2830 push(new HInvokeDynamicMethod( |
2831 selector, mask, inputs, type, isIntercepted)); | 2831 selector, mask, inputs, type, isIntercepted)); |
2832 } | 2832 } |
2833 } | 2833 } |
2834 | 2834 |
2835 @override | 2835 @override |
2836 visitFunctionNode(ir.FunctionNode node) { | 2836 visitFunctionNode(ir.FunctionNode node) { |
2837 Local methodElement = _elementMap.getLocalFunction(node); | 2837 Local methodElement = _elementMap.getLocalFunction(node); |
2838 ClosureClassMap nestedClosureData = | 2838 // TODO(efortuna): Rewrite this so we're not reaching into the |
2839 closureToClassMapper.getLocalFunctionMap(methodElement); | 2839 // closureToClassMapper. We're instead asking it to do something on our |
2840 assert(nestedClosureData != null); | 2840 // behalf. |
2841 assert(nestedClosureData.closureClassElement != null); | 2841 ClosureRepresentationInfo closureInfo = |
2842 ClosureClassElement closureClassElement = | 2842 closureToClassMapper.getClosureRepresentationInfo(methodElement); |
2843 nestedClosureData.closureClassElement; | 2843 ClassEntity closureClassEntity = closureInfo.closureClassEntity; |
2844 MethodElement callElement = nestedClosureData.callElement; | |
2845 | 2844 |
2846 List<HInstruction> capturedVariables = <HInstruction>[]; | 2845 List<HInstruction> capturedVariables = <HInstruction>[]; |
2847 closureClassElement.closureFields.forEach((ClosureFieldElement field) { | 2846 closureInfo.createdFieldEntities.forEach((Local capturedLocal) { |
2848 Local capturedLocal = | |
2849 nestedClosureData.getLocalVariableForClosureField(field); | |
2850 assert(capturedLocal != null); | 2847 assert(capturedLocal != null); |
2851 capturedVariables.add(localsHandler.readLocal(capturedLocal)); | 2848 capturedVariables.add(localsHandler.readLocal(capturedLocal)); |
2852 }); | 2849 }); |
2853 | 2850 |
2854 TypeMask type = new TypeMask.nonNullExact(closureClassElement, closedWorld); | 2851 TypeMask type = new TypeMask.nonNullExact(closureClassEntity, closedWorld); |
2855 // TODO(efortuna): Add source information here. | 2852 // TODO(efortuna): Add source information here. |
2856 push(new HCreate(closureClassElement, capturedVariables, type, | 2853 push(new HCreate(closureClassEntity, capturedVariables, type, |
2857 callMethod: callElement, localFunction: methodElement)); | 2854 callMethod: closureInfo.callEntity, localFunction: methodElement)); |
2858 } | 2855 } |
2859 | 2856 |
2860 @override | 2857 @override |
2861 visitFunctionDeclaration(ir.FunctionDeclaration declaration) { | 2858 visitFunctionDeclaration(ir.FunctionDeclaration declaration) { |
2862 assert(isReachable); | 2859 assert(isReachable); |
2863 declaration.function.accept(this); | 2860 declaration.function.accept(this); |
2864 Local localFunction = _elementMap.getLocalFunction(declaration.function); | 2861 Local localFunction = _elementMap.getLocalFunction(declaration.function); |
2865 localsHandler.updateLocal(localFunction, pop()); | 2862 localsHandler.updateLocal(localFunction, pop()); |
2866 } | 2863 } |
2867 | 2864 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3479 enterBlock.setBlockFlow( | 3476 enterBlock.setBlockFlow( |
3480 new HTryBlockInformation( | 3477 new HTryBlockInformation( |
3481 kernelBuilder.wrapStatementGraph(bodyGraph), | 3478 kernelBuilder.wrapStatementGraph(bodyGraph), |
3482 exception, | 3479 exception, |
3483 kernelBuilder.wrapStatementGraph(catchGraph), | 3480 kernelBuilder.wrapStatementGraph(catchGraph), |
3484 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3481 kernelBuilder.wrapStatementGraph(finallyGraph)), |
3485 exitBlock); | 3482 exitBlock); |
3486 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3483 kernelBuilder.inTryStatement = previouslyInTryStatement; |
3487 } | 3484 } |
3488 } | 3485 } |
OLD | NEW |