| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 * to the [builder] and return the last added statement for trees that represent | 123 * to the [builder] and return the last added statement for trees that represent |
| 124 * an expression. | 124 * an expression. |
| 125 */ | 125 */ |
| 126 abstract class IrBuilderVisitor extends SemanticVisitor<ir.Primitive, dynamic> | 126 abstract class IrBuilderVisitor extends SemanticVisitor<ir.Primitive, dynamic> |
| 127 with IrBuilderMixin<ast.Node>, | 127 with IrBuilderMixin<ast.Node>, |
| 128 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, | 128 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, |
| 129 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, | 129 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, |
| 130 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, | 130 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, |
| 131 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, | 131 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, |
| 132 BaseImplementationOfSuperIncDecsMixin<ir.Primitive, dynamic>, | 132 BaseImplementationOfSuperIncDecsMixin<ir.Primitive, dynamic>, |
| 133 BaseImplementationOfNewMixin<ir.Primitive, dynamic>, |
| 133 ErrorBulkMixin<ir.Primitive, dynamic> | 134 ErrorBulkMixin<ir.Primitive, dynamic> |
| 134 implements SemanticSendVisitor<ir.Primitive, dynamic> { | 135 implements SemanticSendVisitor<ir.Primitive, dynamic> { |
| 135 final Compiler compiler; | 136 final Compiler compiler; |
| 136 final SourceInformationBuilder sourceInformationBuilder; | 137 final SourceInformationBuilder sourceInformationBuilder; |
| 137 | 138 |
| 138 // In SSA terms, join-point continuation parameters are the phis and the | 139 // In SSA terms, join-point continuation parameters are the phis and the |
| 139 // continuation invocation arguments are the corresponding phi inputs. To | 140 // continuation invocation arguments are the corresponding phi inputs. To |
| 140 // support name introduction and renaming for source level variables, we use | 141 // support name introduction and renaming for source level variables, we use |
| 141 // nested (delimited) visitors for constructing subparts of the IR that will | 142 // nested (delimited) visitors for constructing subparts of the IR that will |
| 142 // need renaming. Each source variable is assigned an index. | 143 // need renaming. Each source variable is assigned an index. |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 return irBuilder.buildCallInvocation(receiver, selector, arguments); | 635 return irBuilder.buildCallInvocation(receiver, selector, arguments); |
| 635 } | 636 } |
| 636 | 637 |
| 637 /// Returns `true` if [node] is a super call. | 638 /// Returns `true` if [node] is a super call. |
| 638 // TODO(johnniwinther): Remove the need for this. | 639 // TODO(johnniwinther): Remove the need for this. |
| 639 bool isSuperCall(ast.Send node) { | 640 bool isSuperCall(ast.Send node) { |
| 640 return node != null && node.receiver != null && node.receiver.isSuper(); | 641 return node != null && node.receiver != null && node.receiver.isSuper(); |
| 641 } | 642 } |
| 642 | 643 |
| 643 @override | 644 @override |
| 644 ir.Primitive handleConstantGet(ast.Send node, | 645 ir.Primitive handleConstantGet( |
| 645 ConstantExpression constant, _) { | 646 ast.Node node, |
| 647 ConstantExpression constant, _) { |
| 646 return irBuilder.buildConstantLiteral(constant); | 648 return irBuilder.buildConstantLiteral(constant); |
| 647 } | 649 } |
| 648 | 650 |
| 649 /// If [node] is null, returns this. | 651 /// If [node] is null, returns this. |
| 650 /// Otherwise visits [node] and returns the result. | 652 /// Otherwise visits [node] and returns the result. |
| 651 ir.Primitive translateReceiver(ast.Expression node) { | 653 ir.Primitive translateReceiver(ast.Expression node) { |
| 652 return node != null ? visit(node) : irBuilder.buildThis(); | 654 return node != null ? visit(node) : irBuilder.buildThis(); |
| 653 } | 655 } |
| 654 | 656 |
| 655 @override | 657 @override |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 _) { | 1698 _) { |
| 1697 return translateCompound( | 1699 return translateCompound( |
| 1698 getValue: () => irBuilder.buildSuperGet(method), | 1700 getValue: () => irBuilder.buildSuperGet(method), |
| 1699 operator: operator, | 1701 operator: operator, |
| 1700 rhs: rhs, | 1702 rhs: rhs, |
| 1701 setValue: (ir.Primitive result) { | 1703 setValue: (ir.Primitive result) { |
| 1702 irBuilder.buildSuperSet(setter, result); | 1704 irBuilder.buildSuperSet(setter, result); |
| 1703 }); | 1705 }); |
| 1704 } | 1706 } |
| 1705 | 1707 |
| 1706 ir.Primitive visitNewExpression(ast.NewExpression node) { | 1708 @override |
| 1707 if (node.isConst) { | 1709 ir.Primitive handleConstructorInvoke( |
| 1708 return translateConstant(node); | 1710 ast.NewExpression node, |
| 1709 } | 1711 ConstructorElement constructor, |
| 1710 FunctionElement element = elements[node.send]; | 1712 DartType type, |
| 1711 Selector selector = elements.getSelector(node.send); | 1713 ast.NodeList arguments, |
| 1712 DartType type = elements.getType(node); | 1714 Selector selector, _) { |
| 1713 ast.Node selectorNode = node.send.selector; | |
| 1714 List<ir.Primitive> arguments = | 1715 List<ir.Primitive> arguments = |
| 1715 node.send.arguments.mapToList(visit, growable:false); | 1716 node.send.arguments.mapToList(visit, growable:false); |
| 1716 arguments = normalizeStaticArguments(selector, element, arguments); | 1717 arguments = normalizeStaticArguments(selector, constructor, arguments); |
| 1717 return irBuilder.buildConstructorInvocation( | 1718 return irBuilder.buildConstructorInvocation( |
| 1718 element, selector, type, arguments); | 1719 constructor, selector, type, arguments); |
| 1719 } | 1720 } |
| 1720 | 1721 |
| 1721 ir.Primitive visitStringJuxtaposition(ast.StringJuxtaposition node) { | 1722 ir.Primitive visitStringJuxtaposition(ast.StringJuxtaposition node) { |
| 1722 assert(irBuilder.isOpen); | 1723 assert(irBuilder.isOpen); |
| 1723 ir.Primitive first = visit(node.first); | 1724 ir.Primitive first = visit(node.first); |
| 1724 ir.Primitive second = visit(node.second); | 1725 ir.Primitive second = visit(node.second); |
| 1725 return irBuilder.buildStringConcatenation([first, second]); | 1726 return irBuilder.buildStringConcatenation([first, second]); |
| 1726 } | 1727 } |
| 1727 | 1728 |
| 1728 ir.Primitive visitStringInterpolation(ast.StringInterpolation node) { | 1729 ir.Primitive visitStringInterpolation(ast.StringInterpolation node) { |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 SourceInformation buildCall(ast.Node node) { | 2654 SourceInformation buildCall(ast.Node node) { |
| 2654 return new PositionSourceInformation( | 2655 return new PositionSourceInformation( |
| 2655 new TokenSourceLocation(sourceFile, node.getBeginToken(), name)); | 2656 new TokenSourceLocation(sourceFile, node.getBeginToken(), name)); |
| 2656 } | 2657 } |
| 2657 | 2658 |
| 2658 @override | 2659 @override |
| 2659 SourceInformationBuilder forContext(AstElement element) { | 2660 SourceInformationBuilder forContext(AstElement element) { |
| 2660 return new PositionSourceInformationBuilder(element); | 2661 return new PositionSourceInformationBuilder(element); |
| 2661 } | 2662 } |
| 2662 } | 2663 } |
| OLD | NEW |