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