| 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 '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 @override | 693 @override |
| 694 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 694 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 695 return visitor.errorUndefinedUnaryExpression( | 695 return visitor.errorUndefinedUnaryExpression( |
| 696 node, | 696 node, |
| 697 node.selector, | 697 node.selector, |
| 698 node.receiver, | 698 node.receiver, |
| 699 arg); | 699 arg); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| 703 /// The structure for a [Send] that is an index expression, i.e. of the form |
| 704 /// `a[b]`. |
| 705 class IndexStructure<R, A> implements SendStructure<R, A> { |
| 706 /// The target of the left operand. |
| 707 final AccessSemantics semantics; |
| 708 |
| 709 // TODO(johnniwinther): Should we store this? |
| 710 /// The [Selector] for the `[]` invocation. |
| 711 final Selector selector; |
| 712 |
| 713 IndexStructure(this.semantics, this.selector); |
| 714 |
| 715 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 716 switch (semantics.kind) { |
| 717 case AccessKind.DYNAMIC_PROPERTY: |
| 718 return visitor.visitIndex( |
| 719 node, |
| 720 node.receiver, |
| 721 node.arguments.single, |
| 722 arg); |
| 723 case AccessKind.SUPER_METHOD: |
| 724 return visitor.visitSuperIndex( |
| 725 node, |
| 726 semantics.element, |
| 727 node.arguments.single, |
| 728 arg); |
| 729 default: |
| 730 // This is not a valid case. |
| 731 break; |
| 732 } |
| 733 throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}"); |
| 734 } |
| 735 } |
| 736 |
| 703 /// The structure for a [Send] that is an equals test, i.e. of the form | 737 /// The structure for a [Send] that is an equals test, i.e. of the form |
| 704 /// `a == b`. | 738 /// `a == b`. |
| 705 class EqualsStructure<R, A> implements SendStructure<R, A> { | 739 class EqualsStructure<R, A> implements SendStructure<R, A> { |
| 706 /// The target of the left operand. | 740 /// The target of the left operand. |
| 707 final AccessSemantics semantics; | 741 final AccessSemantics semantics; |
| 708 | 742 |
| 709 // TODO(johnniwinther): Should we store this? | 743 // TODO(johnniwinther): Should we store this? |
| 710 /// The [Selector] for the `==` invocation. | 744 /// The [Selector] for the `==` invocation. |
| 711 final Selector selector; | 745 final Selector selector; |
| 712 | 746 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 case AccessKind.TOPLEVEL_METHOD: | 987 case AccessKind.TOPLEVEL_METHOD: |
| 954 // TODO(johnniwinther): Handle this. | 988 // TODO(johnniwinther): Handle this. |
| 955 break; | 989 break; |
| 956 case AccessKind.TOPLEVEL_GETTER: | 990 case AccessKind.TOPLEVEL_GETTER: |
| 957 // This is not a valid case. | 991 // This is not a valid case. |
| 958 break; | 992 break; |
| 959 case AccessKind.TOPLEVEL_SETTER: | 993 case AccessKind.TOPLEVEL_SETTER: |
| 960 // This is not a valid case. | 994 // This is not a valid case. |
| 961 break; | 995 break; |
| 962 case AccessKind.CLASS_TYPE_LITERAL: | 996 case AccessKind.CLASS_TYPE_LITERAL: |
| 963 return visitor.visitClassTypeLiteralCompound( | 997 return visitor.errorClassTypeLiteralCompound( |
| 964 node, | 998 node, |
| 965 semantics.constant, | 999 semantics.constant, |
| 966 operator, | 1000 operator, |
| 967 node.arguments.single, | 1001 node.arguments.single, |
| 968 arg); | 1002 arg); |
| 969 case AccessKind.TYPEDEF_TYPE_LITERAL: | 1003 case AccessKind.TYPEDEF_TYPE_LITERAL: |
| 970 return visitor.visitTypedefTypeLiteralCompound( | 1004 return visitor.errorTypedefTypeLiteralCompound( |
| 971 node, | 1005 node, |
| 972 semantics.constant, | 1006 semantics.constant, |
| 973 operator, | 1007 operator, |
| 974 node.arguments.single, | 1008 node.arguments.single, |
| 975 arg); | 1009 arg); |
| 976 case AccessKind.DYNAMIC_TYPE_LITERAL: | 1010 case AccessKind.DYNAMIC_TYPE_LITERAL: |
| 977 return visitor.visitDynamicTypeLiteralCompound( | 1011 return visitor.errorDynamicTypeLiteralCompound( |
| 978 node, | 1012 node, |
| 979 semantics.constant, | 1013 semantics.constant, |
| 980 operator, | 1014 operator, |
| 981 node.arguments.single, | 1015 node.arguments.single, |
| 982 arg); | 1016 arg); |
| 983 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: | 1017 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: |
| 984 return visitor.visitTypeVariableTypeLiteralCompound( | 1018 return visitor.errorTypeVariableTypeLiteralCompound( |
| 985 node, | 1019 node, |
| 986 semantics.element, | 1020 semantics.element, |
| 987 operator, | 1021 operator, |
| 988 node.arguments.single, | 1022 node.arguments.single, |
| 989 arg); | 1023 arg); |
| 990 case AccessKind.EXPRESSION: | 1024 case AccessKind.EXPRESSION: |
| 991 // This is not a valid case. | 1025 // This is not a valid case. |
| 992 break; | 1026 break; |
| 993 case AccessKind.THIS: | 1027 case AccessKind.THIS: |
| 994 // This is not a valid case. | 1028 // This is not a valid case. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 case AccessKind.TOPLEVEL_METHOD: | 1274 case AccessKind.TOPLEVEL_METHOD: |
| 1241 // TODO(johnniwinther): Handle this. | 1275 // TODO(johnniwinther): Handle this. |
| 1242 break; | 1276 break; |
| 1243 case AccessKind.TOPLEVEL_GETTER: | 1277 case AccessKind.TOPLEVEL_GETTER: |
| 1244 // This is not a valid case. | 1278 // This is not a valid case. |
| 1245 break; | 1279 break; |
| 1246 case AccessKind.TOPLEVEL_SETTER: | 1280 case AccessKind.TOPLEVEL_SETTER: |
| 1247 // This is not a valid case. | 1281 // This is not a valid case. |
| 1248 break; | 1282 break; |
| 1249 case AccessKind.CLASS_TYPE_LITERAL: | 1283 case AccessKind.CLASS_TYPE_LITERAL: |
| 1250 return visitor.visitClassTypeLiteralPrefix( | 1284 return visitor.errorClassTypeLiteralPrefix( |
| 1251 node, | 1285 node, |
| 1252 semantics.constant, | 1286 semantics.constant, |
| 1253 operator, | 1287 operator, |
| 1254 arg); | 1288 arg); |
| 1255 case AccessKind.TYPEDEF_TYPE_LITERAL: | 1289 case AccessKind.TYPEDEF_TYPE_LITERAL: |
| 1256 return visitor.visitTypedefTypeLiteralPrefix( | 1290 return visitor.errorTypedefTypeLiteralPrefix( |
| 1257 node, | 1291 node, |
| 1258 semantics.constant, | 1292 semantics.constant, |
| 1259 operator, | 1293 operator, |
| 1260 arg); | 1294 arg); |
| 1261 case AccessKind.DYNAMIC_TYPE_LITERAL: | 1295 case AccessKind.DYNAMIC_TYPE_LITERAL: |
| 1262 return visitor.visitDynamicTypeLiteralPrefix( | 1296 return visitor.errorDynamicTypeLiteralPrefix( |
| 1263 node, | 1297 node, |
| 1264 semantics.constant, | 1298 semantics.constant, |
| 1265 operator, | 1299 operator, |
| 1266 arg); | 1300 arg); |
| 1267 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: | 1301 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: |
| 1268 return visitor.visitTypeVariableTypeLiteralPrefix( | 1302 return visitor.errorTypeVariableTypeLiteralPrefix( |
| 1269 node, | 1303 node, |
| 1270 semantics.element, | 1304 semantics.element, |
| 1271 operator, | 1305 operator, |
| 1272 arg); | 1306 arg); |
| 1273 case AccessKind.EXPRESSION: | 1307 case AccessKind.EXPRESSION: |
| 1274 // This is not a valid case. | 1308 // This is not a valid case. |
| 1275 break; | 1309 break; |
| 1276 case AccessKind.THIS: | 1310 case AccessKind.THIS: |
| 1277 // This is not a valid case. | 1311 // This is not a valid case. |
| 1278 break; | 1312 break; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 case AccessKind.TOPLEVEL_METHOD: | 1486 case AccessKind.TOPLEVEL_METHOD: |
| 1453 // TODO(johnniwinther): Handle this. | 1487 // TODO(johnniwinther): Handle this. |
| 1454 break; | 1488 break; |
| 1455 case AccessKind.TOPLEVEL_GETTER: | 1489 case AccessKind.TOPLEVEL_GETTER: |
| 1456 // This is not a valid case. | 1490 // This is not a valid case. |
| 1457 break; | 1491 break; |
| 1458 case AccessKind.TOPLEVEL_SETTER: | 1492 case AccessKind.TOPLEVEL_SETTER: |
| 1459 // This is not a valid case. | 1493 // This is not a valid case. |
| 1460 break; | 1494 break; |
| 1461 case AccessKind.CLASS_TYPE_LITERAL: | 1495 case AccessKind.CLASS_TYPE_LITERAL: |
| 1462 return visitor.visitClassTypeLiteralPostfix( | 1496 return visitor.errorClassTypeLiteralPostfix( |
| 1463 node, | 1497 node, |
| 1464 semantics.constant, | 1498 semantics.constant, |
| 1465 operator, | 1499 operator, |
| 1466 arg); | 1500 arg); |
| 1467 case AccessKind.TYPEDEF_TYPE_LITERAL: | 1501 case AccessKind.TYPEDEF_TYPE_LITERAL: |
| 1468 return visitor.visitTypedefTypeLiteralPostfix( | 1502 return visitor.errorTypedefTypeLiteralPostfix( |
| 1469 node, | 1503 node, |
| 1470 semantics.constant, | 1504 semantics.constant, |
| 1471 operator, | 1505 operator, |
| 1472 arg); | 1506 arg); |
| 1473 case AccessKind.DYNAMIC_TYPE_LITERAL: | 1507 case AccessKind.DYNAMIC_TYPE_LITERAL: |
| 1474 return visitor.visitDynamicTypeLiteralPostfix( | 1508 return visitor.errorDynamicTypeLiteralPostfix( |
| 1475 node, | 1509 node, |
| 1476 semantics.constant, | 1510 semantics.constant, |
| 1477 operator, | 1511 operator, |
| 1478 arg); | 1512 arg); |
| 1479 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: | 1513 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: |
| 1480 return visitor.visitTypeVariableTypeLiteralPostfix( | 1514 return visitor.errorTypeVariableTypeLiteralPostfix( |
| 1481 node, | 1515 node, |
| 1482 semantics.element, | 1516 semantics.element, |
| 1483 operator, | 1517 operator, |
| 1484 arg); | 1518 arg); |
| 1485 case AccessKind.EXPRESSION: | 1519 case AccessKind.EXPRESSION: |
| 1486 // This is not a valid case. | 1520 // This is not a valid case. |
| 1487 break; | 1521 break; |
| 1488 case AccessKind.THIS: | 1522 case AccessKind.THIS: |
| 1489 // This is not a valid case. | 1523 // This is not a valid case. |
| 1490 break; | 1524 break; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 compoundSemantics.setter, | 1619 compoundSemantics.setter, |
| 1586 operator, | 1620 operator, |
| 1587 arg); | 1621 arg); |
| 1588 } | 1622 } |
| 1589 } | 1623 } |
| 1590 throw new SpannableAssertionFailure(node, | 1624 throw new SpannableAssertionFailure(node, |
| 1591 "Invalid compound assigment: ${semantics}"); | 1625 "Invalid compound assigment: ${semantics}"); |
| 1592 } | 1626 } |
| 1593 } | 1627 } |
| 1594 | 1628 |
| OLD | NEW |