| OLD | NEW |
| 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.send_structure; | 5 library dart2js.send_structure; |
| 6 | 6 |
| 7 import 'access_semantics.dart'; | 7 import 'access_semantics.dart'; |
| 8 import 'operators.dart'; | 8 import 'operators.dart'; |
| 9 import 'semantic_visitor.dart'; | 9 import 'semantic_visitor.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 arg); | 1012 arg); |
| 1013 case AccessKind.SUPER_METHOD: | 1013 case AccessKind.SUPER_METHOD: |
| 1014 return visitor.visitSuperIndexSet( | 1014 return visitor.visitSuperIndexSet( |
| 1015 node, | 1015 node, |
| 1016 semantics.element, | 1016 semantics.element, |
| 1017 node.arguments.first, | 1017 node.arguments.first, |
| 1018 node.arguments.tail.head, | 1018 node.arguments.tail.head, |
| 1019 arg); | 1019 arg); |
| 1020 case AccessKind.UNRESOLVED_SUPER: | 1020 case AccessKind.UNRESOLVED_SUPER: |
| 1021 case AccessKind.UNRESOLVED: | 1021 case AccessKind.UNRESOLVED: |
| 1022 // TODO(johnniwinther): Support these through [AccessKind.COMPOUND]. | 1022 return visitor.visitUnresolvedSuperIndexSet( |
| 1023 return visitor.errorUnresolvedSuperIndexSet( | |
| 1024 node, | 1023 node, |
| 1025 semantics.element, | 1024 semantics.element, |
| 1026 node.arguments.first, | 1025 node.arguments.first, |
| 1027 node.arguments.tail.head, | 1026 node.arguments.tail.head, |
| 1028 arg); | 1027 arg); |
| 1029 default: | 1028 default: |
| 1030 // This is not a valid case. | 1029 // This is not a valid case. |
| 1031 break; | 1030 break; |
| 1032 } | 1031 } |
| 1033 throw new SpannableAssertionFailure( | 1032 throw new SpannableAssertionFailure( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1061 | 1060 |
| 1062 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1061 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1063 switch (semantics.kind) { | 1062 switch (semantics.kind) { |
| 1064 case AccessKind.DYNAMIC_PROPERTY: | 1063 case AccessKind.DYNAMIC_PROPERTY: |
| 1065 return visitor.visitIndexPrefix( | 1064 return visitor.visitIndexPrefix( |
| 1066 node, | 1065 node, |
| 1067 node.receiver, | 1066 node.receiver, |
| 1068 node.arguments.single, | 1067 node.arguments.single, |
| 1069 operator, | 1068 operator, |
| 1070 arg); | 1069 arg); |
| 1071 case AccessKind.UNRESOLVED_SUPER: | |
| 1072 case AccessKind.UNRESOLVED: | |
| 1073 // TODO(johnniwinther): Support these through [AccessKind.COMPOUND]. | |
| 1074 return visitor.errorUnresolvedSuperIndexPrefix( | |
| 1075 node, | |
| 1076 semantics.element, | |
| 1077 node.arguments.single, | |
| 1078 operator, | |
| 1079 arg); | |
| 1080 case AccessKind.COMPOUND: | 1070 case AccessKind.COMPOUND: |
| 1081 CompoundAccessSemantics compoundSemantics = semantics; | 1071 CompoundAccessSemantics compoundSemantics = semantics; |
| 1082 switch (compoundSemantics.compoundAccessKind) { | 1072 switch (compoundSemantics.compoundAccessKind) { |
| 1083 case CompoundAccessKind.SUPER_GETTER_SETTER: | 1073 case CompoundAccessKind.SUPER_GETTER_SETTER: |
| 1084 return visitor.visitSuperIndexPrefix( | 1074 return visitor.visitSuperIndexPrefix( |
| 1085 node, | 1075 node, |
| 1086 compoundSemantics.getter, | 1076 compoundSemantics.getter, |
| 1087 compoundSemantics.setter, | 1077 compoundSemantics.setter, |
| 1088 node.arguments.single, | 1078 node.arguments.single, |
| 1089 operator, | 1079 operator, |
| 1090 arg); | 1080 arg); |
| 1081 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: |
| 1082 return visitor.visitUnresolvedSuperGetterIndexPrefix( |
| 1083 node, |
| 1084 compoundSemantics.getter, |
| 1085 node.arguments.single, |
| 1086 operator, |
| 1087 arg); |
| 1088 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
| 1089 return visitor.visitUnresolvedSuperSetterIndexPrefix( |
| 1090 node, |
| 1091 compoundSemantics.getter, |
| 1092 compoundSemantics.setter, |
| 1093 node.arguments.single, |
| 1094 operator, |
| 1095 arg); |
| 1091 default: | 1096 default: |
| 1092 // This is not a valid case. | 1097 // This is not a valid case. |
| 1093 break; | 1098 break; |
| 1094 } | 1099 } |
| 1095 break; | 1100 break; |
| 1096 default: | 1101 default: |
| 1097 // This is not a valid case. | 1102 // This is not a valid case. |
| 1098 break; | 1103 break; |
| 1099 } | 1104 } |
| 1100 throw new SpannableAssertionFailure( | 1105 throw new SpannableAssertionFailure( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1126 | 1131 |
| 1127 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1132 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1128 switch (semantics.kind) { | 1133 switch (semantics.kind) { |
| 1129 case AccessKind.DYNAMIC_PROPERTY: | 1134 case AccessKind.DYNAMIC_PROPERTY: |
| 1130 return visitor.visitIndexPostfix( | 1135 return visitor.visitIndexPostfix( |
| 1131 node, | 1136 node, |
| 1132 node.receiver, | 1137 node.receiver, |
| 1133 node.arguments.single, | 1138 node.arguments.single, |
| 1134 operator, | 1139 operator, |
| 1135 arg); | 1140 arg); |
| 1136 case AccessKind.UNRESOLVED_SUPER: | |
| 1137 case AccessKind.UNRESOLVED: | |
| 1138 // TODO(johnniwinther): Support these through [AccessKind.COMPOUND]. | |
| 1139 return visitor.errorUnresolvedSuperIndexPostfix( | |
| 1140 node, | |
| 1141 semantics.element, | |
| 1142 node.arguments.single, | |
| 1143 operator, | |
| 1144 arg); | |
| 1145 case AccessKind.COMPOUND: | 1141 case AccessKind.COMPOUND: |
| 1146 CompoundAccessSemantics compoundSemantics = semantics; | 1142 CompoundAccessSemantics compoundSemantics = semantics; |
| 1147 switch (compoundSemantics.compoundAccessKind) { | 1143 switch (compoundSemantics.compoundAccessKind) { |
| 1148 case CompoundAccessKind.SUPER_GETTER_SETTER: | 1144 case CompoundAccessKind.SUPER_GETTER_SETTER: |
| 1149 return visitor.visitSuperIndexPostfix( | 1145 return visitor.visitSuperIndexPostfix( |
| 1150 node, | 1146 node, |
| 1151 compoundSemantics.getter, | 1147 compoundSemantics.getter, |
| 1152 compoundSemantics.setter, | 1148 compoundSemantics.setter, |
| 1153 node.arguments.single, | 1149 node.arguments.single, |
| 1154 operator, | 1150 operator, |
| 1155 arg); | 1151 arg); |
| 1152 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: |
| 1153 return visitor.visitUnresolvedSuperGetterIndexPostfix( |
| 1154 node, |
| 1155 compoundSemantics.getter, |
| 1156 node.arguments.single, |
| 1157 operator, |
| 1158 arg); |
| 1159 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
| 1160 return visitor.visitUnresolvedSuperSetterIndexPostfix( |
| 1161 node, |
| 1162 compoundSemantics.getter, |
| 1163 compoundSemantics.setter, |
| 1164 node.arguments.single, |
| 1165 operator, |
| 1166 arg); |
| 1156 default: | 1167 default: |
| 1157 // This is not a valid case. | 1168 // This is not a valid case. |
| 1158 break; | 1169 break; |
| 1159 } | 1170 } |
| 1160 break; | 1171 break; |
| 1161 default: | 1172 default: |
| 1162 // This is not a valid case. | 1173 // This is not a valid case. |
| 1163 break; | 1174 break; |
| 1164 } | 1175 } |
| 1165 throw new SpannableAssertionFailure( | 1176 throw new SpannableAssertionFailure( |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 node.arguments.single, | 1395 node.arguments.single, |
| 1385 arg); | 1396 arg); |
| 1386 case CompoundAccessKind.SUPER_FIELD_SETTER: | 1397 case CompoundAccessKind.SUPER_FIELD_SETTER: |
| 1387 return visitor.visitSuperFieldSetterCompound( | 1398 return visitor.visitSuperFieldSetterCompound( |
| 1388 node, | 1399 node, |
| 1389 compoundSemantics.getter, | 1400 compoundSemantics.getter, |
| 1390 compoundSemantics.setter, | 1401 compoundSemantics.setter, |
| 1391 operator, | 1402 operator, |
| 1392 node.arguments.single, | 1403 node.arguments.single, |
| 1393 arg); | 1404 arg); |
| 1405 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: |
| 1406 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
| 1407 // TODO(johnniwinther): Handle these separately. |
| 1408 return visitor.errorUnresolvedCompound( |
| 1409 node, |
| 1410 semantics.element, |
| 1411 operator, |
| 1412 node.arguments.single, |
| 1413 arg); |
| 1414 break; |
| 1394 } | 1415 } |
| 1395 break; | 1416 break; |
| 1396 } | 1417 } |
| 1397 throw new SpannableAssertionFailure(node, | 1418 throw new SpannableAssertionFailure(node, |
| 1398 "Invalid compound assigment: ${semantics}"); | 1419 "Invalid compound assigment: ${semantics}"); |
| 1399 } | 1420 } |
| 1400 | 1421 |
| 1401 String toString() => 'compound($operator,$semantics)'; | 1422 String toString() => 'compound($operator,$semantics)'; |
| 1402 } | 1423 } |
| 1403 | 1424 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1423 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1444 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1424 switch (semantics.kind) { | 1445 switch (semantics.kind) { |
| 1425 case AccessKind.DYNAMIC_PROPERTY: | 1446 case AccessKind.DYNAMIC_PROPERTY: |
| 1426 return visitor.visitCompoundIndexSet( | 1447 return visitor.visitCompoundIndexSet( |
| 1427 node, | 1448 node, |
| 1428 node.receiver, | 1449 node.receiver, |
| 1429 node.arguments.first, | 1450 node.arguments.first, |
| 1430 operator, | 1451 operator, |
| 1431 node.arguments.tail.head, | 1452 node.arguments.tail.head, |
| 1432 arg); | 1453 arg); |
| 1433 case AccessKind.UNRESOLVED_SUPER: | |
| 1434 case AccessKind.UNRESOLVED: | |
| 1435 // TODO(johnniwinther): Support these through [AccessKind.COMPOUND]. | |
| 1436 return visitor.errorUnresolvedSuperCompoundIndexSet( | |
| 1437 node, | |
| 1438 semantics.element, | |
| 1439 node.arguments.first, | |
| 1440 operator, | |
| 1441 node.arguments.tail.head, | |
| 1442 arg); | |
| 1443 case AccessKind.COMPOUND: | 1454 case AccessKind.COMPOUND: |
| 1444 CompoundAccessSemantics compoundSemantics = semantics; | 1455 CompoundAccessSemantics compoundSemantics = semantics; |
| 1445 switch (compoundSemantics.compoundAccessKind) { | 1456 switch (compoundSemantics.compoundAccessKind) { |
| 1446 case CompoundAccessKind.SUPER_GETTER_SETTER: | 1457 case CompoundAccessKind.SUPER_GETTER_SETTER: |
| 1447 return visitor.visitSuperCompoundIndexSet( | 1458 return visitor.visitSuperCompoundIndexSet( |
| 1448 node, | 1459 node, |
| 1449 compoundSemantics.getter, | 1460 compoundSemantics.getter, |
| 1450 compoundSemantics.setter, | 1461 compoundSemantics.setter, |
| 1451 node.arguments.first, | 1462 node.arguments.first, |
| 1452 operator, | 1463 operator, |
| 1453 node.arguments.tail.head, | 1464 node.arguments.tail.head, |
| 1454 arg); | 1465 arg); |
| 1466 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: |
| 1467 return visitor.visitUnresolvedSuperGetterCompoundIndexSet( |
| 1468 node, |
| 1469 compoundSemantics.getter, |
| 1470 node.arguments.first, |
| 1471 operator, |
| 1472 node.arguments.tail.head, |
| 1473 arg); |
| 1474 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
| 1475 return visitor.visitUnresolvedSuperSetterCompoundIndexSet( |
| 1476 node, |
| 1477 compoundSemantics.getter, |
| 1478 compoundSemantics.setter, |
| 1479 node.arguments.first, |
| 1480 operator, |
| 1481 node.arguments.tail.head, |
| 1482 arg); |
| 1455 default: | 1483 default: |
| 1456 // This is not a valid case. | 1484 // This is not a valid case. |
| 1457 break; | 1485 break; |
| 1458 } | 1486 } |
| 1459 break; | 1487 break; |
| 1460 default: | 1488 default: |
| 1461 // This is not a valid case. | 1489 // This is not a valid case. |
| 1462 break; | 1490 break; |
| 1463 } | 1491 } |
| 1464 throw new SpannableAssertionFailure( | 1492 throw new SpannableAssertionFailure( |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 compoundSemantics.setter, | 1696 compoundSemantics.setter, |
| 1669 operator, | 1697 operator, |
| 1670 arg); | 1698 arg); |
| 1671 case CompoundAccessKind.SUPER_FIELD_SETTER: | 1699 case CompoundAccessKind.SUPER_FIELD_SETTER: |
| 1672 return visitor.visitSuperFieldSetterPrefix( | 1700 return visitor.visitSuperFieldSetterPrefix( |
| 1673 node, | 1701 node, |
| 1674 compoundSemantics.getter, | 1702 compoundSemantics.getter, |
| 1675 compoundSemantics.setter, | 1703 compoundSemantics.setter, |
| 1676 operator, | 1704 operator, |
| 1677 arg); | 1705 arg); |
| 1706 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: |
| 1707 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
| 1708 // TODO(johnniwinther): Handle these directly. |
| 1709 return visitor.errorUnresolvedPrefix( |
| 1710 node, |
| 1711 semantics.element, |
| 1712 operator, |
| 1713 arg); |
| 1678 } | 1714 } |
| 1679 } | 1715 } |
| 1680 throw new SpannableAssertionFailure(node, | 1716 throw new SpannableAssertionFailure(node, |
| 1681 "Invalid compound assigment: ${semantics}"); | 1717 "Invalid compound assigment: ${semantics}"); |
| 1682 } | 1718 } |
| 1683 | 1719 |
| 1684 String toString() => 'prefix($operator,$semantics)'; | 1720 String toString() => 'prefix($operator,$semantics)'; |
| 1685 } | 1721 } |
| 1686 | 1722 |
| 1687 /// The structure for a [Send] that is a postfix operations. For instance | 1723 /// The structure for a [Send] that is a postfix operations. For instance |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 compoundSemantics.setter, | 1920 compoundSemantics.setter, |
| 1885 operator, | 1921 operator, |
| 1886 arg); | 1922 arg); |
| 1887 case CompoundAccessKind.SUPER_FIELD_SETTER: | 1923 case CompoundAccessKind.SUPER_FIELD_SETTER: |
| 1888 return visitor.visitSuperFieldSetterPostfix( | 1924 return visitor.visitSuperFieldSetterPostfix( |
| 1889 node, | 1925 node, |
| 1890 compoundSemantics.getter, | 1926 compoundSemantics.getter, |
| 1891 compoundSemantics.setter, | 1927 compoundSemantics.setter, |
| 1892 operator, | 1928 operator, |
| 1893 arg); | 1929 arg); |
| 1930 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: |
| 1931 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
| 1932 // TODO(johnniwinther): Handle these directly. |
| 1933 return visitor.errorUnresolvedPostfix( |
| 1934 node, |
| 1935 semantics.element, |
| 1936 operator, |
| 1937 arg); |
| 1894 } | 1938 } |
| 1895 } | 1939 } |
| 1896 throw new SpannableAssertionFailure(node, | 1940 throw new SpannableAssertionFailure(node, |
| 1897 "Invalid compound assigment: ${semantics}"); | 1941 "Invalid compound assigment: ${semantics}"); |
| 1898 } | 1942 } |
| 1899 | 1943 |
| 1900 String toString() => 'postfix($operator,$semantics)'; | 1944 String toString() => 'postfix($operator,$semantics)'; |
| 1901 } | 1945 } |
| 1902 | 1946 |
| 1903 /// The structure for a [NewExpression] of a new invocation. | 1947 /// The structure for a [NewExpression] of a new invocation. |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 final ConstructorElement constructor; | 2206 final ConstructorElement constructor; |
| 2163 final Selector selector; | 2207 final Selector selector; |
| 2164 | 2208 |
| 2165 ThisConstructorInvokeStructure(this.constructor, this.selector); | 2209 ThisConstructorInvokeStructure(this.constructor, this.selector); |
| 2166 | 2210 |
| 2167 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { | 2211 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { |
| 2168 return visitor.visitThisConstructorInvoke( | 2212 return visitor.visitThisConstructorInvoke( |
| 2169 node, constructor, node.argumentsNode, selector, arg); | 2213 node, constructor, node.argumentsNode, selector, arg); |
| 2170 } | 2214 } |
| 2171 } | 2215 } |
| OLD | NEW |