| 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 openFunction(); | 641 openFunction(); |
| 642 _addClassTypeVariablesIfNeeded(constructor); | 642 _addClassTypeVariablesIfNeeded(constructor); |
| 643 constructor.function.body.accept(this); | 643 constructor.function.body.accept(this); |
| 644 closeFunction(); | 644 closeFunction(); |
| 645 } | 645 } |
| 646 | 646 |
| 647 /// Builds a SSA graph for FunctionNodes, found in FunctionExpressions and | 647 /// Builds a SSA graph for FunctionNodes, found in FunctionExpressions and |
| 648 /// Procedures. | 648 /// Procedures. |
| 649 void buildFunctionNode(ir.FunctionNode functionNode) { | 649 void buildFunctionNode(ir.FunctionNode functionNode) { |
| 650 openFunction(); | 650 openFunction(); |
| 651 if (functionNode.parent is ir.Procedure && | 651 ir.TreeNode parent = functionNode.parent; |
| 652 (functionNode.parent as ir.Procedure).kind == | 652 if (parent is ir.Procedure && parent.kind == ir.ProcedureKind.Factory) { |
| 653 ir.ProcedureKind.Factory) { | |
| 654 _addClassTypeVariablesIfNeeded(functionNode.parent); | 653 _addClassTypeVariablesIfNeeded(functionNode.parent); |
| 655 } | 654 } |
| 655 |
| 656 // If [functionNode] is `operator==` we explicitly add a null check at the |
| 657 // beginning of the method. This is to avoid having call sites do the null |
| 658 // check. |
| 659 if (parent is ir.Procedure && |
| 660 parent.kind == ir.ProcedureKind.Operator && |
| 661 parent.name.name == '==') { |
| 662 if (!backend |
| 663 .operatorEqHandlesNullArgument(astAdapter.getMethod(parent))) { |
| 664 handleIf( |
| 665 visitCondition: () { |
| 666 HParameterValue parameter = parameters.values.first; |
| 667 push(new HIdentity(parameter, graph.addConstantNull(closedWorld), |
| 668 null, commonMasks.boolType)); |
| 669 }, |
| 670 visitThen: () { |
| 671 closeAndGotoExit(new HReturn( |
| 672 graph.addConstantBool(false, closedWorld), |
| 673 sourceInformationBuilder |
| 674 .buildImplicitReturn(astAdapter.getElement(parent)))); |
| 675 }, |
| 676 visitElse: null, |
| 677 // TODO(27394): Add sourceInformation via |
| 678 // `sourceInformationBuilder.buildIf(?)`. |
| 679 ); |
| 680 } |
| 681 } |
| 656 functionNode.body.accept(this); | 682 functionNode.body.accept(this); |
| 657 closeFunction(); | 683 closeFunction(); |
| 658 } | 684 } |
| 659 | 685 |
| 660 void addImplicitInstantiation(ResolutionDartType type) { | 686 void addImplicitInstantiation(ResolutionDartType type) { |
| 661 if (type != null) { | 687 if (type != null) { |
| 662 currentImplicitInstantiations.add(type); | 688 currentImplicitInstantiations.add(type); |
| 663 } | 689 } |
| 664 } | 690 } |
| 665 | 691 |
| (...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3414 enterBlock.setBlockFlow( | 3440 enterBlock.setBlockFlow( |
| 3415 new HTryBlockInformation( | 3441 new HTryBlockInformation( |
| 3416 kernelBuilder.wrapStatementGraph(bodyGraph), | 3442 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3417 exception, | 3443 exception, |
| 3418 kernelBuilder.wrapStatementGraph(catchGraph), | 3444 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3419 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3445 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3420 exitBlock); | 3446 exitBlock); |
| 3421 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3447 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3422 } | 3448 } |
| 3423 } | 3449 } |
| OLD | NEW |