| 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 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
| 6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
| 7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
| 8 /// | 8 /// |
| 9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
| 10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 var upcastType = types.hierarchy.getTypeAsInstanceOf(type, superclass); | 1399 var upcastType = types.hierarchy.getTypeAsInstanceOf(type, superclass); |
| 1400 if (upcastType != null) return upcastType; | 1400 if (upcastType != null) return upcastType; |
| 1401 } else if (type is BottomType) { | 1401 } else if (type is BottomType) { |
| 1402 return superclass.bottomType; | 1402 return superclass.bottomType; |
| 1403 } | 1403 } |
| 1404 types.typeError(this, '$type is not a subtype of $superclass'); | 1404 types.typeError(this, '$type is not a subtype of $superclass'); |
| 1405 return superclass.rawType; | 1405 return superclass.rawType; |
| 1406 } | 1406 } |
| 1407 | 1407 |
| 1408 accept(ExpressionVisitor v); | 1408 accept(ExpressionVisitor v); |
| 1409 accept1(ExpressionVisitor1 v, arg); |
| 1409 } | 1410 } |
| 1410 | 1411 |
| 1411 /// An expression containing compile-time errors. | 1412 /// An expression containing compile-time errors. |
| 1412 /// | 1413 /// |
| 1413 /// Should throw a runtime error when evaluated. | 1414 /// Should throw a runtime error when evaluated. |
| 1414 class InvalidExpression extends Expression { | 1415 class InvalidExpression extends Expression { |
| 1415 DartType getStaticType(TypeEnvironment types) => const BottomType(); | 1416 DartType getStaticType(TypeEnvironment types) => const BottomType(); |
| 1416 | 1417 |
| 1417 accept(ExpressionVisitor v) => v.visitInvalidExpression(this); | 1418 accept(ExpressionVisitor v) => v.visitInvalidExpression(this); |
| 1419 accept1(ExpressionVisitor1 v, arg) => v.visitInvalidExpression(this, arg); |
| 1418 | 1420 |
| 1419 visitChildren(Visitor v) {} | 1421 visitChildren(Visitor v) {} |
| 1420 transformChildren(Transformer v) {} | 1422 transformChildren(Transformer v) {} |
| 1421 } | 1423 } |
| 1422 | 1424 |
| 1423 /// Read a local variable, a local function, or a function parameter. | 1425 /// Read a local variable, a local function, or a function parameter. |
| 1424 class VariableGet extends Expression { | 1426 class VariableGet extends Expression { |
| 1425 VariableDeclaration variable; | 1427 VariableDeclaration variable; |
| 1426 DartType promotedType; // Null if not promoted. | 1428 DartType promotedType; // Null if not promoted. |
| 1427 | 1429 |
| 1428 VariableGet(this.variable, [this.promotedType]); | 1430 VariableGet(this.variable, [this.promotedType]); |
| 1429 | 1431 |
| 1430 DartType getStaticType(TypeEnvironment types) { | 1432 DartType getStaticType(TypeEnvironment types) { |
| 1431 return promotedType ?? variable.type; | 1433 return promotedType ?? variable.type; |
| 1432 } | 1434 } |
| 1433 | 1435 |
| 1434 accept(ExpressionVisitor v) => v.visitVariableGet(this); | 1436 accept(ExpressionVisitor v) => v.visitVariableGet(this); |
| 1437 accept1(ExpressionVisitor1 v, arg) => v.visitVariableGet(this, arg); |
| 1435 | 1438 |
| 1436 visitChildren(Visitor v) { | 1439 visitChildren(Visitor v) { |
| 1437 promotedType?.accept(v); | 1440 promotedType?.accept(v); |
| 1438 } | 1441 } |
| 1439 | 1442 |
| 1440 transformChildren(Transformer v) { | 1443 transformChildren(Transformer v) { |
| 1441 if (promotedType != null) { | 1444 if (promotedType != null) { |
| 1442 promotedType = v.visitDartType(promotedType); | 1445 promotedType = v.visitDartType(promotedType); |
| 1443 } | 1446 } |
| 1444 } | 1447 } |
| 1445 } | 1448 } |
| 1446 | 1449 |
| 1447 /// Assign a local variable or function parameter. | 1450 /// Assign a local variable or function parameter. |
| 1448 /// | 1451 /// |
| 1449 /// Evaluates to the value of [value]. | 1452 /// Evaluates to the value of [value]. |
| 1450 class VariableSet extends Expression { | 1453 class VariableSet extends Expression { |
| 1451 VariableDeclaration variable; | 1454 VariableDeclaration variable; |
| 1452 Expression value; | 1455 Expression value; |
| 1453 | 1456 |
| 1454 VariableSet(this.variable, this.value) { | 1457 VariableSet(this.variable, this.value) { |
| 1455 value?.parent = this; | 1458 value?.parent = this; |
| 1456 } | 1459 } |
| 1457 | 1460 |
| 1458 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1461 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
| 1459 | 1462 |
| 1460 accept(ExpressionVisitor v) => v.visitVariableSet(this); | 1463 accept(ExpressionVisitor v) => v.visitVariableSet(this); |
| 1464 accept1(ExpressionVisitor1 v, arg) => v.visitVariableSet(this, arg); |
| 1461 | 1465 |
| 1462 visitChildren(Visitor v) { | 1466 visitChildren(Visitor v) { |
| 1463 value?.accept(v); | 1467 value?.accept(v); |
| 1464 } | 1468 } |
| 1465 | 1469 |
| 1466 transformChildren(Transformer v) { | 1470 transformChildren(Transformer v) { |
| 1467 if (value != null) { | 1471 if (value != null) { |
| 1468 value = value.accept(v); | 1472 value = value.accept(v); |
| 1469 value?.parent = this; | 1473 value?.parent = this; |
| 1470 } | 1474 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 String nameString = name.name; | 1511 String nameString = name.name; |
| 1508 if (nameString == 'hashCode') { | 1512 if (nameString == 'hashCode') { |
| 1509 return types.intType; | 1513 return types.intType; |
| 1510 } else if (nameString == 'runtimeType') { | 1514 } else if (nameString == 'runtimeType') { |
| 1511 return types.typeType; | 1515 return types.typeType; |
| 1512 } | 1516 } |
| 1513 return const DynamicType(); | 1517 return const DynamicType(); |
| 1514 } | 1518 } |
| 1515 | 1519 |
| 1516 accept(ExpressionVisitor v) => v.visitPropertyGet(this); | 1520 accept(ExpressionVisitor v) => v.visitPropertyGet(this); |
| 1521 accept1(ExpressionVisitor1 v, arg) => v.visitPropertyGet(this, arg); |
| 1517 | 1522 |
| 1518 visitChildren(Visitor v) { | 1523 visitChildren(Visitor v) { |
| 1519 receiver?.accept(v); | 1524 receiver?.accept(v); |
| 1520 name?.accept(v); | 1525 name?.accept(v); |
| 1521 } | 1526 } |
| 1522 | 1527 |
| 1523 transformChildren(Transformer v) { | 1528 transformChildren(Transformer v) { |
| 1524 if (receiver != null) { | 1529 if (receiver != null) { |
| 1525 receiver = receiver.accept(v); | 1530 receiver = receiver.accept(v); |
| 1526 receiver?.parent = this; | 1531 receiver?.parent = this; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1553 | 1558 |
| 1554 Member get interfaceTarget => interfaceTargetReference?.asMember; | 1559 Member get interfaceTarget => interfaceTargetReference?.asMember; |
| 1555 | 1560 |
| 1556 void set interfaceTarget(Member member) { | 1561 void set interfaceTarget(Member member) { |
| 1557 interfaceTargetReference = getMemberReference(member); | 1562 interfaceTargetReference = getMemberReference(member); |
| 1558 } | 1563 } |
| 1559 | 1564 |
| 1560 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1565 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
| 1561 | 1566 |
| 1562 accept(ExpressionVisitor v) => v.visitPropertySet(this); | 1567 accept(ExpressionVisitor v) => v.visitPropertySet(this); |
| 1568 accept1(ExpressionVisitor1 v, arg) => v.visitPropertySet(this, arg); |
| 1563 | 1569 |
| 1564 visitChildren(Visitor v) { | 1570 visitChildren(Visitor v) { |
| 1565 receiver?.accept(v); | 1571 receiver?.accept(v); |
| 1566 name?.accept(v); | 1572 name?.accept(v); |
| 1567 value?.accept(v); | 1573 value?.accept(v); |
| 1568 } | 1574 } |
| 1569 | 1575 |
| 1570 transformChildren(Transformer v) { | 1576 transformChildren(Transformer v) { |
| 1571 if (receiver != null) { | 1577 if (receiver != null) { |
| 1572 receiver = receiver.accept(v); | 1578 receiver = receiver.accept(v); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1603 } | 1609 } |
| 1604 | 1610 |
| 1605 transformChildren(Transformer v) { | 1611 transformChildren(Transformer v) { |
| 1606 if (receiver != null) { | 1612 if (receiver != null) { |
| 1607 receiver = receiver.accept(v); | 1613 receiver = receiver.accept(v); |
| 1608 receiver?.parent = this; | 1614 receiver?.parent = this; |
| 1609 } | 1615 } |
| 1610 } | 1616 } |
| 1611 | 1617 |
| 1612 accept(ExpressionVisitor v) => v.visitDirectPropertyGet(this); | 1618 accept(ExpressionVisitor v) => v.visitDirectPropertyGet(this); |
| 1619 accept1(ExpressionVisitor1 v, arg) => v.visitDirectPropertyGet(this, arg); |
| 1613 | 1620 |
| 1614 DartType getStaticType(TypeEnvironment types) { | 1621 DartType getStaticType(TypeEnvironment types) { |
| 1615 Class superclass = target.enclosingClass; | 1622 Class superclass = target.enclosingClass; |
| 1616 var receiverType = receiver.getStaticTypeAsInstanceOf(superclass, types); | 1623 var receiverType = receiver.getStaticTypeAsInstanceOf(superclass, types); |
| 1617 return Substitution | 1624 return Substitution |
| 1618 .fromInterfaceType(receiverType) | 1625 .fromInterfaceType(receiverType) |
| 1619 .substituteType(target.getterType); | 1626 .substituteType(target.getterType); |
| 1620 } | 1627 } |
| 1621 } | 1628 } |
| 1622 | 1629 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 receiver = receiver.accept(v); | 1661 receiver = receiver.accept(v); |
| 1655 receiver?.parent = this; | 1662 receiver?.parent = this; |
| 1656 } | 1663 } |
| 1657 if (value != null) { | 1664 if (value != null) { |
| 1658 value = value.accept(v); | 1665 value = value.accept(v); |
| 1659 value?.parent = this; | 1666 value?.parent = this; |
| 1660 } | 1667 } |
| 1661 } | 1668 } |
| 1662 | 1669 |
| 1663 accept(ExpressionVisitor v) => v.visitDirectPropertySet(this); | 1670 accept(ExpressionVisitor v) => v.visitDirectPropertySet(this); |
| 1671 accept1(ExpressionVisitor1 v, arg) => v.visitDirectPropertySet(this, arg); |
| 1664 | 1672 |
| 1665 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1673 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
| 1666 } | 1674 } |
| 1667 | 1675 |
| 1668 /// Directly call an instance method, bypassing ordinary dispatch. | 1676 /// Directly call an instance method, bypassing ordinary dispatch. |
| 1669 class DirectMethodInvocation extends InvocationExpression { | 1677 class DirectMethodInvocation extends InvocationExpression { |
| 1670 Expression receiver; | 1678 Expression receiver; |
| 1671 Reference targetReference; | 1679 Reference targetReference; |
| 1672 Arguments arguments; | 1680 Arguments arguments; |
| 1673 | 1681 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1700 receiver = receiver.accept(v); | 1708 receiver = receiver.accept(v); |
| 1701 receiver?.parent = this; | 1709 receiver?.parent = this; |
| 1702 } | 1710 } |
| 1703 if (arguments != null) { | 1711 if (arguments != null) { |
| 1704 arguments = arguments.accept(v); | 1712 arguments = arguments.accept(v); |
| 1705 arguments?.parent = this; | 1713 arguments?.parent = this; |
| 1706 } | 1714 } |
| 1707 } | 1715 } |
| 1708 | 1716 |
| 1709 accept(ExpressionVisitor v) => v.visitDirectMethodInvocation(this); | 1717 accept(ExpressionVisitor v) => v.visitDirectMethodInvocation(this); |
| 1718 accept1(ExpressionVisitor1 v, arg) => |
| 1719 v.visitDirectMethodInvocation(this, arg); |
| 1710 | 1720 |
| 1711 DartType getStaticType(TypeEnvironment types) { | 1721 DartType getStaticType(TypeEnvironment types) { |
| 1712 if (types.isOverloadedArithmeticOperator(target)) { | 1722 if (types.isOverloadedArithmeticOperator(target)) { |
| 1713 return types.getTypeOfOverloadedArithmetic(receiver.getStaticType(types), | 1723 return types.getTypeOfOverloadedArithmetic(receiver.getStaticType(types), |
| 1714 arguments.positional[0].getStaticType(types)); | 1724 arguments.positional[0].getStaticType(types)); |
| 1715 } | 1725 } |
| 1716 Class superclass = target.enclosingClass; | 1726 Class superclass = target.enclosingClass; |
| 1717 var receiverType = receiver.getStaticTypeAsInstanceOf(superclass, types); | 1727 var receiverType = receiver.getStaticTypeAsInstanceOf(superclass, types); |
| 1718 var returnType = Substitution | 1728 var returnType = Substitution |
| 1719 .fromInterfaceType(receiverType) | 1729 .fromInterfaceType(receiverType) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1748 return interfaceTarget.getterType; | 1758 return interfaceTarget.getterType; |
| 1749 } | 1759 } |
| 1750 var receiver = | 1760 var receiver = |
| 1751 types.hierarchy.getTypeAsInstanceOf(types.thisType, declaringClass); | 1761 types.hierarchy.getTypeAsInstanceOf(types.thisType, declaringClass); |
| 1752 return Substitution | 1762 return Substitution |
| 1753 .fromInterfaceType(receiver) | 1763 .fromInterfaceType(receiver) |
| 1754 .substituteType(interfaceTarget.getterType); | 1764 .substituteType(interfaceTarget.getterType); |
| 1755 } | 1765 } |
| 1756 | 1766 |
| 1757 accept(ExpressionVisitor v) => v.visitSuperPropertyGet(this); | 1767 accept(ExpressionVisitor v) => v.visitSuperPropertyGet(this); |
| 1768 accept1(ExpressionVisitor1 v, arg) => v.visitSuperPropertyGet(this, arg); |
| 1758 | 1769 |
| 1759 visitChildren(Visitor v) { | 1770 visitChildren(Visitor v) { |
| 1760 name?.accept(v); | 1771 name?.accept(v); |
| 1761 } | 1772 } |
| 1762 | 1773 |
| 1763 transformChildren(Transformer v) {} | 1774 transformChildren(Transformer v) {} |
| 1764 } | 1775 } |
| 1765 | 1776 |
| 1766 /// Expression of form `super.field = value`. | 1777 /// Expression of form `super.field = value`. |
| 1767 /// | 1778 /// |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1783 | 1794 |
| 1784 Member get interfaceTarget => interfaceTargetReference?.asMember; | 1795 Member get interfaceTarget => interfaceTargetReference?.asMember; |
| 1785 | 1796 |
| 1786 void set interfaceTarget(Member member) { | 1797 void set interfaceTarget(Member member) { |
| 1787 interfaceTargetReference = getMemberReference(member); | 1798 interfaceTargetReference = getMemberReference(member); |
| 1788 } | 1799 } |
| 1789 | 1800 |
| 1790 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1801 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
| 1791 | 1802 |
| 1792 accept(ExpressionVisitor v) => v.visitSuperPropertySet(this); | 1803 accept(ExpressionVisitor v) => v.visitSuperPropertySet(this); |
| 1804 accept1(ExpressionVisitor1 v, arg) => v.visitSuperPropertySet(this, arg); |
| 1793 | 1805 |
| 1794 visitChildren(Visitor v) { | 1806 visitChildren(Visitor v) { |
| 1795 name?.accept(v); | 1807 name?.accept(v); |
| 1796 value?.accept(v); | 1808 value?.accept(v); |
| 1797 } | 1809 } |
| 1798 | 1810 |
| 1799 transformChildren(Transformer v) { | 1811 transformChildren(Transformer v) { |
| 1800 if (value != null) { | 1812 if (value != null) { |
| 1801 value = value.accept(v); | 1813 value = value.accept(v); |
| 1802 value?.parent = this; | 1814 value?.parent = this; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1815 | 1827 |
| 1816 Member get target => targetReference?.asMember; | 1828 Member get target => targetReference?.asMember; |
| 1817 | 1829 |
| 1818 void set target(Member target) { | 1830 void set target(Member target) { |
| 1819 targetReference = getMemberReference(target); | 1831 targetReference = getMemberReference(target); |
| 1820 } | 1832 } |
| 1821 | 1833 |
| 1822 DartType getStaticType(TypeEnvironment types) => target.getterType; | 1834 DartType getStaticType(TypeEnvironment types) => target.getterType; |
| 1823 | 1835 |
| 1824 accept(ExpressionVisitor v) => v.visitStaticGet(this); | 1836 accept(ExpressionVisitor v) => v.visitStaticGet(this); |
| 1837 accept1(ExpressionVisitor1 v, arg) => v.visitStaticGet(this, arg); |
| 1825 | 1838 |
| 1826 visitChildren(Visitor v) { | 1839 visitChildren(Visitor v) { |
| 1827 target?.acceptReference(v); | 1840 target?.acceptReference(v); |
| 1828 } | 1841 } |
| 1829 | 1842 |
| 1830 transformChildren(Transformer v) {} | 1843 transformChildren(Transformer v) {} |
| 1831 } | 1844 } |
| 1832 | 1845 |
| 1833 /// Assign a static field or call a static setter. | 1846 /// Assign a static field or call a static setter. |
| 1834 /// | 1847 /// |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1847 | 1860 |
| 1848 Member get target => targetReference?.asMember; | 1861 Member get target => targetReference?.asMember; |
| 1849 | 1862 |
| 1850 void set target(Member target) { | 1863 void set target(Member target) { |
| 1851 targetReference = getMemberReference(target); | 1864 targetReference = getMemberReference(target); |
| 1852 } | 1865 } |
| 1853 | 1866 |
| 1854 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); | 1867 DartType getStaticType(TypeEnvironment types) => value.getStaticType(types); |
| 1855 | 1868 |
| 1856 accept(ExpressionVisitor v) => v.visitStaticSet(this); | 1869 accept(ExpressionVisitor v) => v.visitStaticSet(this); |
| 1870 accept1(ExpressionVisitor1 v, arg) => v.visitStaticSet(this, arg); |
| 1857 | 1871 |
| 1858 visitChildren(Visitor v) { | 1872 visitChildren(Visitor v) { |
| 1859 target?.acceptReference(v); | 1873 target?.acceptReference(v); |
| 1860 value?.accept(v); | 1874 value?.accept(v); |
| 1861 } | 1875 } |
| 1862 | 1876 |
| 1863 transformChildren(Transformer v) { | 1877 transformChildren(Transformer v) { |
| 1864 if (value != null) { | 1878 if (value != null) { |
| 1865 value = value.accept(v); | 1879 value = value.accept(v); |
| 1866 value?.parent = this; | 1880 value?.parent = this; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 } | 2005 } |
| 1992 } | 2006 } |
| 1993 if (name.name == '==') { | 2007 if (name.name == '==') { |
| 1994 // We use this special case to simplify generation of '==' checks. | 2008 // We use this special case to simplify generation of '==' checks. |
| 1995 return types.boolType; | 2009 return types.boolType; |
| 1996 } | 2010 } |
| 1997 return const DynamicType(); | 2011 return const DynamicType(); |
| 1998 } | 2012 } |
| 1999 | 2013 |
| 2000 accept(ExpressionVisitor v) => v.visitMethodInvocation(this); | 2014 accept(ExpressionVisitor v) => v.visitMethodInvocation(this); |
| 2015 accept1(ExpressionVisitor1 v, arg) => v.visitMethodInvocation(this, arg); |
| 2001 | 2016 |
| 2002 visitChildren(Visitor v) { | 2017 visitChildren(Visitor v) { |
| 2003 receiver?.accept(v); | 2018 receiver?.accept(v); |
| 2004 name?.accept(v); | 2019 name?.accept(v); |
| 2005 arguments?.accept(v); | 2020 arguments?.accept(v); |
| 2006 } | 2021 } |
| 2007 | 2022 |
| 2008 transformChildren(Transformer v) { | 2023 transformChildren(Transformer v) { |
| 2009 if (receiver != null) { | 2024 if (receiver != null) { |
| 2010 receiver = receiver.accept(v); | 2025 receiver = receiver.accept(v); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 types.hierarchy.getTypeAsInstanceOf(types.thisType, superclass); | 2063 types.hierarchy.getTypeAsInstanceOf(types.thisType, superclass); |
| 2049 var returnType = Substitution | 2064 var returnType = Substitution |
| 2050 .fromInterfaceType(receiverType) | 2065 .fromInterfaceType(receiverType) |
| 2051 .substituteType(interfaceTarget.function.returnType); | 2066 .substituteType(interfaceTarget.function.returnType); |
| 2052 return Substitution | 2067 return Substitution |
| 2053 .fromPairs(interfaceTarget.function.typeParameters, arguments.types) | 2068 .fromPairs(interfaceTarget.function.typeParameters, arguments.types) |
| 2054 .substituteType(returnType); | 2069 .substituteType(returnType); |
| 2055 } | 2070 } |
| 2056 | 2071 |
| 2057 accept(ExpressionVisitor v) => v.visitSuperMethodInvocation(this); | 2072 accept(ExpressionVisitor v) => v.visitSuperMethodInvocation(this); |
| 2073 accept1(ExpressionVisitor1 v, arg) => v.visitSuperMethodInvocation(this, arg); |
| 2058 | 2074 |
| 2059 visitChildren(Visitor v) { | 2075 visitChildren(Visitor v) { |
| 2060 name?.accept(v); | 2076 name?.accept(v); |
| 2061 arguments?.accept(v); | 2077 arguments?.accept(v); |
| 2062 } | 2078 } |
| 2063 | 2079 |
| 2064 transformChildren(Transformer v) { | 2080 transformChildren(Transformer v) { |
| 2065 if (arguments != null) { | 2081 if (arguments != null) { |
| 2066 arguments = arguments.accept(v); | 2082 arguments = arguments.accept(v); |
| 2067 arguments?.parent = this; | 2083 arguments?.parent = this; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2097 targetReference = getMemberReference(target); | 2113 targetReference = getMemberReference(target); |
| 2098 } | 2114 } |
| 2099 | 2115 |
| 2100 DartType getStaticType(TypeEnvironment types) { | 2116 DartType getStaticType(TypeEnvironment types) { |
| 2101 return Substitution | 2117 return Substitution |
| 2102 .fromPairs(target.function.typeParameters, arguments.types) | 2118 .fromPairs(target.function.typeParameters, arguments.types) |
| 2103 .substituteType(target.function.returnType); | 2119 .substituteType(target.function.returnType); |
| 2104 } | 2120 } |
| 2105 | 2121 |
| 2106 accept(ExpressionVisitor v) => v.visitStaticInvocation(this); | 2122 accept(ExpressionVisitor v) => v.visitStaticInvocation(this); |
| 2123 accept1(ExpressionVisitor1 v, arg) => v.visitStaticInvocation(this, arg); |
| 2107 | 2124 |
| 2108 visitChildren(Visitor v) { | 2125 visitChildren(Visitor v) { |
| 2109 target?.acceptReference(v); | 2126 target?.acceptReference(v); |
| 2110 arguments?.accept(v); | 2127 arguments?.accept(v); |
| 2111 } | 2128 } |
| 2112 | 2129 |
| 2113 transformChildren(Transformer v) { | 2130 transformChildren(Transformer v) { |
| 2114 if (arguments != null) { | 2131 if (arguments != null) { |
| 2115 arguments = arguments.accept(v); | 2132 arguments = arguments.accept(v); |
| 2116 arguments?.parent = this; | 2133 arguments?.parent = this; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 targetReference = getMemberReference(target); | 2165 targetReference = getMemberReference(target); |
| 2149 } | 2166 } |
| 2150 | 2167 |
| 2151 DartType getStaticType(TypeEnvironment types) { | 2168 DartType getStaticType(TypeEnvironment types) { |
| 2152 return arguments.types.isEmpty | 2169 return arguments.types.isEmpty |
| 2153 ? target.enclosingClass.rawType | 2170 ? target.enclosingClass.rawType |
| 2154 : new InterfaceType(target.enclosingClass, arguments.types); | 2171 : new InterfaceType(target.enclosingClass, arguments.types); |
| 2155 } | 2172 } |
| 2156 | 2173 |
| 2157 accept(ExpressionVisitor v) => v.visitConstructorInvocation(this); | 2174 accept(ExpressionVisitor v) => v.visitConstructorInvocation(this); |
| 2175 accept1(ExpressionVisitor1 v, arg) => v.visitConstructorInvocation(this, arg); |
| 2158 | 2176 |
| 2159 visitChildren(Visitor v) { | 2177 visitChildren(Visitor v) { |
| 2160 target?.acceptReference(v); | 2178 target?.acceptReference(v); |
| 2161 arguments?.accept(v); | 2179 arguments?.accept(v); |
| 2162 } | 2180 } |
| 2163 | 2181 |
| 2164 transformChildren(Transformer v) { | 2182 transformChildren(Transformer v) { |
| 2165 if (arguments != null) { | 2183 if (arguments != null) { |
| 2166 arguments = arguments.accept(v); | 2184 arguments = arguments.accept(v); |
| 2167 arguments?.parent = this; | 2185 arguments?.parent = this; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2182 class Not extends Expression { | 2200 class Not extends Expression { |
| 2183 Expression operand; | 2201 Expression operand; |
| 2184 | 2202 |
| 2185 Not(this.operand) { | 2203 Not(this.operand) { |
| 2186 operand?.parent = this; | 2204 operand?.parent = this; |
| 2187 } | 2205 } |
| 2188 | 2206 |
| 2189 DartType getStaticType(TypeEnvironment types) => types.boolType; | 2207 DartType getStaticType(TypeEnvironment types) => types.boolType; |
| 2190 | 2208 |
| 2191 accept(ExpressionVisitor v) => v.visitNot(this); | 2209 accept(ExpressionVisitor v) => v.visitNot(this); |
| 2210 accept1(ExpressionVisitor1 v, arg) => v.visitNot(this, arg); |
| 2192 | 2211 |
| 2193 visitChildren(Visitor v) { | 2212 visitChildren(Visitor v) { |
| 2194 operand?.accept(v); | 2213 operand?.accept(v); |
| 2195 } | 2214 } |
| 2196 | 2215 |
| 2197 transformChildren(Transformer v) { | 2216 transformChildren(Transformer v) { |
| 2198 if (operand != null) { | 2217 if (operand != null) { |
| 2199 operand = operand.accept(v); | 2218 operand = operand.accept(v); |
| 2200 operand?.parent = this; | 2219 operand?.parent = this; |
| 2201 } | 2220 } |
| 2202 } | 2221 } |
| 2203 } | 2222 } |
| 2204 | 2223 |
| 2205 /// Expression of form `x && y` or `x || y` | 2224 /// Expression of form `x && y` or `x || y` |
| 2206 class LogicalExpression extends Expression { | 2225 class LogicalExpression extends Expression { |
| 2207 Expression left; | 2226 Expression left; |
| 2208 String operator; // && or || or ?? | 2227 String operator; // && or || or ?? |
| 2209 Expression right; | 2228 Expression right; |
| 2210 | 2229 |
| 2211 LogicalExpression(this.left, this.operator, this.right) { | 2230 LogicalExpression(this.left, this.operator, this.right) { |
| 2212 left?.parent = this; | 2231 left?.parent = this; |
| 2213 right?.parent = this; | 2232 right?.parent = this; |
| 2214 } | 2233 } |
| 2215 | 2234 |
| 2216 DartType getStaticType(TypeEnvironment types) => types.boolType; | 2235 DartType getStaticType(TypeEnvironment types) => types.boolType; |
| 2217 | 2236 |
| 2218 accept(ExpressionVisitor v) => v.visitLogicalExpression(this); | 2237 accept(ExpressionVisitor v) => v.visitLogicalExpression(this); |
| 2238 accept1(ExpressionVisitor1 v, arg) => v.visitLogicalExpression(this, arg); |
| 2219 | 2239 |
| 2220 visitChildren(Visitor v) { | 2240 visitChildren(Visitor v) { |
| 2221 left?.accept(v); | 2241 left?.accept(v); |
| 2222 right?.accept(v); | 2242 right?.accept(v); |
| 2223 } | 2243 } |
| 2224 | 2244 |
| 2225 transformChildren(Transformer v) { | 2245 transformChildren(Transformer v) { |
| 2226 if (left != null) { | 2246 if (left != null) { |
| 2227 left = left.accept(v); | 2247 left = left.accept(v); |
| 2228 left?.parent = this; | 2248 left?.parent = this; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2246 ConditionalExpression( | 2266 ConditionalExpression( |
| 2247 this.condition, this.then, this.otherwise, this.staticType) { | 2267 this.condition, this.then, this.otherwise, this.staticType) { |
| 2248 condition?.parent = this; | 2268 condition?.parent = this; |
| 2249 then?.parent = this; | 2269 then?.parent = this; |
| 2250 otherwise?.parent = this; | 2270 otherwise?.parent = this; |
| 2251 } | 2271 } |
| 2252 | 2272 |
| 2253 DartType getStaticType(TypeEnvironment types) => staticType; | 2273 DartType getStaticType(TypeEnvironment types) => staticType; |
| 2254 | 2274 |
| 2255 accept(ExpressionVisitor v) => v.visitConditionalExpression(this); | 2275 accept(ExpressionVisitor v) => v.visitConditionalExpression(this); |
| 2276 accept1(ExpressionVisitor1 v, arg) => v.visitConditionalExpression(this, arg); |
| 2256 | 2277 |
| 2257 visitChildren(Visitor v) { | 2278 visitChildren(Visitor v) { |
| 2258 condition?.accept(v); | 2279 condition?.accept(v); |
| 2259 then?.accept(v); | 2280 then?.accept(v); |
| 2260 otherwise?.accept(v); | 2281 otherwise?.accept(v); |
| 2261 staticType?.accept(v); | 2282 staticType?.accept(v); |
| 2262 } | 2283 } |
| 2263 | 2284 |
| 2264 transformChildren(Transformer v) { | 2285 transformChildren(Transformer v) { |
| 2265 if (condition != null) { | 2286 if (condition != null) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2290 class StringConcatenation extends Expression { | 2311 class StringConcatenation extends Expression { |
| 2291 final List<Expression> expressions; | 2312 final List<Expression> expressions; |
| 2292 | 2313 |
| 2293 StringConcatenation(this.expressions) { | 2314 StringConcatenation(this.expressions) { |
| 2294 setParents(expressions, this); | 2315 setParents(expressions, this); |
| 2295 } | 2316 } |
| 2296 | 2317 |
| 2297 DartType getStaticType(TypeEnvironment types) => types.stringType; | 2318 DartType getStaticType(TypeEnvironment types) => types.stringType; |
| 2298 | 2319 |
| 2299 accept(ExpressionVisitor v) => v.visitStringConcatenation(this); | 2320 accept(ExpressionVisitor v) => v.visitStringConcatenation(this); |
| 2321 accept1(ExpressionVisitor1 v, arg) => v.visitStringConcatenation(this, arg); |
| 2300 | 2322 |
| 2301 visitChildren(Visitor v) { | 2323 visitChildren(Visitor v) { |
| 2302 visitList(expressions, v); | 2324 visitList(expressions, v); |
| 2303 } | 2325 } |
| 2304 | 2326 |
| 2305 transformChildren(Transformer v) { | 2327 transformChildren(Transformer v) { |
| 2306 transformList(expressions, v, this); | 2328 transformList(expressions, v, this); |
| 2307 } | 2329 } |
| 2308 } | 2330 } |
| 2309 | 2331 |
| 2310 /// Expression of form `x is T`. | 2332 /// Expression of form `x is T`. |
| 2311 class IsExpression extends Expression { | 2333 class IsExpression extends Expression { |
| 2312 Expression operand; | 2334 Expression operand; |
| 2313 DartType type; | 2335 DartType type; |
| 2314 | 2336 |
| 2315 IsExpression(this.operand, this.type) { | 2337 IsExpression(this.operand, this.type) { |
| 2316 operand?.parent = this; | 2338 operand?.parent = this; |
| 2317 } | 2339 } |
| 2318 | 2340 |
| 2319 DartType getStaticType(TypeEnvironment types) => types.boolType; | 2341 DartType getStaticType(TypeEnvironment types) => types.boolType; |
| 2320 | 2342 |
| 2321 accept(ExpressionVisitor v) => v.visitIsExpression(this); | 2343 accept(ExpressionVisitor v) => v.visitIsExpression(this); |
| 2344 accept1(ExpressionVisitor1 v, arg) => v.visitIsExpression(this, arg); |
| 2322 | 2345 |
| 2323 visitChildren(Visitor v) { | 2346 visitChildren(Visitor v) { |
| 2324 operand?.accept(v); | 2347 operand?.accept(v); |
| 2325 type?.accept(v); | 2348 type?.accept(v); |
| 2326 } | 2349 } |
| 2327 | 2350 |
| 2328 transformChildren(Transformer v) { | 2351 transformChildren(Transformer v) { |
| 2329 if (operand != null) { | 2352 if (operand != null) { |
| 2330 operand = operand.accept(v); | 2353 operand = operand.accept(v); |
| 2331 operand?.parent = this; | 2354 operand?.parent = this; |
| 2332 } | 2355 } |
| 2333 type = v.visitDartType(type); | 2356 type = v.visitDartType(type); |
| 2334 } | 2357 } |
| 2335 } | 2358 } |
| 2336 | 2359 |
| 2337 /// Expression of form `x as T`. | 2360 /// Expression of form `x as T`. |
| 2338 class AsExpression extends Expression { | 2361 class AsExpression extends Expression { |
| 2339 Expression operand; | 2362 Expression operand; |
| 2340 DartType type; | 2363 DartType type; |
| 2341 | 2364 |
| 2342 AsExpression(this.operand, this.type) { | 2365 AsExpression(this.operand, this.type) { |
| 2343 operand?.parent = this; | 2366 operand?.parent = this; |
| 2344 } | 2367 } |
| 2345 | 2368 |
| 2346 DartType getStaticType(TypeEnvironment types) => type; | 2369 DartType getStaticType(TypeEnvironment types) => type; |
| 2347 | 2370 |
| 2348 accept(ExpressionVisitor v) => v.visitAsExpression(this); | 2371 accept(ExpressionVisitor v) => v.visitAsExpression(this); |
| 2372 accept1(ExpressionVisitor1 v, arg) => v.visitAsExpression(this, arg); |
| 2349 | 2373 |
| 2350 visitChildren(Visitor v) { | 2374 visitChildren(Visitor v) { |
| 2351 operand?.accept(v); | 2375 operand?.accept(v); |
| 2352 type?.accept(v); | 2376 type?.accept(v); |
| 2353 } | 2377 } |
| 2354 | 2378 |
| 2355 transformChildren(Transformer v) { | 2379 transformChildren(Transformer v) { |
| 2356 if (operand != null) { | 2380 if (operand != null) { |
| 2357 operand = operand.accept(v); | 2381 operand = operand.accept(v); |
| 2358 operand?.parent = this; | 2382 operand?.parent = this; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2370 } | 2394 } |
| 2371 | 2395 |
| 2372 class StringLiteral extends BasicLiteral { | 2396 class StringLiteral extends BasicLiteral { |
| 2373 String value; | 2397 String value; |
| 2374 | 2398 |
| 2375 StringLiteral(this.value); | 2399 StringLiteral(this.value); |
| 2376 | 2400 |
| 2377 DartType getStaticType(TypeEnvironment types) => types.stringType; | 2401 DartType getStaticType(TypeEnvironment types) => types.stringType; |
| 2378 | 2402 |
| 2379 accept(ExpressionVisitor v) => v.visitStringLiteral(this); | 2403 accept(ExpressionVisitor v) => v.visitStringLiteral(this); |
| 2404 accept1(ExpressionVisitor1 v, arg) => v.visitStringLiteral(this, arg); |
| 2380 } | 2405 } |
| 2381 | 2406 |
| 2382 class IntLiteral extends BasicLiteral { | 2407 class IntLiteral extends BasicLiteral { |
| 2383 int value; | 2408 int value; |
| 2384 | 2409 |
| 2385 IntLiteral(this.value); | 2410 IntLiteral(this.value); |
| 2386 | 2411 |
| 2387 DartType getStaticType(TypeEnvironment types) => types.intType; | 2412 DartType getStaticType(TypeEnvironment types) => types.intType; |
| 2388 | 2413 |
| 2389 accept(ExpressionVisitor v) => v.visitIntLiteral(this); | 2414 accept(ExpressionVisitor v) => v.visitIntLiteral(this); |
| 2415 accept1(ExpressionVisitor1 v, arg) => v.visitIntLiteral(this, arg); |
| 2390 } | 2416 } |
| 2391 | 2417 |
| 2392 class DoubleLiteral extends BasicLiteral { | 2418 class DoubleLiteral extends BasicLiteral { |
| 2393 double value; | 2419 double value; |
| 2394 | 2420 |
| 2395 DoubleLiteral(this.value); | 2421 DoubleLiteral(this.value); |
| 2396 | 2422 |
| 2397 DartType getStaticType(TypeEnvironment types) => types.doubleType; | 2423 DartType getStaticType(TypeEnvironment types) => types.doubleType; |
| 2398 | 2424 |
| 2399 accept(ExpressionVisitor v) => v.visitDoubleLiteral(this); | 2425 accept(ExpressionVisitor v) => v.visitDoubleLiteral(this); |
| 2426 accept1(ExpressionVisitor1 v, arg) => v.visitDoubleLiteral(this, arg); |
| 2400 } | 2427 } |
| 2401 | 2428 |
| 2402 class BoolLiteral extends BasicLiteral { | 2429 class BoolLiteral extends BasicLiteral { |
| 2403 bool value; | 2430 bool value; |
| 2404 | 2431 |
| 2405 BoolLiteral(this.value); | 2432 BoolLiteral(this.value); |
| 2406 | 2433 |
| 2407 DartType getStaticType(TypeEnvironment types) => types.boolType; | 2434 DartType getStaticType(TypeEnvironment types) => types.boolType; |
| 2408 | 2435 |
| 2409 accept(ExpressionVisitor v) => v.visitBoolLiteral(this); | 2436 accept(ExpressionVisitor v) => v.visitBoolLiteral(this); |
| 2437 accept1(ExpressionVisitor1 v, arg) => v.visitBoolLiteral(this, arg); |
| 2410 } | 2438 } |
| 2411 | 2439 |
| 2412 class NullLiteral extends BasicLiteral { | 2440 class NullLiteral extends BasicLiteral { |
| 2413 Object get value => null; | 2441 Object get value => null; |
| 2414 | 2442 |
| 2415 DartType getStaticType(TypeEnvironment types) => const BottomType(); | 2443 DartType getStaticType(TypeEnvironment types) => const BottomType(); |
| 2416 | 2444 |
| 2417 accept(ExpressionVisitor v) => v.visitNullLiteral(this); | 2445 accept(ExpressionVisitor v) => v.visitNullLiteral(this); |
| 2446 accept1(ExpressionVisitor1 v, arg) => v.visitNullLiteral(this, arg); |
| 2418 } | 2447 } |
| 2419 | 2448 |
| 2420 class SymbolLiteral extends Expression { | 2449 class SymbolLiteral extends Expression { |
| 2421 String value; // Everything strictly after the '#'. | 2450 String value; // Everything strictly after the '#'. |
| 2422 | 2451 |
| 2423 SymbolLiteral(this.value); | 2452 SymbolLiteral(this.value); |
| 2424 | 2453 |
| 2425 DartType getStaticType(TypeEnvironment types) => types.symbolType; | 2454 DartType getStaticType(TypeEnvironment types) => types.symbolType; |
| 2426 | 2455 |
| 2427 accept(ExpressionVisitor v) => v.visitSymbolLiteral(this); | 2456 accept(ExpressionVisitor v) => v.visitSymbolLiteral(this); |
| 2457 accept1(ExpressionVisitor1 v, arg) => v.visitSymbolLiteral(this, arg); |
| 2428 | 2458 |
| 2429 visitChildren(Visitor v) {} | 2459 visitChildren(Visitor v) {} |
| 2430 transformChildren(Transformer v) {} | 2460 transformChildren(Transformer v) {} |
| 2431 } | 2461 } |
| 2432 | 2462 |
| 2433 class TypeLiteral extends Expression { | 2463 class TypeLiteral extends Expression { |
| 2434 DartType type; | 2464 DartType type; |
| 2435 | 2465 |
| 2436 TypeLiteral(this.type); | 2466 TypeLiteral(this.type); |
| 2437 | 2467 |
| 2438 DartType getStaticType(TypeEnvironment types) => types.typeType; | 2468 DartType getStaticType(TypeEnvironment types) => types.typeType; |
| 2439 | 2469 |
| 2440 accept(ExpressionVisitor v) => v.visitTypeLiteral(this); | 2470 accept(ExpressionVisitor v) => v.visitTypeLiteral(this); |
| 2471 accept1(ExpressionVisitor1 v, arg) => v.visitTypeLiteral(this, arg); |
| 2441 | 2472 |
| 2442 visitChildren(Visitor v) { | 2473 visitChildren(Visitor v) { |
| 2443 type?.accept(v); | 2474 type?.accept(v); |
| 2444 } | 2475 } |
| 2445 | 2476 |
| 2446 transformChildren(Transformer v) { | 2477 transformChildren(Transformer v) { |
| 2447 type = v.visitDartType(type); | 2478 type = v.visitDartType(type); |
| 2448 } | 2479 } |
| 2449 } | 2480 } |
| 2450 | 2481 |
| 2451 class ThisExpression extends Expression { | 2482 class ThisExpression extends Expression { |
| 2452 DartType getStaticType(TypeEnvironment types) => types.thisType; | 2483 DartType getStaticType(TypeEnvironment types) => types.thisType; |
| 2453 | 2484 |
| 2454 accept(ExpressionVisitor v) => v.visitThisExpression(this); | 2485 accept(ExpressionVisitor v) => v.visitThisExpression(this); |
| 2486 accept1(ExpressionVisitor1 v, arg) => v.visitThisExpression(this, arg); |
| 2455 | 2487 |
| 2456 visitChildren(Visitor v) {} | 2488 visitChildren(Visitor v) {} |
| 2457 transformChildren(Transformer v) {} | 2489 transformChildren(Transformer v) {} |
| 2458 } | 2490 } |
| 2459 | 2491 |
| 2460 class Rethrow extends Expression { | 2492 class Rethrow extends Expression { |
| 2461 DartType getStaticType(TypeEnvironment types) => const BottomType(); | 2493 DartType getStaticType(TypeEnvironment types) => const BottomType(); |
| 2462 | 2494 |
| 2463 accept(ExpressionVisitor v) => v.visitRethrow(this); | 2495 accept(ExpressionVisitor v) => v.visitRethrow(this); |
| 2496 accept1(ExpressionVisitor1 v, arg) => v.visitRethrow(this, arg); |
| 2464 | 2497 |
| 2465 visitChildren(Visitor v) {} | 2498 visitChildren(Visitor v) {} |
| 2466 transformChildren(Transformer v) {} | 2499 transformChildren(Transformer v) {} |
| 2467 } | 2500 } |
| 2468 | 2501 |
| 2469 class Throw extends Expression { | 2502 class Throw extends Expression { |
| 2470 Expression expression; | 2503 Expression expression; |
| 2471 | 2504 |
| 2472 Throw(this.expression) { | 2505 Throw(this.expression) { |
| 2473 expression?.parent = this; | 2506 expression?.parent = this; |
| 2474 } | 2507 } |
| 2475 | 2508 |
| 2476 DartType getStaticType(TypeEnvironment types) => const BottomType(); | 2509 DartType getStaticType(TypeEnvironment types) => const BottomType(); |
| 2477 | 2510 |
| 2478 accept(ExpressionVisitor v) => v.visitThrow(this); | 2511 accept(ExpressionVisitor v) => v.visitThrow(this); |
| 2512 accept1(ExpressionVisitor1 v, arg) => v.visitThrow(this, arg); |
| 2479 | 2513 |
| 2480 visitChildren(Visitor v) { | 2514 visitChildren(Visitor v) { |
| 2481 expression?.accept(v); | 2515 expression?.accept(v); |
| 2482 } | 2516 } |
| 2483 | 2517 |
| 2484 transformChildren(Transformer v) { | 2518 transformChildren(Transformer v) { |
| 2485 if (expression != null) { | 2519 if (expression != null) { |
| 2486 expression = expression.accept(v); | 2520 expression = expression.accept(v); |
| 2487 expression?.parent = this; | 2521 expression?.parent = this; |
| 2488 } | 2522 } |
| 2489 } | 2523 } |
| 2490 } | 2524 } |
| 2491 | 2525 |
| 2492 class ListLiteral extends Expression { | 2526 class ListLiteral extends Expression { |
| 2493 bool isConst; | 2527 bool isConst; |
| 2494 DartType typeArgument; // Not null, defaults to DynamicType. | 2528 DartType typeArgument; // Not null, defaults to DynamicType. |
| 2495 final List<Expression> expressions; | 2529 final List<Expression> expressions; |
| 2496 | 2530 |
| 2497 ListLiteral(this.expressions, | 2531 ListLiteral(this.expressions, |
| 2498 {this.typeArgument: const DynamicType(), this.isConst: false}) { | 2532 {this.typeArgument: const DynamicType(), this.isConst: false}) { |
| 2499 assert(typeArgument != null); | 2533 assert(typeArgument != null); |
| 2500 setParents(expressions, this); | 2534 setParents(expressions, this); |
| 2501 } | 2535 } |
| 2502 | 2536 |
| 2503 DartType getStaticType(TypeEnvironment types) { | 2537 DartType getStaticType(TypeEnvironment types) { |
| 2504 return types.literalListType(typeArgument); | 2538 return types.literalListType(typeArgument); |
| 2505 } | 2539 } |
| 2506 | 2540 |
| 2507 accept(ExpressionVisitor v) => v.visitListLiteral(this); | 2541 accept(ExpressionVisitor v) => v.visitListLiteral(this); |
| 2542 accept1(ExpressionVisitor1 v, arg) => v.visitListLiteral(this, arg); |
| 2508 | 2543 |
| 2509 visitChildren(Visitor v) { | 2544 visitChildren(Visitor v) { |
| 2510 typeArgument?.accept(v); | 2545 typeArgument?.accept(v); |
| 2511 visitList(expressions, v); | 2546 visitList(expressions, v); |
| 2512 } | 2547 } |
| 2513 | 2548 |
| 2514 transformChildren(Transformer v) { | 2549 transformChildren(Transformer v) { |
| 2515 typeArgument = v.visitDartType(typeArgument); | 2550 typeArgument = v.visitDartType(typeArgument); |
| 2516 transformList(expressions, v, this); | 2551 transformList(expressions, v, this); |
| 2517 } | 2552 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2530 assert(keyType != null); | 2565 assert(keyType != null); |
| 2531 assert(valueType != null); | 2566 assert(valueType != null); |
| 2532 setParents(entries, this); | 2567 setParents(entries, this); |
| 2533 } | 2568 } |
| 2534 | 2569 |
| 2535 DartType getStaticType(TypeEnvironment types) { | 2570 DartType getStaticType(TypeEnvironment types) { |
| 2536 return types.literalMapType(keyType, valueType); | 2571 return types.literalMapType(keyType, valueType); |
| 2537 } | 2572 } |
| 2538 | 2573 |
| 2539 accept(ExpressionVisitor v) => v.visitMapLiteral(this); | 2574 accept(ExpressionVisitor v) => v.visitMapLiteral(this); |
| 2575 accept1(ExpressionVisitor1 v, arg) => v.visitMapLiteral(this, arg); |
| 2540 | 2576 |
| 2541 visitChildren(Visitor v) { | 2577 visitChildren(Visitor v) { |
| 2542 keyType?.accept(v); | 2578 keyType?.accept(v); |
| 2543 valueType?.accept(v); | 2579 valueType?.accept(v); |
| 2544 visitList(entries, v); | 2580 visitList(entries, v); |
| 2545 } | 2581 } |
| 2546 | 2582 |
| 2547 transformChildren(Transformer v) { | 2583 transformChildren(Transformer v) { |
| 2548 keyType = v.visitDartType(keyType); | 2584 keyType = v.visitDartType(keyType); |
| 2549 valueType = v.visitDartType(valueType); | 2585 valueType = v.visitDartType(valueType); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 | 2621 |
| 2586 AwaitExpression(this.operand) { | 2622 AwaitExpression(this.operand) { |
| 2587 operand?.parent = this; | 2623 operand?.parent = this; |
| 2588 } | 2624 } |
| 2589 | 2625 |
| 2590 DartType getStaticType(TypeEnvironment types) { | 2626 DartType getStaticType(TypeEnvironment types) { |
| 2591 return types.unfutureType(operand.getStaticType(types)); | 2627 return types.unfutureType(operand.getStaticType(types)); |
| 2592 } | 2628 } |
| 2593 | 2629 |
| 2594 accept(ExpressionVisitor v) => v.visitAwaitExpression(this); | 2630 accept(ExpressionVisitor v) => v.visitAwaitExpression(this); |
| 2631 accept1(ExpressionVisitor1 v, arg) => v.visitAwaitExpression(this, arg); |
| 2595 | 2632 |
| 2596 visitChildren(Visitor v) { | 2633 visitChildren(Visitor v) { |
| 2597 operand?.accept(v); | 2634 operand?.accept(v); |
| 2598 } | 2635 } |
| 2599 | 2636 |
| 2600 transformChildren(Transformer v) { | 2637 transformChildren(Transformer v) { |
| 2601 if (operand != null) { | 2638 if (operand != null) { |
| 2602 operand = operand.accept(v); | 2639 operand = operand.accept(v); |
| 2603 operand?.parent = this; | 2640 operand?.parent = this; |
| 2604 } | 2641 } |
| 2605 } | 2642 } |
| 2606 } | 2643 } |
| 2607 | 2644 |
| 2608 /// Expression of form `(x,y) => ...` or `(x,y) { ... }` | 2645 /// Expression of form `(x,y) => ...` or `(x,y) { ... }` |
| 2609 /// | 2646 /// |
| 2610 /// The arrow-body form `=> e` is desugared into `return e;`. | 2647 /// The arrow-body form `=> e` is desugared into `return e;`. |
| 2611 class FunctionExpression extends Expression { | 2648 class FunctionExpression extends Expression { |
| 2612 FunctionNode function; | 2649 FunctionNode function; |
| 2613 | 2650 |
| 2614 FunctionExpression(this.function) { | 2651 FunctionExpression(this.function) { |
| 2615 function?.parent = this; | 2652 function?.parent = this; |
| 2616 } | 2653 } |
| 2617 | 2654 |
| 2618 DartType getStaticType(TypeEnvironment types) => function.functionType; | 2655 DartType getStaticType(TypeEnvironment types) => function.functionType; |
| 2619 | 2656 |
| 2620 accept(ExpressionVisitor v) => v.visitFunctionExpression(this); | 2657 accept(ExpressionVisitor v) => v.visitFunctionExpression(this); |
| 2658 accept1(ExpressionVisitor1 v, arg) => v.visitFunctionExpression(this, arg); |
| 2621 | 2659 |
| 2622 visitChildren(Visitor v) { | 2660 visitChildren(Visitor v) { |
| 2623 function?.accept(v); | 2661 function?.accept(v); |
| 2624 } | 2662 } |
| 2625 | 2663 |
| 2626 transformChildren(Transformer v) { | 2664 transformChildren(Transformer v) { |
| 2627 if (function != null) { | 2665 if (function != null) { |
| 2628 function = function.accept(v); | 2666 function = function.accept(v); |
| 2629 function?.parent = this; | 2667 function?.parent = this; |
| 2630 } | 2668 } |
| 2631 } | 2669 } |
| 2632 } | 2670 } |
| 2633 | 2671 |
| 2634 /// Synthetic expression of form `let v = x in y` | 2672 /// Synthetic expression of form `let v = x in y` |
| 2635 class Let extends Expression { | 2673 class Let extends Expression { |
| 2636 VariableDeclaration variable; // Must have an initializer. | 2674 VariableDeclaration variable; // Must have an initializer. |
| 2637 Expression body; | 2675 Expression body; |
| 2638 | 2676 |
| 2639 Let(this.variable, this.body) { | 2677 Let(this.variable, this.body) { |
| 2640 variable?.parent = this; | 2678 variable?.parent = this; |
| 2641 body?.parent = this; | 2679 body?.parent = this; |
| 2642 } | 2680 } |
| 2643 | 2681 |
| 2644 DartType getStaticType(TypeEnvironment types) => body.getStaticType(types); | 2682 DartType getStaticType(TypeEnvironment types) => body.getStaticType(types); |
| 2645 | 2683 |
| 2646 accept(ExpressionVisitor v) => v.visitLet(this); | 2684 accept(ExpressionVisitor v) => v.visitLet(this); |
| 2685 accept1(ExpressionVisitor1 v, arg) => v.visitLet(this, arg); |
| 2647 | 2686 |
| 2648 visitChildren(Visitor v) { | 2687 visitChildren(Visitor v) { |
| 2649 variable?.accept(v); | 2688 variable?.accept(v); |
| 2650 body?.accept(v); | 2689 body?.accept(v); |
| 2651 } | 2690 } |
| 2652 | 2691 |
| 2653 transformChildren(Transformer v) { | 2692 transformChildren(Transformer v) { |
| 2654 if (variable != null) { | 2693 if (variable != null) { |
| 2655 variable = variable.accept(v); | 2694 variable = variable.accept(v); |
| 2656 variable?.parent = this; | 2695 variable?.parent = this; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2678 /// Reference to a deferred import in the enclosing library. | 2717 /// Reference to a deferred import in the enclosing library. |
| 2679 DeferredImport import; | 2718 DeferredImport import; |
| 2680 | 2719 |
| 2681 LoadLibrary(this.import); | 2720 LoadLibrary(this.import); |
| 2682 | 2721 |
| 2683 DartType getStaticType(TypeEnvironment types) { | 2722 DartType getStaticType(TypeEnvironment types) { |
| 2684 return types.futureType(const DynamicType()); | 2723 return types.futureType(const DynamicType()); |
| 2685 } | 2724 } |
| 2686 | 2725 |
| 2687 accept(ExpressionVisitor v) => v.visitLoadLibrary(this); | 2726 accept(ExpressionVisitor v) => v.visitLoadLibrary(this); |
| 2727 accept1(ExpressionVisitor1 v, arg) => v.visitLoadLibrary(this, arg); |
| 2688 | 2728 |
| 2689 visitChildren(Visitor v) {} | 2729 visitChildren(Visitor v) {} |
| 2690 transformChildren(Transformer v) {} | 2730 transformChildren(Transformer v) {} |
| 2691 } | 2731 } |
| 2692 | 2732 |
| 2693 /// Checks that the given deferred import has been marked as 'loaded'. | 2733 /// Checks that the given deferred import has been marked as 'loaded'. |
| 2694 class CheckLibraryIsLoaded extends Expression { | 2734 class CheckLibraryIsLoaded extends Expression { |
| 2695 /// Reference to a deferred import in the enclosing library. | 2735 /// Reference to a deferred import in the enclosing library. |
| 2696 DeferredImport import; | 2736 DeferredImport import; |
| 2697 | 2737 |
| 2698 CheckLibraryIsLoaded(this.import); | 2738 CheckLibraryIsLoaded(this.import); |
| 2699 | 2739 |
| 2700 DartType getStaticType(TypeEnvironment types) { | 2740 DartType getStaticType(TypeEnvironment types) { |
| 2701 return types.objectType; | 2741 return types.objectType; |
| 2702 } | 2742 } |
| 2703 | 2743 |
| 2704 accept(ExpressionVisitor v) => v.visitCheckLibraryIsLoaded(this); | 2744 accept(ExpressionVisitor v) => v.visitCheckLibraryIsLoaded(this); |
| 2745 accept1(ExpressionVisitor1 v, arg) => v.visitCheckLibraryIsLoaded(this, arg); |
| 2705 | 2746 |
| 2706 visitChildren(Visitor v) {} | 2747 visitChildren(Visitor v) {} |
| 2707 transformChildren(Transformer v) {} | 2748 transformChildren(Transformer v) {} |
| 2708 } | 2749 } |
| 2709 | 2750 |
| 2710 // ------------------------------------------------------------------------ | 2751 // ------------------------------------------------------------------------ |
| 2711 // STATEMENTS | 2752 // STATEMENTS |
| 2712 // ------------------------------------------------------------------------ | 2753 // ------------------------------------------------------------------------ |
| 2713 | 2754 |
| 2714 abstract class Statement extends TreeNode { | 2755 abstract class Statement extends TreeNode { |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4024 /// library has not been assigned a canonical name yet. | 4065 /// library has not been assigned a canonical name yet. |
| 4025 /// | 4066 /// |
| 4026 /// Returns `null` if the library is `null`. | 4067 /// Returns `null` if the library is `null`. |
| 4027 CanonicalName getCanonicalNameOfLibrary(Library library) { | 4068 CanonicalName getCanonicalNameOfLibrary(Library library) { |
| 4028 if (library == null) return null; | 4069 if (library == null) return null; |
| 4029 if (library.canonicalName == null) { | 4070 if (library.canonicalName == null) { |
| 4030 throw '$library has no canonical name'; | 4071 throw '$library has no canonical name'; |
| 4031 } | 4072 } |
| 4032 return library.canonicalName; | 4073 return library.canonicalName; |
| 4033 } | 4074 } |
| OLD | NEW |