Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: pkg/compiler/lib/src/resolution/send_structure.dart

Issue 1313323002: Add visitor methods specific to ??= to SemanticSendVisitor. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.resolution.send_structure; 5 library dart2js.resolution.send_structure;
6 6
7 import '../dart_types.dart'; 7 import '../dart_types.dart';
8 import '../diagnostics/spannable.dart' show 8 import '../diagnostics/spannable.dart' show
9 SpannableAssertionFailure; 9 SpannableAssertionFailure;
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 arg); 1555 arg);
1556 case CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER: 1556 case CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER:
1557 return visitor.visitUnresolvedTopLevelSetterCompound( 1557 return visitor.visitUnresolvedTopLevelSetterCompound(
1558 node, 1558 node,
1559 compoundSemantics.getter, 1559 compoundSemantics.getter,
1560 compoundSemantics.setter, 1560 compoundSemantics.setter,
1561 operator, 1561 operator,
1562 node.arguments.single, 1562 node.arguments.single,
1563 arg); 1563 arg);
1564 case CompoundAccessKind.SUPER_FIELD_FIELD: 1564 case CompoundAccessKind.SUPER_FIELD_FIELD:
1565 // TODO(johnniwinther): Handle this. 1565 return visitor.visitSuperFieldFieldCompound(
1566 break; 1566 node,
1567 compoundSemantics.getter,
1568 compoundSemantics.setter,
1569 operator,
1570 node.arguments.single,
1571 arg);
1567 case CompoundAccessKind.SUPER_GETTER_SETTER: 1572 case CompoundAccessKind.SUPER_GETTER_SETTER:
1568 return visitor.visitSuperGetterSetterCompound( 1573 return visitor.visitSuperGetterSetterCompound(
1569 node, 1574 node,
1570 compoundSemantics.getter, 1575 compoundSemantics.getter,
1571 compoundSemantics.setter, 1576 compoundSemantics.setter,
1572 operator, 1577 operator,
1573 node.arguments.single, 1578 node.arguments.single,
1574 arg); 1579 arg);
1575 case CompoundAccessKind.SUPER_GETTER_FIELD: 1580 case CompoundAccessKind.SUPER_GETTER_FIELD:
1576 return visitor.visitSuperGetterFieldCompound( 1581 return visitor.visitSuperGetterFieldCompound(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 } 1620 }
1616 break; 1621 break;
1617 } 1622 }
1618 throw new SpannableAssertionFailure(node, 1623 throw new SpannableAssertionFailure(node,
1619 "Invalid compound assigment: ${semantics}"); 1624 "Invalid compound assigment: ${semantics}");
1620 } 1625 }
1621 1626
1622 String toString() => 'compound($operator,$semantics)'; 1627 String toString() => 'compound($operator,$semantics)';
1623 } 1628 }
1624 1629
1630 /// The structure for a [Send] that is an if-null assignment. For instance
1631 /// `a ??= b`.
1632 class SetIfNullStructure<R, A> implements SendStructure<R, A> {
1633 /// The target of the if-null assignment, i.e. the left-hand side.
1634 final AccessSemantics semantics;
1635
1636 SetIfNullStructure(this.semantics);
1637
1638 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1639 switch (semantics.kind) {
1640 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
1641 return visitor.visitIfNotNullDynamicPropertySetIfNull(
1642 node,
1643 node.receiver,
1644 semantics.name,
1645 node.arguments.single,
1646 arg);
1647 case AccessKind.DYNAMIC_PROPERTY:
1648 return visitor.visitDynamicPropertySetIfNull(
1649 node,
1650 node.receiver,
1651 semantics.name,
1652 node.arguments.single,
1653 arg);
1654 case AccessKind.LOCAL_FUNCTION:
1655 return visitor.visitLocalFunctionSetIfNull(
1656 node,
1657 semantics.element,
1658 node.arguments.single,
1659 arg);
1660 case AccessKind.LOCAL_VARIABLE:
1661 return visitor.visitLocalVariableSetIfNull(
1662 node,
1663 semantics.element,
1664 node.arguments.single,
1665 arg);
1666 case AccessKind.FINAL_LOCAL_VARIABLE:
1667 return visitor.visitFinalLocalVariableSetIfNull(
1668 node,
1669 semantics.element,
1670 node.arguments.single,
1671 arg);
1672 case AccessKind.PARAMETER:
1673 return visitor.visitParameterSetIfNull(
1674 node,
1675 semantics.element,
1676 node.arguments.single,
1677 arg);
1678 case AccessKind.FINAL_PARAMETER:
1679 return visitor.visitFinalParameterSetIfNull(
1680 node,
1681 semantics.element,
1682 node.arguments.single,
1683 arg);
1684 case AccessKind.STATIC_FIELD:
1685 return visitor.visitStaticFieldSetIfNull(
1686 node,
1687 semantics.element,
1688 node.arguments.single,
1689 arg);
1690 case AccessKind.FINAL_STATIC_FIELD:
1691 return visitor.visitFinalStaticFieldSetIfNull(
1692 node,
1693 semantics.element,
1694 node.arguments.single,
1695 arg);
1696 case AccessKind.STATIC_METHOD:
1697 return visitor.visitStaticMethodSetIfNull(
1698 node,
1699 semantics.element,
1700 node.arguments.single,
1701 arg);
1702 case AccessKind.STATIC_GETTER:
1703 // This is not a valid case.
1704 break;
1705 case AccessKind.STATIC_SETTER:
1706 // This is not a valid case.
1707 break;
1708 case AccessKind.TOPLEVEL_FIELD:
1709 return visitor.visitTopLevelFieldSetIfNull(
1710 node,
1711 semantics.element,
1712 node.arguments.single,
1713 arg);
1714 case AccessKind.FINAL_TOPLEVEL_FIELD:
1715 return visitor.visitFinalTopLevelFieldSetIfNull(
1716 node,
1717 semantics.element,
1718 node.arguments.single,
1719 arg);
1720 case AccessKind.TOPLEVEL_METHOD:
1721 return visitor.visitTopLevelMethodSetIfNull(
1722 node,
1723 semantics.element,
1724 node.arguments.single,
1725 arg);
1726 case AccessKind.TOPLEVEL_GETTER:
1727 // This is not a valid case.
1728 break;
1729 case AccessKind.TOPLEVEL_SETTER:
1730 // This is not a valid case.
1731 break;
1732 case AccessKind.CLASS_TYPE_LITERAL:
1733 return visitor.visitClassTypeLiteralSetIfNull(
1734 node,
1735 semantics.constant,
1736 node.arguments.single,
1737 arg);
1738 case AccessKind.TYPEDEF_TYPE_LITERAL:
1739 return visitor.visitTypedefTypeLiteralSetIfNull(
1740 node,
1741 semantics.constant,
1742 node.arguments.single,
1743 arg);
1744 case AccessKind.DYNAMIC_TYPE_LITERAL:
1745 return visitor.visitDynamicTypeLiteralSetIfNull(
1746 node,
1747 semantics.constant,
1748 node.arguments.single,
1749 arg);
1750 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
1751 return visitor.visitTypeVariableTypeLiteralSetIfNull(
1752 node,
1753 semantics.element,
1754 node.arguments.single,
1755 arg);
1756 case AccessKind.EXPRESSION:
1757 // This is not a valid case.
1758 break;
1759 case AccessKind.THIS:
1760 // This is not a valid case.
1761 break;
1762 case AccessKind.THIS_PROPERTY:
1763 return visitor.visitThisPropertySetIfNull(
1764 node,
1765 semantics.name,
1766 node.arguments.single,
1767 arg);
1768 case AccessKind.SUPER_FIELD:
1769 return visitor.visitSuperFieldSetIfNull(
1770 node,
1771 semantics.element,
1772 node.arguments.single,
1773 arg);
1774 case AccessKind.SUPER_FINAL_FIELD:
1775 return visitor.visitFinalSuperFieldSetIfNull(
1776 node,
1777 semantics.element,
1778 node.arguments.single,
1779 arg);
1780 case AccessKind.SUPER_METHOD:
1781 return visitor.visitSuperMethodSetIfNull(
1782 node,
1783 semantics.element,
1784 node.arguments.single,
1785 arg);
1786 case AccessKind.SUPER_GETTER:
1787 // This is not a valid case.
1788 break;
1789 case AccessKind.SUPER_SETTER:
1790 // This is not a valid case.
1791 break;
1792 case AccessKind.CONSTANT:
1793 // TODO(johnniwinther): Should this be a valid case?
1794 break;
1795 case AccessKind.UNRESOLVED_SUPER:
1796 return visitor.visitUnresolvedSuperSetIfNull(
1797 node,
1798 semantics.element,
1799 node.arguments.single,
1800 arg);
1801 case AccessKind.UNRESOLVED:
1802 return visitor.visitUnresolvedSetIfNull(
1803 node,
1804 semantics.element,
1805 node.arguments.single,
1806 arg);
1807 case AccessKind.INVALID:
1808 return visitor.errorInvalidSetIfNull(
1809 node,
1810 semantics.element,
1811 node.arguments.single,
1812 arg);
1813 case AccessKind.COMPOUND:
1814 CompoundAccessSemantics compoundSemantics = semantics;
1815 switch (compoundSemantics.compoundAccessKind) {
1816 case CompoundAccessKind.STATIC_GETTER_SETTER:
1817 return visitor.visitStaticGetterSetterSetIfNull(
1818 node,
1819 compoundSemantics.getter,
1820 compoundSemantics.setter,
1821 node.arguments.single,
1822 arg);
1823 case CompoundAccessKind.STATIC_METHOD_SETTER:
1824 return visitor.visitStaticMethodSetterSetIfNull(
1825 node,
1826 compoundSemantics.getter,
1827 compoundSemantics.setter,
1828 node.arguments.single,
1829 arg);
1830 case CompoundAccessKind.UNRESOLVED_STATIC_GETTER:
1831 return visitor.visitUnresolvedStaticGetterSetIfNull(
1832 node,
1833 compoundSemantics.getter,
1834 compoundSemantics.setter,
1835 node.arguments.single,
1836 arg);
1837 case CompoundAccessKind.UNRESOLVED_STATIC_SETTER:
1838 return visitor.visitUnresolvedStaticSetterSetIfNull(
1839 node,
1840 compoundSemantics.getter,
1841 compoundSemantics.setter,
1842 node.arguments.single,
1843 arg);
1844 case CompoundAccessKind.TOPLEVEL_GETTER_SETTER:
1845 return visitor.visitTopLevelGetterSetterSetIfNull(
1846 node,
1847 compoundSemantics.getter,
1848 compoundSemantics.setter,
1849 node.arguments.single,
1850 arg);
1851 case CompoundAccessKind.TOPLEVEL_METHOD_SETTER:
1852 return visitor.visitTopLevelMethodSetterSetIfNull(
1853 node,
1854 compoundSemantics.getter,
1855 compoundSemantics.setter,
1856 node.arguments.single,
1857 arg);
1858 case CompoundAccessKind.UNRESOLVED_TOPLEVEL_GETTER:
1859 return visitor.visitUnresolvedTopLevelGetterSetIfNull(
1860 node,
1861 compoundSemantics.getter,
1862 compoundSemantics.setter,
1863 node.arguments.single,
1864 arg);
1865 case CompoundAccessKind.UNRESOLVED_TOPLEVEL_SETTER:
1866 return visitor.visitUnresolvedTopLevelSetterSetIfNull(
1867 node,
1868 compoundSemantics.getter,
1869 compoundSemantics.setter,
1870 node.arguments.single,
1871 arg);
1872 case CompoundAccessKind.SUPER_FIELD_FIELD:
1873 return visitor.visitSuperFieldFieldSetIfNull(
1874 node,
1875 compoundSemantics.getter,
1876 compoundSemantics.setter,
1877 node.arguments.single,
1878 arg);
1879 case CompoundAccessKind.SUPER_GETTER_SETTER:
1880 return visitor.visitSuperGetterSetterSetIfNull(
1881 node,
1882 compoundSemantics.getter,
1883 compoundSemantics.setter,
1884 node.arguments.single,
1885 arg);
1886 case CompoundAccessKind.SUPER_GETTER_FIELD:
1887 return visitor.visitSuperGetterFieldSetIfNull(
1888 node,
1889 compoundSemantics.getter,
1890 compoundSemantics.setter,
1891 node.arguments.single,
1892 arg);
1893 case CompoundAccessKind.SUPER_METHOD_SETTER:
1894 return visitor.visitSuperMethodSetterSetIfNull(
1895 node,
1896 compoundSemantics.getter,
1897 compoundSemantics.setter,
1898 node.arguments.single,
1899 arg);
1900 case CompoundAccessKind.SUPER_FIELD_SETTER:
1901 return visitor.visitSuperFieldSetterSetIfNull(
1902 node,
1903 compoundSemantics.getter,
1904 compoundSemantics.setter,
1905 node.arguments.single,
1906 arg);
1907 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
1908 return visitor.visitUnresolvedSuperGetterSetIfNull(
1909 node,
1910 compoundSemantics.getter,
1911 compoundSemantics.setter,
1912 node.arguments.single,
1913 arg);
1914 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
1915 return visitor.visitUnresolvedSuperSetterSetIfNull(
1916 node,
1917 compoundSemantics.getter,
1918 compoundSemantics.setter,
1919 node.arguments.single,
1920 arg);
1921 }
1922 break;
1923 }
1924 throw new SpannableAssertionFailure(node,
1925 "Invalid if-null assigment: ${semantics}");
1926 }
1927
1928 String toString() => 'ifNull($semantics)';
1929 }
1930
1625 /// The structure for a [Send] that is a compound assignment on the index 1931 /// The structure for a [Send] that is a compound assignment on the index
1626 /// operator. For instance `a[b] += c`. 1932 /// operator. For instance `a[b] += c`.
1627 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> { 1933 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> {
1628 /// The target of the index operations. 1934 /// The target of the index operations.
1629 final AccessSemantics semantics; 1935 final AccessSemantics semantics;
1630 1936
1631 /// The assignment operator used in the compound assignment. 1937 /// The assignment operator used in the compound assignment.
1632 final AssignmentOperator operator; 1938 final AssignmentOperator operator;
1633 1939
1634 CompoundIndexSetStructure(this.semantics, this.operator); 1940 CompoundIndexSetStructure(this.semantics, this.operator);
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 ThisConstructorInvokeStructure( 2976 ThisConstructorInvokeStructure(
2671 this.node, this.constructor, this.callStructure); 2977 this.node, this.constructor, this.callStructure);
2672 2978
2673 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { 2979 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
2674 return visitor.visitThisConstructorInvoke( 2980 return visitor.visitThisConstructorInvoke(
2675 node, constructor, node.argumentsNode, callStructure, arg); 2981 node, constructor, node.argumentsNode, callStructure, arg);
2676 } 2982 }
2677 2983
2678 bool get isConstructorInvoke => true; 2984 bool get isConstructorInvoke => true;
2679 } 2985 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698