| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closurelib; | 7 import '../closure.dart' as closurelib; |
| 8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 redirectingConstructor.computeEffectiveTargetType(cls.thisType); | 277 redirectingConstructor.computeEffectiveTargetType(cls.thisType); |
| 278 CallStructure callStructure = new CallStructure( | 278 CallStructure callStructure = new CallStructure( |
| 279 redirectingSignature.parameterCount, | 279 redirectingSignature.parameterCount, |
| 280 namedParameters); | 280 namedParameters); |
| 281 arguments = normalizeStaticArguments(callStructure, targetConstructor, | 281 arguments = normalizeStaticArguments(callStructure, targetConstructor, |
| 282 arguments); | 282 arguments); |
| 283 ir.Primitive instance = irBuilder.buildConstructorInvocation( | 283 ir.Primitive instance = irBuilder.buildConstructorInvocation( |
| 284 targetConstructor, | 284 targetConstructor, |
| 285 callStructure, | 285 callStructure, |
| 286 targetType, | 286 targetType, |
| 287 arguments); | 287 arguments, |
| 288 irBuilder.buildReturn(instance); | 288 sourceInformationBuilder.buildNew(node)); |
| 289 irBuilder.buildReturn( |
| 290 value: instance, |
| 291 sourceInformation: sourceInformationBuilder.buildReturn(node)); |
| 289 } | 292 } |
| 290 | 293 |
| 291 visitFor(ast.For node) { | 294 visitFor(ast.For node) { |
| 292 List<LocalElement> loopVariables = <LocalElement>[]; | 295 List<LocalElement> loopVariables = <LocalElement>[]; |
| 293 if (node.initializer is ast.VariableDefinitions) { | 296 if (node.initializer is ast.VariableDefinitions) { |
| 294 ast.VariableDefinitions definitions = node.initializer; | 297 ast.VariableDefinitions definitions = node.initializer; |
| 295 for (ast.Node node in definitions.definitions.nodes) { | 298 for (ast.Node node in definitions.definitions.nodes) { |
| 296 LocalElement loopVariable = elements[node]; | 299 LocalElement loopVariable = elements[node]; |
| 297 loopVariables.add(loopVariable); | 300 loopVariables.add(loopVariable); |
| 298 } | 301 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 return null; | 395 return null; |
| 393 } | 396 } |
| 394 | 397 |
| 395 // Build(Return(e), C) = C'[InvokeContinuation(return, x)] | 398 // Build(Return(e), C) = C'[InvokeContinuation(return, x)] |
| 396 // where (C', x) = Build(e, C) | 399 // where (C', x) = Build(e, C) |
| 397 // | 400 // |
| 398 // Return without a subexpression is translated as if it were return null. | 401 // Return without a subexpression is translated as if it were return null. |
| 399 ir.Primitive visitReturn(ast.Return node) { | 402 ir.Primitive visitReturn(ast.Return node) { |
| 400 assert(irBuilder.isOpen); | 403 assert(irBuilder.isOpen); |
| 401 assert(invariant(node, node.beginToken.value != 'native')); | 404 assert(invariant(node, node.beginToken.value != 'native')); |
| 402 irBuilder.buildReturn(build(node.expression)); | 405 irBuilder.buildReturn( |
| 406 value: build(node.expression), |
| 407 sourceInformation: sourceInformationBuilder.buildReturn(node)); |
| 403 return null; | 408 return null; |
| 404 } | 409 } |
| 405 | 410 |
| 406 visitSwitchStatement(ast.SwitchStatement node) { | 411 visitSwitchStatement(ast.SwitchStatement node) { |
| 407 assert(irBuilder.isOpen); | 412 assert(irBuilder.isOpen); |
| 408 // We do not handle switch statements with continue to labeled cases. | 413 // We do not handle switch statements with continue to labeled cases. |
| 409 for (ast.SwitchCase switchCase in node.cases) { | 414 for (ast.SwitchCase switchCase in node.cases) { |
| 410 for (ast.Node labelOrCase in switchCase.labelsAndCases) { | 415 for (ast.Node labelOrCase in switchCase.labelsAndCases) { |
| 411 if (labelOrCase is ast.Label) { | 416 if (labelOrCase is ast.Label) { |
| 412 LabelDefinition definition = elements.getLabelDefinition(labelOrCase); | 417 LabelDefinition definition = elements.getLabelDefinition(labelOrCase); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 531 } |
| 527 | 532 |
| 528 ConstantValue getConstantForNode(ast.Node node) { | 533 ConstantValue getConstantForNode(ast.Node node) { |
| 529 return irBuilder.state.constants.getConstantValueForNode(node, elements); | 534 return irBuilder.state.constants.getConstantValueForNode(node, elements); |
| 530 } | 535 } |
| 531 | 536 |
| 532 ConstantValue getConstantForVariable(VariableElement element) { | 537 ConstantValue getConstantForVariable(VariableElement element) { |
| 533 return irBuilder.state.constants.getConstantValueForVariable(element); | 538 return irBuilder.state.constants.getConstantValueForVariable(element); |
| 534 } | 539 } |
| 535 | 540 |
| 536 ir.Primitive buildConstantExpression(ConstantExpression expression) { | 541 ir.Primitive buildConstantExpression(ConstantExpression expression, |
| 542 SourceInformation sourceInformation) { |
| 537 return irBuilder.buildConstant( | 543 return irBuilder.buildConstant( |
| 538 irBuilder.state.constants.getConstantValue(expression)); | 544 irBuilder.state.constants.getConstantValue(expression), |
| 545 sourceInformation: sourceInformation); |
| 539 } | 546 } |
| 540 | 547 |
| 541 ir.Primitive visitLiteralList(ast.LiteralList node) { | 548 ir.Primitive visitLiteralList(ast.LiteralList node) { |
| 542 if (node.isConst) { | 549 if (node.isConst) { |
| 543 return translateConstant(node); | 550 return translateConstant(node); |
| 544 } | 551 } |
| 545 List<ir.Primitive> values = node.elements.nodes.mapToList(visit); | 552 List<ir.Primitive> values = node.elements.nodes.mapToList(visit); |
| 546 InterfaceType type = elements.getType(node); | 553 InterfaceType type = elements.getType(node); |
| 547 return irBuilder.buildListLiteral(type, values); | 554 return irBuilder.buildListLiteral(type, values); |
| 548 } | 555 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 | 599 |
| 593 // ## Sends ## | 600 // ## Sends ## |
| 594 @override | 601 @override |
| 595 ir.Primitive visitAssert(ast.Send node, ast.Node condition, _) { | 602 ir.Primitive visitAssert(ast.Send node, ast.Node condition, _) { |
| 596 assert(irBuilder.isOpen); | 603 assert(irBuilder.isOpen); |
| 597 if (compiler.enableUserAssertions) { | 604 if (compiler.enableUserAssertions) { |
| 598 return giveup(node, 'assert in checked mode not implemented'); | 605 return giveup(node, 'assert in checked mode not implemented'); |
| 599 } else { | 606 } else { |
| 600 // The call to assert and its argument expression must be ignored | 607 // The call to assert and its argument expression must be ignored |
| 601 // in production mode. | 608 // in production mode. |
| 602 // Assertions can only occur in expression statements, so no value needs | 609 // Assertions can onl)y occur in expression statements, so no value needs |
| 603 // to be returned. | 610 // to be returned. |
| 604 return null; | 611 return null; |
| 605 } | 612 } |
| 606 } | 613 } |
| 607 | 614 |
| 608 ir.Primitive visitNamedArgument(ast.NamedArgument node) { | 615 ir.Primitive visitNamedArgument(ast.NamedArgument node) { |
| 609 assert(irBuilder.isOpen); | 616 assert(irBuilder.isOpen); |
| 610 return visit(node.expression); | 617 return visit(node.expression); |
| 611 } | 618 } |
| 612 | 619 |
| 613 @override | 620 @override |
| 614 ir.Primitive visitExpressionInvoke(ast.Send node, | 621 ir.Primitive visitExpressionInvoke(ast.Send node, |
| 615 ast.Node expression, | 622 ast.Node expression, |
| 616 ast.NodeList arguments, | 623 ast.NodeList argumentsNode, |
| 617 Selector selector, _) { | 624 Selector selector, _) { |
| 618 ir.Primitive receiver = visit(expression); | 625 ir.Primitive receiver = visit(expression); |
| 619 List<ir.Primitive> arguments = node.arguments.mapToList(visit); | 626 List<ir.Primitive> arguments = node.arguments.mapToList(visit); |
| 620 arguments = normalizeDynamicArguments(selector.callStructure, arguments); | 627 arguments = normalizeDynamicArguments(selector.callStructure, arguments); |
| 621 return irBuilder.buildCallInvocation( | 628 return irBuilder.buildCallInvocation( |
| 622 receiver, selector.callStructure, arguments); | 629 receiver, selector.callStructure, arguments, |
| 630 sourceInformation: |
| 631 sourceInformationBuilder.buildCall(node, argumentsNode)); |
| 623 } | 632 } |
| 624 | 633 |
| 625 /// Returns `true` if [node] is a super call. | 634 /// Returns `true` if [node] is a super call. |
| 626 // TODO(johnniwinther): Remove the need for this. | 635 // TODO(johnniwinther): Remove the need for this. |
| 627 bool isSuperCall(ast.Send node) { | 636 bool isSuperCall(ast.Send node) { |
| 628 return node != null && node.receiver != null && node.receiver.isSuper(); | 637 return node != null && node.receiver != null && node.receiver.isSuper(); |
| 629 } | 638 } |
| 630 | 639 |
| 631 @override | 640 @override |
| 632 ir.Primitive handleConstantGet( | 641 ir.Primitive handleConstantGet( |
| 633 ast.Node node, | 642 ast.Node node, |
| 634 ConstantExpression constant, _) { | 643 ConstantExpression constant, _) { |
| 635 return buildConstantExpression(constant); | 644 return buildConstantExpression(constant, |
| 645 sourceInformationBuilder.buildGet(node)); |
| 636 } | 646 } |
| 637 | 647 |
| 638 /// If [node] is null, returns this. | 648 /// If [node] is null, returns this. |
| 639 /// Otherwise visits [node] and returns the result. | 649 /// Otherwise visits [node] and returns the result. |
| 640 ir.Primitive translateReceiver(ast.Expression node) { | 650 ir.Primitive translateReceiver(ast.Expression node) { |
| 641 return node != null ? visit(node) : irBuilder.buildThis(); | 651 return node != null ? visit(node) : irBuilder.buildThis(); |
| 642 } | 652 } |
| 643 | 653 |
| 644 @override | 654 @override |
| 645 ir.Primitive handleDynamicGet( | 655 ir.Primitive handleDynamicGet( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 664 target, | 674 target, |
| 665 nested(() => irBuilder.buildDynamicGet( | 675 nested(() => irBuilder.buildDynamicGet( |
| 666 target, selector, elements.getTypeMask(node)))); | 676 target, selector, elements.getTypeMask(node)))); |
| 667 } | 677 } |
| 668 | 678 |
| 669 @override | 679 @override |
| 670 ir.Primitive visitDynamicTypeLiteralGet( | 680 ir.Primitive visitDynamicTypeLiteralGet( |
| 671 ast.Send node, | 681 ast.Send node, |
| 672 ConstantExpression constant, | 682 ConstantExpression constant, |
| 673 _) { | 683 _) { |
| 674 return buildConstantExpression(constant); | 684 return buildConstantExpression(constant, |
| 685 sourceInformationBuilder.buildGet(node)); |
| 675 } | 686 } |
| 676 | 687 |
| 677 @override | 688 @override |
| 678 ir.Primitive visitLocalVariableGet( | 689 ir.Primitive visitLocalVariableGet( |
| 679 ast.Send node, | 690 ast.Send node, |
| 680 LocalVariableElement element, | 691 LocalVariableElement element, |
| 681 _) { | 692 _) { |
| 682 return element.isConst | 693 return element.isConst |
| 683 ? irBuilder.buildConstant(getConstantForVariable(element)) | 694 ? irBuilder.buildConstant(getConstantForVariable(element), |
| 695 sourceInformation: sourceInformationBuilder.buildGet(node)) |
| 684 : irBuilder.buildLocalVariableGet(element); | 696 : irBuilder.buildLocalVariableGet(element); |
| 685 } | 697 } |
| 686 | 698 |
| 687 @override | 699 @override |
| 688 ir.Primitive handleLocalGet( | 700 ir.Primitive handleLocalGet( |
| 689 ast.Send node, | 701 ast.Send node, |
| 690 LocalElement element, | 702 LocalElement element, |
| 691 _) { | 703 _) { |
| 692 return irBuilder.buildLocalVariableGet(element); | 704 return irBuilder.buildLocalVariableGet(element); |
| 693 } | 705 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 710 return giveup(node, 'handleStaticFunctionGet: foreign: $function'); | 722 return giveup(node, 'handleStaticFunctionGet: foreign: $function'); |
| 711 } | 723 } |
| 712 return irBuilder.buildStaticFunctionGet(function); | 724 return irBuilder.buildStaticFunctionGet(function); |
| 713 } | 725 } |
| 714 | 726 |
| 715 @override | 727 @override |
| 716 ir.Primitive handleStaticGetterGet( | 728 ir.Primitive handleStaticGetterGet( |
| 717 ast.Send node, | 729 ast.Send node, |
| 718 FunctionElement getter, | 730 FunctionElement getter, |
| 719 _) { | 731 _) { |
| 720 return irBuilder.buildStaticGetterGet(getter); | 732 return irBuilder.buildStaticGetterGet( |
| 733 getter, sourceInformationBuilder.buildGet(node)); |
| 721 } | 734 } |
| 722 | 735 |
| 723 @override | 736 @override |
| 724 ir.Primitive visitSuperFieldGet( | 737 ir.Primitive visitSuperFieldGet( |
| 725 ast.Send node, | 738 ast.Send node, |
| 726 FieldElement field, | 739 FieldElement field, |
| 727 _) { | 740 _) { |
| 728 return irBuilder.buildSuperFieldGet(field); | 741 return irBuilder.buildSuperFieldGet(field); |
| 729 } | 742 } |
| 730 | 743 |
| 731 @override | 744 @override |
| 732 ir.Primitive visitSuperGetterGet( | 745 ir.Primitive visitSuperGetterGet( |
| 733 ast.Send node, | 746 ast.Send node, |
| 734 FunctionElement getter, | 747 FunctionElement getter, |
| 735 _) { | 748 _) { |
| 736 return irBuilder.buildSuperGetterGet(getter); | 749 return irBuilder.buildSuperGetterGet( |
| 750 getter, sourceInformationBuilder.buildGet(node)); |
| 737 } | 751 } |
| 738 | 752 |
| 739 @override | 753 @override |
| 740 ir.Primitive visitSuperMethodGet( | 754 ir.Primitive visitSuperMethodGet( |
| 741 ast.Send node, | 755 ast.Send node, |
| 742 MethodElement method, | 756 MethodElement method, |
| 743 _) { | 757 _) { |
| 744 return irBuilder.buildSuperMethodGet(method); | 758 return irBuilder.buildSuperMethodGet(method); |
| 745 } | 759 } |
| 746 | 760 |
| 747 @override | 761 @override |
| 748 ir.Primitive visitUnresolvedSuperGet( | 762 ir.Primitive visitUnresolvedSuperGet( |
| 749 ast.Send node, | 763 ast.Send node, |
| 750 Element element, _) { | 764 Element element, _) { |
| 751 return buildInstanceNoSuchMethod( | 765 return buildInstanceNoSuchMethod( |
| 752 elements.getSelector(node), elements.getTypeMask(node), []); | 766 elements.getSelector(node), elements.getTypeMask(node), []); |
| 753 } | 767 } |
| 754 | 768 |
| 755 @override | 769 @override |
| 756 ir.Primitive visitThisGet(ast.Identifier node, _) { | 770 ir.Primitive visitThisGet(ast.Identifier node, _) { |
| 757 if (irBuilder.state.thisParameter == null) { | 771 if (irBuilder.state.thisParameter == null) { |
| 758 // TODO(asgerf,johnniwinther): Should be in a visitInvalidThis method. | 772 // TODO(asgerf,johnniwinther): Should be in a visitInvalidThis method. |
| 759 // 'this' in static context. Just translate to null. | 773 // 'this' in static context. Just translate to null. |
| 760 assert(compiler.compilationFailed); | 774 assert(compiler.compilationFailed); |
| 761 return irBuilder.buildNullConstant(); | 775 return irBuilder.buildNullConstant(); |
| 762 } | 776 } |
| 763 return irBuilder.buildThis(); | 777 return irBuilder.buildThis(); |
| 764 } | 778 } |
| 765 | 779 |
| 766 ir.Primitive translateTypeVariableTypeLiteral(TypeVariableElement element) { | 780 ir.Primitive translateTypeVariableTypeLiteral( |
| 767 return irBuilder.buildReifyTypeVariable(element.type); | 781 TypeVariableElement element, |
| 782 SourceInformation sourceInformation) { |
| 783 return irBuilder.buildReifyTypeVariable(element.type, sourceInformation); |
| 768 } | 784 } |
| 769 | 785 |
| 770 @override | 786 @override |
| 771 ir.Primitive visitTypeVariableTypeLiteralGet(ast.Send node, | 787 ir.Primitive visitTypeVariableTypeLiteralGet(ast.Send node, |
| 772 TypeVariableElement element, _) { | 788 TypeVariableElement element, _) { |
| 773 return translateTypeVariableTypeLiteral(element); | 789 return translateTypeVariableTypeLiteral(element, |
| 790 sourceInformationBuilder.buildGet(node)); |
| 774 } | 791 } |
| 775 | 792 |
| 776 ir.Primitive translateLogicalOperator(ast.Expression left, | 793 ir.Primitive translateLogicalOperator(ast.Expression left, |
| 777 ast.Expression right, | 794 ast.Expression right, |
| 778 {bool isLazyOr}) { | 795 {bool isLazyOr}) { |
| 779 ir.Primitive leftValue = visit(left); | 796 ir.Primitive leftValue = visit(left); |
| 780 | 797 |
| 781 ir.Primitive buildRightValue(IrBuilder rightBuilder) { | 798 ir.Primitive buildRightValue(IrBuilder rightBuilder) { |
| 782 return withBuilder(rightBuilder, () => visit(right)); | 799 return withBuilder(rightBuilder, () => visit(right)); |
| 783 } | 800 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 | 852 |
| 836 ir.Primitive translateBinary(ast.Send node, | 853 ir.Primitive translateBinary(ast.Send node, |
| 837 ast.Node left, | 854 ast.Node left, |
| 838 op.BinaryOperator operator, | 855 op.BinaryOperator operator, |
| 839 ast.Node right) { | 856 ast.Node right) { |
| 840 Selector selector = new Selector.binaryOperator(operator.selectorName); | 857 Selector selector = new Selector.binaryOperator(operator.selectorName); |
| 841 ir.Primitive receiver = visit(left); | 858 ir.Primitive receiver = visit(left); |
| 842 List<ir.Primitive> arguments = <ir.Primitive>[visit(right)]; | 859 List<ir.Primitive> arguments = <ir.Primitive>[visit(right)]; |
| 843 arguments = normalizeDynamicArguments(selector.callStructure, arguments); | 860 arguments = normalizeDynamicArguments(selector.callStructure, arguments); |
| 844 return irBuilder.buildDynamicInvocation( | 861 return irBuilder.buildDynamicInvocation( |
| 845 receiver, selector, elements.getTypeMask(node), arguments); | 862 receiver, selector, elements.getTypeMask(node), arguments, |
| 863 sourceInformation: |
| 864 sourceInformationBuilder.buildCall(node, node.selector)); |
| 846 } | 865 } |
| 847 | 866 |
| 848 @override | 867 @override |
| 849 ir.Primitive visitBinary(ast.Send node, | 868 ir.Primitive visitBinary(ast.Send node, |
| 850 ast.Node left, | 869 ast.Node left, |
| 851 op.BinaryOperator operator, | 870 op.BinaryOperator operator, |
| 852 ast.Node right, _) { | 871 ast.Node right, _) { |
| 853 return translateBinary(node, left, operator, right); | 872 return translateBinary(node, left, operator, right); |
| 854 } | 873 } |
| 855 | 874 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 // semantic correlation between arguments and invocation. | 991 // semantic correlation between arguments and invocation. |
| 973 List<ir.Primitive> translateStaticArguments(ast.NodeList nodeList, | 992 List<ir.Primitive> translateStaticArguments(ast.NodeList nodeList, |
| 974 Element element, | 993 Element element, |
| 975 CallStructure callStructure) { | 994 CallStructure callStructure) { |
| 976 List<ir.Primitive> arguments = nodeList.nodes.mapToList(visit); | 995 List<ir.Primitive> arguments = nodeList.nodes.mapToList(visit); |
| 977 return normalizeStaticArguments(callStructure, element, arguments); | 996 return normalizeStaticArguments(callStructure, element, arguments); |
| 978 } | 997 } |
| 979 | 998 |
| 980 ir.Primitive translateCallInvoke(ir.Primitive target, | 999 ir.Primitive translateCallInvoke(ir.Primitive target, |
| 981 ast.NodeList arguments, | 1000 ast.NodeList arguments, |
| 982 CallStructure callStructure) { | 1001 CallStructure callStructure, |
| 1002 SourceInformation sourceInformation) { |
| 983 | 1003 |
| 984 return irBuilder.buildCallInvocation(target, callStructure, | 1004 return irBuilder.buildCallInvocation(target, callStructure, |
| 985 translateDynamicArguments(arguments, callStructure)); | 1005 translateDynamicArguments(arguments, callStructure), |
| 1006 sourceInformation: sourceInformation); |
| 986 } | 1007 } |
| 987 | 1008 |
| 988 @override | 1009 @override |
| 989 ir.Primitive handleConstantInvoke( | 1010 ir.Primitive handleConstantInvoke( |
| 990 ast.Send node, | 1011 ast.Send node, |
| 991 ConstantExpression constant, | 1012 ConstantExpression constant, |
| 992 ast.NodeList arguments, | 1013 ast.NodeList arguments, |
| 993 CallStructure callStructure, | 1014 CallStructure callStructure, |
| 994 _) { | 1015 _) { |
| 995 ir.Primitive target = buildConstantExpression(constant); | 1016 ir.Primitive target = buildConstantExpression(constant, |
| 996 return translateCallInvoke(target, arguments, callStructure); | 1017 sourceInformationBuilder.buildGet(node)); |
| 1018 return translateCallInvoke(target, arguments, callStructure, |
| 1019 sourceInformationBuilder.buildCall(node, arguments)); |
| 997 } | 1020 } |
| 998 | 1021 |
| 999 @override | 1022 @override |
| 1000 ir.Primitive handleDynamicInvoke( | 1023 ir.Primitive handleDynamicInvoke( |
| 1001 ast.Send node, | 1024 ast.Send node, |
| 1002 ast.Node receiver, | 1025 ast.Node receiver, |
| 1003 ast.NodeList arguments, | 1026 ast.NodeList arguments, |
| 1004 Selector selector, | 1027 Selector selector, |
| 1005 _) { | 1028 _) { |
| 1006 return irBuilder.buildDynamicInvocation( | 1029 return irBuilder.buildDynamicInvocation( |
| 1007 translateReceiver(receiver), selector, elements.getTypeMask(node), | 1030 translateReceiver(receiver), selector, elements.getTypeMask(node), |
| 1008 translateDynamicArguments(arguments, selector.callStructure)); | 1031 translateDynamicArguments(arguments, selector.callStructure), |
| 1032 sourceInformation: |
| 1033 sourceInformationBuilder.buildCall(node, node.selector)); |
| 1009 } | 1034 } |
| 1010 | 1035 |
| 1011 @override | 1036 @override |
| 1012 ir.Primitive visitIfNotNullDynamicPropertyInvoke( | 1037 ir.Primitive visitIfNotNullDynamicPropertyInvoke( |
| 1013 ast.Send node, | 1038 ast.Send node, |
| 1014 ast.Node receiver, | 1039 ast.Node receiver, |
| 1015 ast.NodeList arguments, | 1040 ast.NodeList arguments, |
| 1016 Selector selector, | 1041 Selector selector, |
| 1017 _) { | 1042 _) { |
| 1018 ir.Primitive target = visit(receiver); | 1043 ir.Primitive target = visit(receiver); |
| 1019 return irBuilder.buildIfNotNullSend( | 1044 return irBuilder.buildIfNotNullSend( |
| 1020 target, | 1045 target, |
| 1021 nested(() => irBuilder.buildDynamicInvocation( | 1046 nested(() => irBuilder.buildDynamicInvocation( |
| 1022 target, selector, elements.getTypeMask(node), | 1047 target, selector, elements.getTypeMask(node), |
| 1023 translateDynamicArguments(arguments, selector.callStructure)))); | 1048 translateDynamicArguments(arguments, selector.callStructure)))); |
| 1024 } | 1049 } |
| 1025 | 1050 |
| 1026 ir.Primitive handleLocalInvoke( | 1051 ir.Primitive handleLocalInvoke( |
| 1027 ast.Send node, | 1052 ast.Send node, |
| 1028 LocalElement element, | 1053 LocalElement element, |
| 1029 ast.NodeList arguments, | 1054 ast.NodeList arguments, |
| 1030 CallStructure callStructure, | 1055 CallStructure callStructure, |
| 1031 _) { | 1056 _) { |
| 1032 return irBuilder.buildLocalVariableInvocation(element, callStructure, | 1057 return irBuilder.buildLocalVariableInvocation(element, callStructure, |
| 1033 translateDynamicArguments(arguments, callStructure)); | 1058 translateDynamicArguments(arguments, callStructure), |
| 1059 callSourceInformation: |
| 1060 sourceInformationBuilder.buildCall(node, arguments)); |
| 1034 } | 1061 } |
| 1035 | 1062 |
| 1036 @override | 1063 @override |
| 1037 ir.Primitive visitLocalFunctionInvoke( | 1064 ir.Primitive visitLocalFunctionInvoke( |
| 1038 ast.Send node, | 1065 ast.Send node, |
| 1039 LocalFunctionElement function, | 1066 LocalFunctionElement function, |
| 1040 ast.NodeList arguments, | 1067 ast.NodeList arguments, |
| 1041 CallStructure callStructure, | 1068 CallStructure callStructure, |
| 1042 _) { | 1069 _) { |
| 1043 return irBuilder.buildLocalFunctionInvocation(function, callStructure, | 1070 return irBuilder.buildLocalFunctionInvocation(function, callStructure, |
| 1044 translateDynamicArguments(arguments, callStructure)); | 1071 translateDynamicArguments(arguments, callStructure), |
| 1072 sourceInformationBuilder.buildCall(node, arguments)); |
| 1045 } | 1073 } |
| 1046 | 1074 |
| 1047 @override | 1075 @override |
| 1048 ir.Primitive handleStaticFieldGet(ast.Send node, FieldElement field, _) { | 1076 ir.Primitive handleStaticFieldGet(ast.Send node, FieldElement field, _) { |
| 1049 return buildStaticFieldGet(field, sourceInformationBuilder.buildGet(node)); | 1077 return buildStaticFieldGet(field, sourceInformationBuilder.buildGet(node)); |
| 1050 } | 1078 } |
| 1051 | 1079 |
| 1052 @override | 1080 @override |
| 1053 ir.Primitive handleStaticFieldInvoke( | 1081 ir.Primitive handleStaticFieldInvoke( |
| 1054 ast.Send node, | 1082 ast.Send node, |
| 1055 FieldElement field, | 1083 FieldElement field, |
| 1056 ast.NodeList arguments, | 1084 ast.NodeList arguments, |
| 1057 CallStructure callStructure, | 1085 CallStructure callStructure, |
| 1058 _) { | 1086 _) { |
| 1059 SourceInformation src = sourceInformationBuilder.buildGet(node); | 1087 SourceInformation src = sourceInformationBuilder.buildGet(node); |
| 1060 ir.Primitive target = buildStaticFieldGet(field, src); | 1088 ir.Primitive target = buildStaticFieldGet(field, src); |
| 1061 return irBuilder.buildCallInvocation(target, | 1089 return irBuilder.buildCallInvocation(target, |
| 1062 callStructure, | 1090 callStructure, |
| 1063 translateDynamicArguments(arguments, callStructure)); | 1091 translateDynamicArguments(arguments, callStructure), |
| 1092 sourceInformation: |
| 1093 sourceInformationBuilder.buildCall(node, arguments)); |
| 1064 } | 1094 } |
| 1065 | 1095 |
| 1066 @override | 1096 @override |
| 1067 ir.Primitive handleStaticFunctionInvoke( | 1097 ir.Primitive handleStaticFunctionInvoke( |
| 1068 ast.Send node, | 1098 ast.Send node, |
| 1069 MethodElement function, | 1099 MethodElement function, |
| 1070 ast.NodeList arguments, | 1100 ast.NodeList arguments, |
| 1071 CallStructure callStructure, | 1101 CallStructure callStructure, |
| 1072 _); | 1102 _); |
| 1073 | 1103 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1085 @override | 1115 @override |
| 1086 ir.Primitive handleStaticGetterInvoke( | 1116 ir.Primitive handleStaticGetterInvoke( |
| 1087 ast.Send node, | 1117 ast.Send node, |
| 1088 FunctionElement getter, | 1118 FunctionElement getter, |
| 1089 ast.NodeList arguments, | 1119 ast.NodeList arguments, |
| 1090 CallStructure callStructure, | 1120 CallStructure callStructure, |
| 1091 _) { | 1121 _) { |
| 1092 if (compiler.backend.isForeign(getter)) { | 1122 if (compiler.backend.isForeign(getter)) { |
| 1093 return giveup(node, 'handleStaticGetterInvoke: foreign: $getter'); | 1123 return giveup(node, 'handleStaticGetterInvoke: foreign: $getter'); |
| 1094 } | 1124 } |
| 1095 ir.Primitive target = irBuilder.buildStaticGetterGet(getter); | 1125 ir.Primitive target = irBuilder.buildStaticGetterGet( |
| 1126 getter, sourceInformationBuilder.buildGet(node)); |
| 1096 return irBuilder.buildCallInvocation(target, | 1127 return irBuilder.buildCallInvocation(target, |
| 1097 callStructure, | 1128 callStructure, |
| 1098 translateDynamicArguments(arguments, callStructure)); | 1129 translateDynamicArguments(arguments, callStructure), |
| 1130 sourceInformation: |
| 1131 sourceInformationBuilder.buildCall(node, arguments)); |
| 1099 } | 1132 } |
| 1100 | 1133 |
| 1101 @override | 1134 @override |
| 1102 ir.Primitive visitSuperFieldInvoke( | 1135 ir.Primitive visitSuperFieldInvoke( |
| 1103 ast.Send node, | 1136 ast.Send node, |
| 1104 FieldElement field, | 1137 FieldElement field, |
| 1105 ast.NodeList arguments, | 1138 ast.NodeList arguments, |
| 1106 CallStructure callStructure, | 1139 CallStructure callStructure, |
| 1107 _) { | 1140 _) { |
| 1108 ir.Primitive target = irBuilder.buildSuperFieldGet(field); | 1141 ir.Primitive target = irBuilder.buildSuperFieldGet(field); |
| 1109 return irBuilder.buildCallInvocation(target, | 1142 return irBuilder.buildCallInvocation(target, |
| 1110 callStructure, | 1143 callStructure, |
| 1111 translateDynamicArguments(arguments, callStructure)); | 1144 translateDynamicArguments(arguments, callStructure), |
| 1145 sourceInformation: |
| 1146 sourceInformationBuilder.buildCall(node, arguments)); |
| 1112 } | 1147 } |
| 1113 | 1148 |
| 1114 @override | 1149 @override |
| 1115 ir.Primitive visitSuperGetterInvoke( | 1150 ir.Primitive visitSuperGetterInvoke( |
| 1116 ast.Send node, | 1151 ast.Send node, |
| 1117 FunctionElement getter, | 1152 FunctionElement getter, |
| 1118 ast.NodeList arguments, | 1153 ast.NodeList arguments, |
| 1119 CallStructure callStructure, | 1154 CallStructure callStructure, |
| 1120 _) { | 1155 _) { |
| 1121 ir.Primitive target = irBuilder.buildSuperGetterGet(getter); | 1156 ir.Primitive target = irBuilder.buildSuperGetterGet( |
| 1157 getter, sourceInformationBuilder.buildGet(node)); |
| 1122 return irBuilder.buildCallInvocation(target, | 1158 return irBuilder.buildCallInvocation(target, |
| 1123 callStructure, | 1159 callStructure, |
| 1124 translateDynamicArguments(arguments, callStructure)); | 1160 translateDynamicArguments(arguments, callStructure), |
| 1161 sourceInformation: |
| 1162 sourceInformationBuilder.buildCall(node, arguments)); |
| 1125 } | 1163 } |
| 1126 | 1164 |
| 1127 @override | 1165 @override |
| 1128 ir.Primitive visitSuperMethodInvoke( | 1166 ir.Primitive visitSuperMethodInvoke( |
| 1129 ast.Send node, | 1167 ast.Send node, |
| 1130 MethodElement method, | 1168 MethodElement method, |
| 1131 ast.NodeList arguments, | 1169 ast.NodeList arguments, |
| 1132 CallStructure callStructure, | 1170 CallStructure callStructure, |
| 1133 _) { | 1171 _) { |
| 1134 return irBuilder.buildSuperMethodInvocation(method, callStructure, | 1172 return irBuilder.buildSuperMethodInvocation(method, callStructure, |
| 1135 translateDynamicArguments(arguments, callStructure)); | 1173 translateDynamicArguments(arguments, callStructure), |
| 1174 sourceInformation: |
| 1175 sourceInformationBuilder.buildCall(node, node.selector)); |
| 1136 } | 1176 } |
| 1137 | 1177 |
| 1138 @override | 1178 @override |
| 1139 ir.Primitive visitSuperMethodIncompatibleInvoke( | 1179 ir.Primitive visitSuperMethodIncompatibleInvoke( |
| 1140 ast.Send node, | 1180 ast.Send node, |
| 1141 MethodElement method, | 1181 MethodElement method, |
| 1142 ast.NodeList arguments, | 1182 ast.NodeList arguments, |
| 1143 CallStructure callStructure, _) { | 1183 CallStructure callStructure, _) { |
| 1144 return buildInstanceNoSuchMethod( | 1184 return buildInstanceNoSuchMethod( |
| 1145 elements.getSelector(node), | 1185 elements.getSelector(node), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1158 elements.getTypeMask(node), | 1198 elements.getTypeMask(node), |
| 1159 translateDynamicArguments(arguments, selector.callStructure)); | 1199 translateDynamicArguments(arguments, selector.callStructure)); |
| 1160 } | 1200 } |
| 1161 | 1201 |
| 1162 @override | 1202 @override |
| 1163 ir.Primitive visitThisInvoke( | 1203 ir.Primitive visitThisInvoke( |
| 1164 ast.Send node, | 1204 ast.Send node, |
| 1165 ast.NodeList arguments, | 1205 ast.NodeList arguments, |
| 1166 CallStructure callStructure, | 1206 CallStructure callStructure, |
| 1167 _) { | 1207 _) { |
| 1168 return translateCallInvoke(irBuilder.buildThis(), arguments, callStructure); | 1208 return translateCallInvoke( |
| 1209 irBuilder.buildThis(), |
| 1210 arguments, |
| 1211 callStructure, |
| 1212 sourceInformationBuilder.buildCall(node, arguments)); |
| 1169 } | 1213 } |
| 1170 | 1214 |
| 1171 @override | 1215 @override |
| 1172 ir.Primitive visitTypeVariableTypeLiteralInvoke( | 1216 ir.Primitive visitTypeVariableTypeLiteralInvoke( |
| 1173 ast.Send node, | 1217 ast.Send node, |
| 1174 TypeVariableElement element, | 1218 TypeVariableElement element, |
| 1175 ast.NodeList arguments, | 1219 ast.NodeList arguments, |
| 1176 CallStructure callStructure, | 1220 CallStructure callStructure, |
| 1177 _) { | 1221 _) { |
| 1178 return translateCallInvoke( | 1222 return translateCallInvoke( |
| 1179 translateTypeVariableTypeLiteral(element), | 1223 translateTypeVariableTypeLiteral( |
| 1224 element, sourceInformationBuilder.buildGet(node)), |
| 1180 arguments, | 1225 arguments, |
| 1181 callStructure); | 1226 callStructure, |
| 1227 sourceInformationBuilder.buildCall(node, arguments)); |
| 1182 } | 1228 } |
| 1183 | 1229 |
| 1184 @override | 1230 @override |
| 1185 ir.Primitive visitIndexSet( | 1231 ir.Primitive visitIndexSet( |
| 1186 ast.SendSet node, | 1232 ast.SendSet node, |
| 1187 ast.Node receiver, | 1233 ast.Node receiver, |
| 1188 ast.Node index, | 1234 ast.Node index, |
| 1189 ast.Node rhs, | 1235 ast.Node rhs, |
| 1190 _) { | 1236 _) { |
| 1191 return irBuilder.buildDynamicIndexSet( | 1237 return irBuilder.buildDynamicIndexSet( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 return irBuilder.buildStaticSetterSet(setter, visit(rhs)); | 1366 return irBuilder.buildStaticSetterSet(setter, visit(rhs)); |
| 1321 } | 1367 } |
| 1322 | 1368 |
| 1323 @override | 1369 @override |
| 1324 ir.Primitive handleTypeLiteralConstantCompounds( | 1370 ir.Primitive handleTypeLiteralConstantCompounds( |
| 1325 ast.SendSet node, | 1371 ast.SendSet node, |
| 1326 ConstantExpression constant, | 1372 ConstantExpression constant, |
| 1327 CompoundRhs rhs, | 1373 CompoundRhs rhs, |
| 1328 arg) { | 1374 arg) { |
| 1329 return translateCompounds( | 1375 return translateCompounds( |
| 1330 getValue: () => buildConstantExpression(constant), | 1376 getValue: () { |
| 1377 return buildConstantExpression(constant, |
| 1378 sourceInformationBuilder.buildGet(node)); |
| 1379 }, |
| 1331 rhs: rhs, | 1380 rhs: rhs, |
| 1332 setValue: (value) {}, // The binary operator will throw before this. | 1381 setValue: (value) {}, // The binary operator will throw before this. |
| 1333 operatorTypeMask: elements.getOperatorTypeMaskInComplexSendSet(node)); | 1382 operatorTypeMask: elements.getOperatorTypeMaskInComplexSendSet(node)); |
| 1334 } | 1383 } |
| 1335 | 1384 |
| 1336 @override | 1385 @override |
| 1337 ir.Primitive handleDynamicCompounds( | 1386 ir.Primitive handleDynamicCompounds( |
| 1338 ast.SendSet node, | 1387 ast.SendSet node, |
| 1339 ast.Node receiver, | 1388 ast.Node receiver, |
| 1340 CompoundRhs rhs, | 1389 CompoundRhs rhs, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 CompoundSetter setterKind, | 1461 CompoundSetter setterKind, |
| 1413 CompoundRhs rhs, | 1462 CompoundRhs rhs, |
| 1414 arg) { | 1463 arg) { |
| 1415 return translateCompounds( | 1464 return translateCompounds( |
| 1416 getValue: () { | 1465 getValue: () { |
| 1417 switch (getterKind) { | 1466 switch (getterKind) { |
| 1418 case CompoundGetter.FIELD: | 1467 case CompoundGetter.FIELD: |
| 1419 SourceInformation src = sourceInformationBuilder.buildGet(node); | 1468 SourceInformation src = sourceInformationBuilder.buildGet(node); |
| 1420 return irBuilder.buildStaticFieldGet(getter, src); | 1469 return irBuilder.buildStaticFieldGet(getter, src); |
| 1421 case CompoundGetter.GETTER: | 1470 case CompoundGetter.GETTER: |
| 1422 return irBuilder.buildStaticGetterGet(getter); | 1471 return irBuilder.buildStaticGetterGet( |
| 1472 getter, sourceInformationBuilder.buildGet(node)); |
| 1423 case CompoundGetter.METHOD: | 1473 case CompoundGetter.METHOD: |
| 1424 return irBuilder.buildStaticFunctionGet(getter); | 1474 return irBuilder.buildStaticFunctionGet(getter); |
| 1425 case CompoundGetter.UNRESOLVED: | 1475 case CompoundGetter.UNRESOLVED: |
| 1426 return buildStaticNoSuchGetter(getter); | 1476 return buildStaticNoSuchGetter(getter); |
| 1427 } | 1477 } |
| 1428 }, | 1478 }, |
| 1429 rhs: rhs, | 1479 rhs: rhs, |
| 1430 setValue: (ir.Primitive result) { | 1480 setValue: (ir.Primitive result) { |
| 1431 switch (setterKind) { | 1481 switch (setterKind) { |
| 1432 case CompoundSetter.FIELD: | 1482 case CompoundSetter.FIELD: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 Element setter, | 1516 Element setter, |
| 1467 CompoundSetter setterKind, | 1517 CompoundSetter setterKind, |
| 1468 CompoundRhs rhs, | 1518 CompoundRhs rhs, |
| 1469 arg) { | 1519 arg) { |
| 1470 return translateCompounds( | 1520 return translateCompounds( |
| 1471 getValue: () { | 1521 getValue: () { |
| 1472 switch (getterKind) { | 1522 switch (getterKind) { |
| 1473 case CompoundGetter.FIELD: | 1523 case CompoundGetter.FIELD: |
| 1474 return irBuilder.buildSuperFieldGet(getter); | 1524 return irBuilder.buildSuperFieldGet(getter); |
| 1475 case CompoundGetter.GETTER: | 1525 case CompoundGetter.GETTER: |
| 1476 return irBuilder.buildSuperGetterGet(getter); | 1526 return irBuilder.buildSuperGetterGet( |
| 1527 getter, sourceInformationBuilder.buildGet(node)); |
| 1477 case CompoundGetter.METHOD: | 1528 case CompoundGetter.METHOD: |
| 1478 return irBuilder.buildSuperMethodGet(getter); | 1529 return irBuilder.buildSuperMethodGet(getter); |
| 1479 case CompoundGetter.UNRESOLVED: | 1530 case CompoundGetter.UNRESOLVED: |
| 1480 // TODO(johnniwinther): Ensure [getter] is not null. | 1531 // TODO(johnniwinther): Ensure [getter] is not null. |
| 1481 return buildSuperNoSuchGetter( | 1532 return buildSuperNoSuchGetter( |
| 1482 getter != null ? getter : setter, | 1533 getter != null ? getter : setter, |
| 1483 elements.getGetterTypeMaskInComplexSendSet(node)); | 1534 elements.getGetterTypeMaskInComplexSendSet(node)); |
| 1484 } | 1535 } |
| 1485 }, | 1536 }, |
| 1486 rhs: rhs, | 1537 rhs: rhs, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1498 operatorTypeMask: elements.getOperatorTypeMaskInComplexSendSet(node)); | 1549 operatorTypeMask: elements.getOperatorTypeMaskInComplexSendSet(node)); |
| 1499 } | 1550 } |
| 1500 | 1551 |
| 1501 @override | 1552 @override |
| 1502 ir.Primitive handleTypeVariableTypeLiteralCompounds( | 1553 ir.Primitive handleTypeVariableTypeLiteralCompounds( |
| 1503 ast.SendSet node, | 1554 ast.SendSet node, |
| 1504 TypeVariableElement typeVariable, | 1555 TypeVariableElement typeVariable, |
| 1505 CompoundRhs rhs, | 1556 CompoundRhs rhs, |
| 1506 arg) { | 1557 arg) { |
| 1507 return translateCompounds( | 1558 return translateCompounds( |
| 1508 getValue: () => irBuilder.buildReifyTypeVariable(typeVariable.type), | 1559 getValue: () { |
| 1560 return irBuilder.buildReifyTypeVariable( |
| 1561 typeVariable.type, |
| 1562 sourceInformationBuilder.buildGet(node)); |
| 1563 }, |
| 1509 rhs: rhs, | 1564 rhs: rhs, |
| 1510 setValue: (value) {}, // The binary operator will throw before this. | 1565 setValue: (value) {}, // The binary operator will throw before this. |
| 1511 operatorTypeMask: elements.getOperatorTypeMaskInComplexSendSet(node)); | 1566 operatorTypeMask: elements.getOperatorTypeMaskInComplexSendSet(node)); |
| 1512 } | 1567 } |
| 1513 | 1568 |
| 1514 @override | 1569 @override |
| 1515 ir.Primitive handleIndexCompounds( | 1570 ir.Primitive handleIndexCompounds( |
| 1516 ast.SendSet node, | 1571 ast.SendSet node, |
| 1517 ast.Node receiver, | 1572 ast.Node receiver, |
| 1518 ast.Node index, | 1573 ast.Node index, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1669 |
| 1615 ir.Primitive visitStringInterpolation(ast.StringInterpolation node) { | 1670 ir.Primitive visitStringInterpolation(ast.StringInterpolation node) { |
| 1616 assert(irBuilder.isOpen); | 1671 assert(irBuilder.isOpen); |
| 1617 List<ir.Primitive> parts = <ir.Primitive>[]; | 1672 List<ir.Primitive> parts = <ir.Primitive>[]; |
| 1618 buildStringParts(node, parts); | 1673 buildStringParts(node, parts); |
| 1619 return irBuilder.buildStringConcatenation(parts); | 1674 return irBuilder.buildStringConcatenation(parts); |
| 1620 } | 1675 } |
| 1621 | 1676 |
| 1622 ir.Primitive translateConstant(ast.Node node) { | 1677 ir.Primitive translateConstant(ast.Node node) { |
| 1623 assert(irBuilder.isOpen); | 1678 assert(irBuilder.isOpen); |
| 1624 return irBuilder.buildConstant(getConstantForNode(node)); | 1679 return irBuilder.buildConstant( |
| 1680 getConstantForNode(node), |
| 1681 sourceInformation: sourceInformationBuilder.buildGet(node)); |
| 1625 } | 1682 } |
| 1626 | 1683 |
| 1627 ir.Primitive visitThrow(ast.Throw node) { | 1684 ir.Primitive visitThrow(ast.Throw node) { |
| 1628 assert(irBuilder.isOpen); | 1685 assert(irBuilder.isOpen); |
| 1629 // This function is not called for throw expressions occurring as | 1686 // This function is not called for throw expressions occurring as |
| 1630 // statements. | 1687 // statements. |
| 1631 return irBuilder.buildNonTailThrow(visit(node.expression)); | 1688 return irBuilder.buildNonTailThrow(visit(node.expression)); |
| 1632 } | 1689 } |
| 1633 | 1690 |
| 1634 ir.Primitive buildStaticNoSuchMethod( | 1691 ir.Primitive buildStaticNoSuchMethod( |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 /// Builds the IR for creating an instance of the closure class corresponding | 2305 /// Builds the IR for creating an instance of the closure class corresponding |
| 2249 /// to the given nested function. | 2306 /// to the given nested function. |
| 2250 ClosureClassElement makeSubFunction(ast.FunctionExpression node) { | 2307 ClosureClassElement makeSubFunction(ast.FunctionExpression node) { |
| 2251 ClosureClassMap innerMap = | 2308 ClosureClassMap innerMap = |
| 2252 compiler.closureToClassMapper.getMappingForNestedFunction(node); | 2309 compiler.closureToClassMapper.getMappingForNestedFunction(node); |
| 2253 ClosureClassElement closureClass = innerMap.closureClassElement; | 2310 ClosureClassElement closureClass = innerMap.closureClassElement; |
| 2254 return closureClass; | 2311 return closureClass; |
| 2255 } | 2312 } |
| 2256 | 2313 |
| 2257 ir.Primitive visitFunctionExpression(ast.FunctionExpression node) { | 2314 ir.Primitive visitFunctionExpression(ast.FunctionExpression node) { |
| 2258 return irBuilder.buildFunctionExpression(makeSubFunction(node)); | 2315 return irBuilder.buildFunctionExpression(makeSubFunction(node), |
| 2316 sourceInformationBuilder.buildCreate(node)); |
| 2259 } | 2317 } |
| 2260 | 2318 |
| 2261 visitFunctionDeclaration(ast.FunctionDeclaration node) { | 2319 visitFunctionDeclaration(ast.FunctionDeclaration node) { |
| 2262 LocalFunctionElement element = elements[node.function]; | 2320 LocalFunctionElement element = elements[node.function]; |
| 2263 Object inner = makeSubFunction(node.function); | 2321 Object inner = makeSubFunction(node.function); |
| 2264 irBuilder.declareLocalFunction(element, inner); | 2322 irBuilder.declareLocalFunction(element, inner, |
| 2323 sourceInformationBuilder.buildCreate(node.function)); |
| 2265 } | 2324 } |
| 2266 | 2325 |
| 2267 Map mapValues(Map map, dynamic fn(dynamic)) { | 2326 Map mapValues(Map map, dynamic fn(dynamic)) { |
| 2268 Map result = {}; | 2327 Map result = {}; |
| 2269 map.forEach((key, value) { | 2328 map.forEach((key, value) { |
| 2270 result[key] = fn(value); | 2329 result[key] = fn(value); |
| 2271 }); | 2330 }); |
| 2272 return result; | 2331 return result; |
| 2273 } | 2332 } |
| 2274 | 2333 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 } | 2428 } |
| 2370 closureClassMap = | 2429 closureClassMap = |
| 2371 compiler.closureToClassMapper.computeClosureToClassMapping( | 2430 compiler.closureToClassMapper.computeClosureToClassMapping( |
| 2372 element, | 2431 element, |
| 2373 element.node, | 2432 element.node, |
| 2374 elements); | 2433 elements); |
| 2375 IrBuilder builder = getBuilderFor(element); | 2434 IrBuilder builder = getBuilderFor(element); |
| 2376 return withBuilder(builder, () { | 2435 return withBuilder(builder, () { |
| 2377 irBuilder.buildFunctionHeader(<Local>[]); | 2436 irBuilder.buildFunctionHeader(<Local>[]); |
| 2378 ir.Primitive initialValue = visit(element.initializer); | 2437 ir.Primitive initialValue = visit(element.initializer); |
| 2379 irBuilder.buildReturn(initialValue); | 2438 ast.VariableDefinitions node = element.node; |
| 2439 ast.SendSet sendSet = node.definitions.nodes.head; |
| 2440 irBuilder.buildReturn( |
| 2441 value: initialValue, |
| 2442 sourceInformation: |
| 2443 sourceInformationBuilder.buildReturn(sendSet.assignmentOperator)); |
| 2380 return irBuilder.makeFunctionDefinition(); | 2444 return irBuilder.makeFunctionDefinition(); |
| 2381 }); | 2445 }); |
| 2382 } | 2446 } |
| 2383 | 2447 |
| 2384 /// Make a visitor suitable for translating ASTs taken from [context]. | 2448 /// Make a visitor suitable for translating ASTs taken from [context]. |
| 2385 /// | 2449 /// |
| 2386 /// Every visitor can only be applied to nodes in one context, because | 2450 /// Every visitor can only be applied to nodes in one context, because |
| 2387 /// the [elements] field is specific to that context. | 2451 /// the [elements] field is specific to that context. |
| 2388 JsIrBuilderVisitor makeVisitorForContext(AstElement context) { | 2452 JsIrBuilderVisitor makeVisitorForContext(AstElement context) { |
| 2389 return new JsIrBuilderVisitor( | 2453 return new JsIrBuilderVisitor( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2494 List<ir.Primitive> instanceArguments = <ir.Primitive>[]; | 2558 List<ir.Primitive> instanceArguments = <ir.Primitive>[]; |
| 2495 classElement.forEachInstanceField((ClassElement c, FieldElement field) { | 2559 classElement.forEachInstanceField((ClassElement c, FieldElement field) { |
| 2496 ir.Primitive value = fieldValues[field]; | 2560 ir.Primitive value = fieldValues[field]; |
| 2497 if (value != null) { | 2561 if (value != null) { |
| 2498 instanceArguments.add(value); | 2562 instanceArguments.add(value); |
| 2499 } else { | 2563 } else { |
| 2500 assert(Elements.isNativeOrExtendsNative(c)); | 2564 assert(Elements.isNativeOrExtendsNative(c)); |
| 2501 // Native fields are initialized elsewhere. | 2565 // Native fields are initialized elsewhere. |
| 2502 } | 2566 } |
| 2503 }, includeSuperAndInjectedMembers: true); | 2567 }, includeSuperAndInjectedMembers: true); |
| 2568 |
| 2504 ir.Primitive instance = new ir.CreateInstance( | 2569 ir.Primitive instance = new ir.CreateInstance( |
| 2505 classElement, | 2570 classElement, |
| 2506 instanceArguments, | 2571 instanceArguments, |
| 2507 typeInformation); | 2572 typeInformation, |
| 2573 constructor.hasNode |
| 2574 ? sourceInformationBuilder.buildCreate(constructor.node) |
| 2575 // TODO(johnniwinther): Provide source information for creation |
| 2576 // through synthetic constructors. |
| 2577 : null); |
| 2508 irBuilder.add(new ir.LetPrim(instance)); | 2578 irBuilder.add(new ir.LetPrim(instance)); |
| 2509 | 2579 |
| 2510 // --- Call constructor bodies --- | 2580 // --- Call constructor bodies --- |
| 2511 for (ConstructorElement target in constructorList) { | 2581 for (ConstructorElement target in constructorList) { |
| 2512 ConstructorBodyElement bodyElement = getConstructorBody(target); | 2582 ConstructorBodyElement bodyElement = getConstructorBody(target); |
| 2513 if (bodyElement == null) continue; // Skip if constructor has no body. | 2583 if (bodyElement == null) continue; // Skip if constructor has no body. |
| 2514 List<ir.Primitive> bodyArguments = <ir.Primitive>[]; | 2584 List<ir.Primitive> bodyArguments = <ir.Primitive>[]; |
| 2515 for (Local param in getConstructorBodyParameters(bodyElement)) { | 2585 for (Local param in getConstructorBodyParameters(bodyElement)) { |
| 2516 bodyArguments.add(irBuilder.environment.lookup(param)); | 2586 bodyArguments.add(irBuilder.environment.lookup(param)); |
| 2517 } | 2587 } |
| 2518 irBuilder.buildInvokeDirectly(bodyElement, instance, bodyArguments); | 2588 irBuilder.buildInvokeDirectly(bodyElement, instance, bodyArguments); |
| 2519 } | 2589 } |
| 2520 | 2590 |
| 2521 // --- step 4: return the created object ---- | 2591 // --- step 4: return the created object ---- |
| 2522 irBuilder.buildReturn(instance); | 2592 irBuilder.buildReturn( |
| 2593 value: instance, |
| 2594 sourceInformation: |
| 2595 sourceInformationBuilder.buildImplicitReturn(constructor)); |
| 2523 | 2596 |
| 2524 return irBuilder.makeFunctionDefinition(); | 2597 return irBuilder.makeFunctionDefinition(); |
| 2525 }); | 2598 }); |
| 2526 } | 2599 } |
| 2527 | 2600 |
| 2528 /// Evaluates all field initializers on [constructor] and all constructors | 2601 /// Evaluates all field initializers on [constructor] and all constructors |
| 2529 /// invoked through `this()` or `super()` ("superconstructors"). | 2602 /// invoked through `this()` or `super()` ("superconstructors"). |
| 2530 /// | 2603 /// |
| 2531 /// The resulting field values will be available in [fieldValues]. The values | 2604 /// The resulting field values will be available in [fieldValues]. The values |
| 2532 /// are not stored in any fields. | 2605 /// are not stored in any fields. |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2967 _) { | 3040 _) { |
| 2968 List<ir.Primitive> arguments = | 3041 List<ir.Primitive> arguments = |
| 2969 node.send.arguments.mapToList(visit, growable:false); | 3042 node.send.arguments.mapToList(visit, growable:false); |
| 2970 // Use default values from the effective target, not the immediate target. | 3043 // Use default values from the effective target, not the immediate target. |
| 2971 ConstructorElement target = constructor.effectiveTarget; | 3044 ConstructorElement target = constructor.effectiveTarget; |
| 2972 arguments = normalizeStaticArguments(callStructure, target, arguments); | 3045 arguments = normalizeStaticArguments(callStructure, target, arguments); |
| 2973 return irBuilder.buildConstructorInvocation( | 3046 return irBuilder.buildConstructorInvocation( |
| 2974 target, | 3047 target, |
| 2975 callStructure, | 3048 callStructure, |
| 2976 constructor.computeEffectiveTargetType(type), | 3049 constructor.computeEffectiveTargetType(type), |
| 2977 arguments); | 3050 arguments, |
| 3051 sourceInformationBuilder.buildNew(node)); |
| 2978 } | 3052 } |
| 2979 | 3053 |
| 2980 @override | 3054 @override |
| 2981 ir.Primitive buildStaticNoSuchMethod(Selector selector, | 3055 ir.Primitive buildStaticNoSuchMethod(Selector selector, |
| 2982 List<ir.Primitive> arguments) { | 3056 List<ir.Primitive> arguments) { |
| 2983 Element thrower = backend.getThrowNoSuchMethod(); | 3057 Element thrower = backend.getThrowNoSuchMethod(); |
| 2984 ir.Primitive receiver = irBuilder.buildStringConstant(''); | 3058 ir.Primitive receiver = irBuilder.buildStringConstant(''); |
| 2985 ir.Primitive name = irBuilder.buildStringConstant(selector.name); | 3059 ir.Primitive name = irBuilder.buildStringConstant(selector.name); |
| 2986 ir.Primitive argumentList = irBuilder.buildListLiteral(null, arguments); | 3060 ir.Primitive argumentList = irBuilder.buildListLiteral(null, arguments); |
| 2987 ir.Primitive expectedArgumentNames = irBuilder.buildNullConstant(); | 3061 ir.Primitive expectedArgumentNames = irBuilder.buildNullConstant(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 | 3094 |
| 3021 @override | 3095 @override |
| 3022 ir.Primitive handleStaticFieldGet(ast.Send node, FieldElement field, _) { | 3096 ir.Primitive handleStaticFieldGet(ast.Send node, FieldElement field, _) { |
| 3023 SourceInformation src = sourceInformationBuilder.buildGet(node); | 3097 SourceInformation src = sourceInformationBuilder.buildGet(node); |
| 3024 return buildStaticFieldGet(field, src); | 3098 return buildStaticFieldGet(field, src); |
| 3025 } | 3099 } |
| 3026 | 3100 |
| 3027 ir.Primitive buildStaticFieldGet(FieldElement field, SourceInformation src) { | 3101 ir.Primitive buildStaticFieldGet(FieldElement field, SourceInformation src) { |
| 3028 ConstantValue constant = getConstantForVariable(field); | 3102 ConstantValue constant = getConstantForVariable(field); |
| 3029 if (constant != null && !field.isAssignable) { | 3103 if (constant != null && !field.isAssignable) { |
| 3030 return irBuilder.buildConstant(constant); | 3104 return irBuilder.buildConstant(constant, sourceInformation: src); |
| 3031 } else if (backend.constants.lazyStatics.contains(field)) { | 3105 } else if (backend.constants.lazyStatics.contains(field)) { |
| 3032 return irBuilder.buildStaticFieldLazyGet(field, src); | 3106 return irBuilder.buildStaticFieldLazyGet(field, src); |
| 3033 } else { | 3107 } else { |
| 3034 return irBuilder.buildStaticFieldGet(field, src); | 3108 return irBuilder.buildStaticFieldGet(field, src); |
| 3035 } | 3109 } |
| 3036 } | 3110 } |
| 3037 | 3111 |
| 3038 /// Build code to handle foreign code, that is, native JavaScript code, or | 3112 /// Build code to handle foreign code, that is, native JavaScript code, or |
| 3039 /// builtin values and operations of the backend. | 3113 /// builtin values and operations of the backend. |
| 3040 ir.Primitive handleForeignCode(ast.Send node, | 3114 ir.Primitive handleForeignCode(ast.Send node, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3319 } | 3393 } |
| 3320 | 3394 |
| 3321 processSetStatic(ir.SetStatic node) { | 3395 processSetStatic(ir.SetStatic node) { |
| 3322 node.body = replacementFor(node.body); | 3396 node.body = replacementFor(node.body); |
| 3323 } | 3397 } |
| 3324 | 3398 |
| 3325 processContinuation(ir.Continuation node) { | 3399 processContinuation(ir.Continuation node) { |
| 3326 node.body = replacementFor(node.body); | 3400 node.body = replacementFor(node.body); |
| 3327 } | 3401 } |
| 3328 } | 3402 } |
| OLD | NEW |