| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 /// and the current reaching definition of local variables. | 88 /// and the current reaching definition of local variables. |
| 89 /// | 89 /// |
| 90 /// Visiting a statement or expression extends the IR builder's fragment. | 90 /// Visiting a statement or expression extends the IR builder's fragment. |
| 91 /// For expressions, the primitive holding the resulting value is returned. | 91 /// For expressions, the primitive holding the resulting value is returned. |
| 92 /// For statements, `null` is returned. | 92 /// For statements, `null` is returned. |
| 93 // TODO(johnniwinther): Implement [SemanticDeclVisitor]. | 93 // TODO(johnniwinther): Implement [SemanticDeclVisitor]. |
| 94 abstract class IrBuilderVisitor extends ast.Visitor<ir.Primitive> | 94 abstract class IrBuilderVisitor extends ast.Visitor<ir.Primitive> |
| 95 with IrBuilderMixin<ast.Node>, | 95 with IrBuilderMixin<ast.Node>, |
| 96 SemanticSendResolvedMixin<ir.Primitive, dynamic>, | 96 SemanticSendResolvedMixin<ir.Primitive, dynamic>, |
| 97 SendResolverMixin, | 97 SendResolverMixin, |
| 98 ErrorBulkMixin<ir.Primitive, dynamic>, |
| 98 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, | 99 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, |
| 99 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, | 100 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, |
| 100 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, | 101 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, |
| 101 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, | 102 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, |
| 102 BaseImplementationOfNewMixin<ir.Primitive, dynamic>, | 103 BaseImplementationOfNewMixin<ir.Primitive, dynamic>, |
| 103 BaseImplementationOfCompoundsMixin<ir.Primitive, dynamic>, | 104 BaseImplementationOfCompoundsMixin<ir.Primitive, dynamic>, |
| 104 BaseImplementationOfIndexCompoundsMixin<ir.Primitive, dynamic> | 105 BaseImplementationOfIndexCompoundsMixin<ir.Primitive, dynamic> |
| 105 implements SemanticSendVisitor<ir.Primitive, dynamic> { | 106 implements SemanticSendVisitor<ir.Primitive, dynamic> { |
| 106 final TreeElements elements; | 107 final TreeElements elements; |
| 107 final Compiler compiler; | 108 final Compiler compiler; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 602 |
| 602 // ## Sends ## | 603 // ## Sends ## |
| 603 @override | 604 @override |
| 604 ir.Primitive visitAssert(ast.Send node, ast.Node condition, _) { | 605 ir.Primitive visitAssert(ast.Send node, ast.Node condition, _) { |
| 605 assert(irBuilder.isOpen); | 606 assert(irBuilder.isOpen); |
| 606 if (compiler.enableUserAssertions) { | 607 if (compiler.enableUserAssertions) { |
| 607 return giveup(node, 'assert in checked mode not implemented'); | 608 return giveup(node, 'assert in checked mode not implemented'); |
| 608 } else { | 609 } else { |
| 609 // The call to assert and its argument expression must be ignored | 610 // The call to assert and its argument expression must be ignored |
| 610 // in production mode. | 611 // in production mode. |
| 611 // Assertions can onl)y occur in expression statements, so no value needs | 612 // Assertions can only occur in expression statements, so no value needs |
| 612 // to be returned. | 613 // to be returned. |
| 613 return null; | 614 return null; |
| 614 } | 615 } |
| 615 } | 616 } |
| 616 | 617 |
| 617 @override | 618 @override |
| 618 void previsitDeferredAccess(ast.Send node, PrefixElement prefix, _) { | 619 void previsitDeferredAccess(ast.Send node, PrefixElement prefix, _) { |
| 619 giveup(node, 'deferred access is not implemented'); | 620 giveup(node, 'deferred access is not implemented'); |
| 620 } | 621 } |
| 621 | 622 |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 ir.Primitive buildInstanceNoSuchMethod( | 1716 ir.Primitive buildInstanceNoSuchMethod( |
| 1716 Selector selector, | 1717 Selector selector, |
| 1717 TypeMask mask, | 1718 TypeMask mask, |
| 1718 List<ir.Primitive> arguments); | 1719 List<ir.Primitive> arguments); |
| 1719 | 1720 |
| 1720 ir.Primitive buildRuntimeError(String message); | 1721 ir.Primitive buildRuntimeError(String message); |
| 1721 | 1722 |
| 1722 ir.Primitive buildAbstractClassInstantiationError(ClassElement element); | 1723 ir.Primitive buildAbstractClassInstantiationError(ClassElement element); |
| 1723 | 1724 |
| 1724 @override | 1725 @override |
| 1725 ir.Primitive errorInvalidAssert( | |
| 1726 ast.Send node, | |
| 1727 ast.NodeList arguments, _) { | |
| 1728 if (compiler.enableUserAssertions) { | |
| 1729 return giveup(node, 'Assert'); | |
| 1730 } else { | |
| 1731 return irBuilder.buildNullConstant(); | |
| 1732 } | |
| 1733 } | |
| 1734 | |
| 1735 @override | |
| 1736 ir.Primitive visitUnresolvedCompound( | 1726 ir.Primitive visitUnresolvedCompound( |
| 1737 ast.Send node, | 1727 ast.Send node, |
| 1738 Element element, | 1728 Element element, |
| 1739 op.AssignmentOperator operator, | 1729 op.AssignmentOperator operator, |
| 1740 ast.Node rhs, _) { | 1730 ast.Node rhs, _) { |
| 1741 // TODO(asgerf): What is unresolved? The getter and/or the setter? | 1731 // TODO(asgerf): What is unresolved? The getter and/or the setter? |
| 1742 // If it was the setter, we must evaluate the right-hand side. | 1732 // If it was the setter, we must evaluate the right-hand side. |
| 1743 return buildStaticNoSuchMethod(elements.getSelector(node), []); | 1733 return buildStaticNoSuchMethod(elements.getSelector(node), []); |
| 1744 } | 1734 } |
| 1745 | 1735 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1771 ast.NewExpression node, | 1761 ast.NewExpression node, |
| 1772 Element constructor, | 1762 Element constructor, |
| 1773 DartType type, | 1763 DartType type, |
| 1774 ast.NodeList arguments, | 1764 ast.NodeList arguments, |
| 1775 CallStructure callStructure, _) { | 1765 CallStructure callStructure, _) { |
| 1776 return buildStaticNoSuchMethod(elements.getSelector(node.send), | 1766 return buildStaticNoSuchMethod(elements.getSelector(node.send), |
| 1777 translateDynamicArguments(arguments, callStructure)); | 1767 translateDynamicArguments(arguments, callStructure)); |
| 1778 } | 1768 } |
| 1779 | 1769 |
| 1780 @override | 1770 @override |
| 1781 ir.Primitive errorNonConstantConstructorInvoke( | |
| 1782 ast.NewExpression node, | |
| 1783 Element element, | |
| 1784 DartType type, | |
| 1785 ast.NodeList arguments, | |
| 1786 CallStructure callStructure, _) { | |
| 1787 assert(compiler.compilationFailed); | |
| 1788 return irBuilder.buildNullConstant(); | |
| 1789 } | |
| 1790 | |
| 1791 @override | |
| 1792 ir.Primitive visitUnresolvedGet( | 1771 ir.Primitive visitUnresolvedGet( |
| 1793 ast.Send node, | 1772 ast.Send node, |
| 1794 Element element, _) { | 1773 Element element, _) { |
| 1795 return buildStaticNoSuchMethod(elements.getSelector(node), []); | 1774 return buildStaticNoSuchMethod(elements.getSelector(node), []); |
| 1796 } | 1775 } |
| 1797 | 1776 |
| 1798 @override | 1777 @override |
| 1799 ir.Primitive visitUnresolvedInvoke( | 1778 ir.Primitive visitUnresolvedInvoke( |
| 1800 ast.Send node, | 1779 ast.Send node, |
| 1801 Element element, | 1780 Element element, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 @override | 1831 @override |
| 1853 ir.Primitive visitUnresolvedSuperUnary( | 1832 ir.Primitive visitUnresolvedSuperUnary( |
| 1854 ast.Send node, | 1833 ast.Send node, |
| 1855 op.UnaryOperator operator, | 1834 op.UnaryOperator operator, |
| 1856 Element element, _) { | 1835 Element element, _) { |
| 1857 return buildInstanceNoSuchMethod( | 1836 return buildInstanceNoSuchMethod( |
| 1858 elements.getSelector(node), elements.getTypeMask(node), []); | 1837 elements.getSelector(node), elements.getTypeMask(node), []); |
| 1859 } | 1838 } |
| 1860 | 1839 |
| 1861 @override | 1840 @override |
| 1862 ir.Primitive errorUndefinedBinaryExpression( | 1841 ir.Primitive bulkHandleNode(ast.Node node, String message, _) { |
| 1863 ast.Send node, | 1842 return giveup(node, "Unhandled node: ${message.replaceAll('#', '$node')}"); |
| 1864 ast.Node left, | 1843 } |
| 1865 ast.Operator operator, | 1844 |
| 1866 ast.Node right, _) { | 1845 @override |
| 1846 ir.Primitive bulkHandleError(ast.Send node, ErroneousElement error, _) { |
| 1867 assert(compiler.compilationFailed); | 1847 assert(compiler.compilationFailed); |
| 1868 return irBuilder.buildNullConstant(); | 1848 return irBuilder.buildNullConstant(); |
| 1869 } | 1849 } |
| 1870 | |
| 1871 @override | |
| 1872 ir.Primitive errorUndefinedUnaryExpression( | |
| 1873 ast.Send node, | |
| 1874 ast.Operator operator, | |
| 1875 ast.Node expression, _) { | |
| 1876 assert(compiler.compilationFailed); | |
| 1877 return irBuilder.buildNullConstant(); | |
| 1878 } | |
| 1879 | 1850 |
| 1880 @override | 1851 @override |
| 1881 ir.Primitive visitClassTypeLiteralSet( | 1852 ir.Primitive visitClassTypeLiteralSet( |
| 1882 ast.SendSet node, | 1853 ast.SendSet node, |
| 1883 TypeConstantExpression constant, | 1854 TypeConstantExpression constant, |
| 1884 ast.Node rhs, _) { | 1855 ast.Node rhs, _) { |
| 1885 InterfaceType type = constant.type; | 1856 InterfaceType type = constant.type; |
| 1886 ClassElement element = type.element; | 1857 ClassElement element = type.element; |
| 1887 return buildStaticNoSuchMethod( | 1858 return buildStaticNoSuchMethod( |
| 1888 new Selector.setter(element.name, element.library), [visit(rhs)]); | 1859 new Selector.setter(element.name, element.library), [visit(rhs)]); |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 if (compiler.backend.isForeign(function)) { | 3335 if (compiler.backend.isForeign(function)) { |
| 3365 return handleForeignCode(node, function, argumentList, callStructure); | 3336 return handleForeignCode(node, function, argumentList, callStructure); |
| 3366 } else { | 3337 } else { |
| 3367 return irBuilder.buildStaticFunctionInvocation(function, callStructure, | 3338 return irBuilder.buildStaticFunctionInvocation(function, callStructure, |
| 3368 translateStaticArguments(argumentList, function, callStructure), | 3339 translateStaticArguments(argumentList, function, callStructure), |
| 3369 sourceInformation: | 3340 sourceInformation: |
| 3370 sourceInformationBuilder.buildCall(node, node.selector)); | 3341 sourceInformationBuilder.buildCall(node, node.selector)); |
| 3371 } | 3342 } |
| 3372 } | 3343 } |
| 3373 } | 3344 } |
| OLD | NEW |