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.resolution.send_structure; | 5 library dart2js.resolution.send_structure; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../elements/operators.dart'; | 10 import '../elements/operators.dart'; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 case AccessKind.UNRESOLVED_SUPER: | 284 case AccessKind.UNRESOLVED_SUPER: |
285 return visitor.visitUnresolvedSuperInvoke( | 285 return visitor.visitUnresolvedSuperInvoke( |
286 node, semantics.element, node.argumentsNode, selector, arg); | 286 node, semantics.element, node.argumentsNode, selector, arg); |
287 case AccessKind.INVALID: | 287 case AccessKind.INVALID: |
288 return visitor.errorInvalidInvoke( | 288 return visitor.errorInvalidInvoke( |
289 node, semantics.element, node.argumentsNode, selector, arg); | 289 node, semantics.element, node.argumentsNode, selector, arg); |
290 case AccessKind.COMPOUND: | 290 case AccessKind.COMPOUND: |
291 // This is not a valid case. | 291 // This is not a valid case. |
292 break; | 292 break; |
293 } | 293 } |
294 throw new SpannableAssertionFailure(node, "Invalid invoke: ${semantics}"); | 294 throw failedAt(node, "Invalid invoke: ${semantics}"); |
295 } | 295 } |
296 | 296 |
297 String toString() => 'invoke($selector, $semantics)'; | 297 String toString() => 'invoke($selector, $semantics)'; |
298 } | 298 } |
299 | 299 |
300 /// The structure for a [Send] that is an incompatible invocation, i.e. an | 300 /// The structure for a [Send] that is an incompatible invocation, i.e. an |
301 /// invocation of a known target where the call structure does not match. | 301 /// invocation of a known target where the call structure does not match. |
302 class IncompatibleInvokeStructure<R, A> implements SendStructure<R, A> { | 302 class IncompatibleInvokeStructure<R, A> implements SendStructure<R, A> { |
303 /// The target of the invocation. | 303 /// The target of the invocation. |
304 final AccessSemantics semantics; | 304 final AccessSemantics semantics; |
(...skipping 22 matching lines...) Expand all Loading... |
327 case AccessKind.TOPLEVEL_METHOD: | 327 case AccessKind.TOPLEVEL_METHOD: |
328 return visitor.visitTopLevelFunctionIncompatibleInvoke( | 328 return visitor.visitTopLevelFunctionIncompatibleInvoke( |
329 node, semantics.element, node.argumentsNode, callStructure, arg); | 329 node, semantics.element, node.argumentsNode, callStructure, arg); |
330 case AccessKind.LOCAL_FUNCTION: | 330 case AccessKind.LOCAL_FUNCTION: |
331 return visitor.visitLocalFunctionIncompatibleInvoke( | 331 return visitor.visitLocalFunctionIncompatibleInvoke( |
332 node, semantics.element, node.argumentsNode, callStructure, arg); | 332 node, semantics.element, node.argumentsNode, callStructure, arg); |
333 default: | 333 default: |
334 // TODO(johnniwinther): Support more variants of this invoke structure. | 334 // TODO(johnniwinther): Support more variants of this invoke structure. |
335 break; | 335 break; |
336 } | 336 } |
337 throw new SpannableAssertionFailure( | 337 throw failedAt(node, "Invalid incompatible invoke: ${semantics}"); |
338 node, "Invalid incompatible invoke: ${semantics}"); | |
339 } | 338 } |
340 | 339 |
341 String toString() => 'incompatible-invoke($selector, $semantics)'; | 340 String toString() => 'incompatible-invoke($selector, $semantics)'; |
342 } | 341 } |
343 | 342 |
344 /// The structure for a [Send] that is a read access. | 343 /// The structure for a [Send] that is a read access. |
345 class GetStructure<R, A> implements SendStructure<R, A> { | 344 class GetStructure<R, A> implements SendStructure<R, A> { |
346 /// The target of the read access. | 345 /// The target of the read access. |
347 final AccessSemantics semantics; | 346 final AccessSemantics semantics; |
348 | 347 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 case AccessKind.UNRESOLVED: | 417 case AccessKind.UNRESOLVED: |
419 return visitor.visitUnresolvedGet(node, semantics.element, arg); | 418 return visitor.visitUnresolvedGet(node, semantics.element, arg); |
420 case AccessKind.UNRESOLVED_SUPER: | 419 case AccessKind.UNRESOLVED_SUPER: |
421 return visitor.visitUnresolvedSuperGet(node, semantics.element, arg); | 420 return visitor.visitUnresolvedSuperGet(node, semantics.element, arg); |
422 case AccessKind.INVALID: | 421 case AccessKind.INVALID: |
423 return visitor.errorInvalidGet(node, semantics.element, arg); | 422 return visitor.errorInvalidGet(node, semantics.element, arg); |
424 case AccessKind.COMPOUND: | 423 case AccessKind.COMPOUND: |
425 // This is not a valid case. | 424 // This is not a valid case. |
426 break; | 425 break; |
427 } | 426 } |
428 throw new SpannableAssertionFailure(node, "Invalid getter: ${semantics}"); | 427 throw failedAt(node, "Invalid getter: ${semantics}"); |
429 } | 428 } |
430 | 429 |
431 String toString() => 'get($semantics)'; | 430 String toString() => 'get($semantics)'; |
432 } | 431 } |
433 | 432 |
434 /// The structure for a [Send] that is an assignment. | 433 /// The structure for a [Send] that is an assignment. |
435 class SetStructure<R, A> implements SendStructure<R, A> { | 434 class SetStructure<R, A> implements SendStructure<R, A> { |
436 /// The target of the assignment. | 435 /// The target of the assignment. |
437 final AccessSemantics semantics; | 436 final AccessSemantics semantics; |
438 | 437 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 case AccessKind.UNRESOLVED: | 538 case AccessKind.UNRESOLVED: |
540 return visitor.visitUnresolvedSet( | 539 return visitor.visitUnresolvedSet( |
541 node, semantics.element, node.arguments.single, arg); | 540 node, semantics.element, node.arguments.single, arg); |
542 case AccessKind.INVALID: | 541 case AccessKind.INVALID: |
543 return visitor.errorInvalidSet( | 542 return visitor.errorInvalidSet( |
544 node, semantics.element, node.arguments.single, arg); | 543 node, semantics.element, node.arguments.single, arg); |
545 case AccessKind.COMPOUND: | 544 case AccessKind.COMPOUND: |
546 // This is not a valid case. | 545 // This is not a valid case. |
547 break; | 546 break; |
548 } | 547 } |
549 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}"); | 548 throw failedAt(node, "Invalid setter: ${semantics}"); |
550 } | 549 } |
551 | 550 |
552 String toString() => 'set($semantics)'; | 551 String toString() => 'set($semantics)'; |
553 } | 552 } |
554 | 553 |
555 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. | 554 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. |
556 class NotStructure<R, A> implements SendStructure<R, A> { | 555 class NotStructure<R, A> implements SendStructure<R, A> { |
557 const NotStructure(); | 556 const NotStructure(); |
558 | 557 |
559 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 558 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
(...skipping 29 matching lines...) Expand all Loading... |
589 case AccessKind.UNRESOLVED_SUPER: | 588 case AccessKind.UNRESOLVED_SUPER: |
590 return visitor.visitUnresolvedSuperUnary( | 589 return visitor.visitUnresolvedSuperUnary( |
591 node, operator, semantics.element, arg); | 590 node, operator, semantics.element, arg); |
592 case AccessKind.INVALID: | 591 case AccessKind.INVALID: |
593 return visitor.errorInvalidUnary( | 592 return visitor.errorInvalidUnary( |
594 node, operator, semantics.element, arg); | 593 node, operator, semantics.element, arg); |
595 default: | 594 default: |
596 // This is not a valid case. | 595 // This is not a valid case. |
597 break; | 596 break; |
598 } | 597 } |
599 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}"); | 598 throw failedAt(node, "Invalid setter: ${semantics}"); |
600 } | 599 } |
601 | 600 |
602 String toString() => 'unary($operator,$semantics)'; | 601 String toString() => 'unary($operator,$semantics)'; |
603 } | 602 } |
604 | 603 |
605 /// The structure for a [Send] that is an invocation of a undefined unary | 604 /// The structure for a [Send] that is an invocation of a undefined unary |
606 /// operator. | 605 /// operator. |
607 class InvalidUnaryStructure<R, A> implements SendStructure<R, A> { | 606 class InvalidUnaryStructure<R, A> implements SendStructure<R, A> { |
608 const InvalidUnaryStructure(); | 607 const InvalidUnaryStructure(); |
609 | 608 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 case AccessKind.UNRESOLVED_SUPER: | 640 case AccessKind.UNRESOLVED_SUPER: |
642 return visitor.visitUnresolvedSuperIndex( | 641 return visitor.visitUnresolvedSuperIndex( |
643 node, semantics.element, node.arguments.single, arg); | 642 node, semantics.element, node.arguments.single, arg); |
644 case AccessKind.INVALID: | 643 case AccessKind.INVALID: |
645 return visitor.errorInvalidIndex( | 644 return visitor.errorInvalidIndex( |
646 node, semantics.element, node.arguments.single, arg); | 645 node, semantics.element, node.arguments.single, arg); |
647 default: | 646 default: |
648 // This is not a valid case. | 647 // This is not a valid case. |
649 break; | 648 break; |
650 } | 649 } |
651 throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}"); | 650 throw failedAt(node, "Invalid index: ${semantics}"); |
652 } | 651 } |
653 } | 652 } |
654 | 653 |
655 /// The structure for a [Send] that is an equals test, i.e. of the form | 654 /// The structure for a [Send] that is an equals test, i.e. of the form |
656 /// `a == b`. | 655 /// `a == b`. |
657 class EqualsStructure<R, A> implements SendStructure<R, A> { | 656 class EqualsStructure<R, A> implements SendStructure<R, A> { |
658 /// The target of the left operand. | 657 /// The target of the left operand. |
659 final AccessSemantics semantics; | 658 final AccessSemantics semantics; |
660 | 659 |
661 EqualsStructure(this.semantics); | 660 EqualsStructure(this.semantics); |
662 | 661 |
663 @override | 662 @override |
664 SendStructureKind get kind => SendStructureKind.EQUALS; | 663 SendStructureKind get kind => SendStructureKind.EQUALS; |
665 | 664 |
666 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 665 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
667 switch (semantics.kind) { | 666 switch (semantics.kind) { |
668 case AccessKind.EXPRESSION: | 667 case AccessKind.EXPRESSION: |
669 return visitor.visitEquals( | 668 return visitor.visitEquals( |
670 node, node.receiver, node.arguments.single, arg); | 669 node, node.receiver, node.arguments.single, arg); |
671 case AccessKind.SUPER_METHOD: | 670 case AccessKind.SUPER_METHOD: |
672 return visitor.visitSuperEquals( | 671 return visitor.visitSuperEquals( |
673 node, semantics.element, node.arguments.single, arg); | 672 node, semantics.element, node.arguments.single, arg); |
674 case AccessKind.INVALID: | 673 case AccessKind.INVALID: |
675 return visitor.errorInvalidEquals( | 674 return visitor.errorInvalidEquals( |
676 node, semantics.element, node.arguments.single, arg); | 675 node, semantics.element, node.arguments.single, arg); |
677 default: | 676 default: |
678 // This is not a valid case. | 677 // This is not a valid case. |
679 break; | 678 break; |
680 } | 679 } |
681 throw new SpannableAssertionFailure(node, "Invalid equals: ${semantics}"); | 680 throw failedAt(node, "Invalid equals: ${semantics}"); |
682 } | 681 } |
683 | 682 |
684 String toString() => '==($semantics)'; | 683 String toString() => '==($semantics)'; |
685 } | 684 } |
686 | 685 |
687 /// The structure for a [Send] that is a not-equals test, i.e. of the form | 686 /// The structure for a [Send] that is a not-equals test, i.e. of the form |
688 /// `a != b`. | 687 /// `a != b`. |
689 class NotEqualsStructure<R, A> implements SendStructure<R, A> { | 688 class NotEqualsStructure<R, A> implements SendStructure<R, A> { |
690 /// The target of the left operand. | 689 /// The target of the left operand. |
691 final AccessSemantics semantics; | 690 final AccessSemantics semantics; |
(...skipping 11 matching lines...) Expand all Loading... |
703 case AccessKind.SUPER_METHOD: | 702 case AccessKind.SUPER_METHOD: |
704 return visitor.visitSuperNotEquals( | 703 return visitor.visitSuperNotEquals( |
705 node, semantics.element, node.arguments.single, arg); | 704 node, semantics.element, node.arguments.single, arg); |
706 case AccessKind.INVALID: | 705 case AccessKind.INVALID: |
707 return visitor.errorInvalidNotEquals( | 706 return visitor.errorInvalidNotEquals( |
708 node, semantics.element, node.arguments.single, arg); | 707 node, semantics.element, node.arguments.single, arg); |
709 default: | 708 default: |
710 // This is not a valid case. | 709 // This is not a valid case. |
711 break; | 710 break; |
712 } | 711 } |
713 throw new SpannableAssertionFailure( | 712 throw failedAt(node, "Invalid not equals: ${semantics}"); |
714 node, "Invalid not equals: ${semantics}"); | |
715 } | 713 } |
716 | 714 |
717 String toString() => '!=($semantics)'; | 715 String toString() => '!=($semantics)'; |
718 } | 716 } |
719 | 717 |
720 /// The structure for a [Send] that is an invocation of a user-definable binary | 718 /// The structure for a [Send] that is an invocation of a user-definable binary |
721 /// operator. | 719 /// operator. |
722 class BinaryStructure<R, A> implements SendStructure<R, A> { | 720 class BinaryStructure<R, A> implements SendStructure<R, A> { |
723 /// The target of the left operand. | 721 /// The target of the left operand. |
724 final AccessSemantics semantics; | 722 final AccessSemantics semantics; |
(...skipping 17 matching lines...) Expand all Loading... |
742 case AccessKind.UNRESOLVED_SUPER: | 740 case AccessKind.UNRESOLVED_SUPER: |
743 return visitor.visitUnresolvedSuperBinary( | 741 return visitor.visitUnresolvedSuperBinary( |
744 node, semantics.element, operator, node.arguments.single, arg); | 742 node, semantics.element, operator, node.arguments.single, arg); |
745 case AccessKind.INVALID: | 743 case AccessKind.INVALID: |
746 return visitor.errorInvalidBinary( | 744 return visitor.errorInvalidBinary( |
747 node, semantics.element, operator, node.arguments.single, arg); | 745 node, semantics.element, operator, node.arguments.single, arg); |
748 default: | 746 default: |
749 // This is not a valid case. | 747 // This is not a valid case. |
750 break; | 748 break; |
751 } | 749 } |
752 throw new SpannableAssertionFailure(node, "Invalid binary: ${semantics}"); | 750 throw failedAt(node, "Invalid binary: ${semantics}"); |
753 } | 751 } |
754 | 752 |
755 String toString() => 'binary($operator,$semantics)'; | 753 String toString() => 'binary($operator,$semantics)'; |
756 } | 754 } |
757 | 755 |
758 /// The structure for a [Send] that is an invocation of a undefined binary | 756 /// The structure for a [Send] that is an invocation of a undefined binary |
759 /// operator. | 757 /// operator. |
760 class InvalidBinaryStructure<R, A> implements SendStructure<R, A> { | 758 class InvalidBinaryStructure<R, A> implements SendStructure<R, A> { |
761 const InvalidBinaryStructure(); | 759 const InvalidBinaryStructure(); |
762 | 760 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 case AccessKind.UNRESOLVED: | 792 case AccessKind.UNRESOLVED: |
795 return visitor.visitUnresolvedSuperIndexSet(node, semantics.element, | 793 return visitor.visitUnresolvedSuperIndexSet(node, semantics.element, |
796 node.arguments.first, node.arguments.tail.head, arg); | 794 node.arguments.first, node.arguments.tail.head, arg); |
797 case AccessKind.INVALID: | 795 case AccessKind.INVALID: |
798 return visitor.errorInvalidIndexSet(node, semantics.element, | 796 return visitor.errorInvalidIndexSet(node, semantics.element, |
799 node.arguments.first, node.arguments.tail.head, arg); | 797 node.arguments.first, node.arguments.tail.head, arg); |
800 default: | 798 default: |
801 // This is not a valid case. | 799 // This is not a valid case. |
802 break; | 800 break; |
803 } | 801 } |
804 throw new SpannableAssertionFailure( | 802 throw failedAt(node, "Invalid index set: ${semantics}"); |
805 node, "Invalid index set: ${semantics}"); | |
806 } | 803 } |
807 | 804 |
808 String toString() => '[]=($semantics)'; | 805 String toString() => '[]=($semantics)'; |
809 } | 806 } |
810 | 807 |
811 /// The structure for a [Send] that is an prefix operation on an index | 808 /// The structure for a [Send] that is an prefix operation on an index |
812 /// expression, i.e. of the form `--a[b]`. | 809 /// expression, i.e. of the form `--a[b]`. |
813 class IndexPrefixStructure<R, A> implements SendStructure<R, A> { | 810 class IndexPrefixStructure<R, A> implements SendStructure<R, A> { |
814 /// The target of the left operand. | 811 /// The target of the left operand. |
815 final AccessSemantics semantics; | 812 final AccessSemantics semantics; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 arg); | 854 arg); |
858 default: | 855 default: |
859 // This is not a valid case. | 856 // This is not a valid case. |
860 break; | 857 break; |
861 } | 858 } |
862 break; | 859 break; |
863 default: | 860 default: |
864 // This is not a valid case. | 861 // This is not a valid case. |
865 break; | 862 break; |
866 } | 863 } |
867 throw new SpannableAssertionFailure( | 864 throw failedAt(node, "Invalid index prefix: ${semantics}"); |
868 node, "Invalid index prefix: ${semantics}"); | |
869 } | 865 } |
870 } | 866 } |
871 | 867 |
872 /// The structure for a [Send] that is an postfix operation on an index | 868 /// The structure for a [Send] that is an postfix operation on an index |
873 /// expression, i.e. of the form `a[b]++`. | 869 /// expression, i.e. of the form `a[b]++`. |
874 class IndexPostfixStructure<R, A> implements SendStructure<R, A> { | 870 class IndexPostfixStructure<R, A> implements SendStructure<R, A> { |
875 /// The target of the left operand. | 871 /// The target of the left operand. |
876 final AccessSemantics semantics; | 872 final AccessSemantics semantics; |
877 | 873 |
878 /// The `++` or `--` operator used in the operation. | 874 /// The `++` or `--` operator used in the operation. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 arg); | 919 arg); |
924 default: | 920 default: |
925 // This is not a valid case. | 921 // This is not a valid case. |
926 break; | 922 break; |
927 } | 923 } |
928 break; | 924 break; |
929 default: | 925 default: |
930 // This is not a valid case. | 926 // This is not a valid case. |
931 break; | 927 break; |
932 } | 928 } |
933 throw new SpannableAssertionFailure( | 929 throw failedAt(node, "Invalid index postfix: ${semantics}"); |
934 node, "Invalid index postfix: ${semantics}"); | |
935 } | 930 } |
936 } | 931 } |
937 | 932 |
938 /// The structure for a [Send] that is a compound assignment. For instance | 933 /// The structure for a [Send] that is a compound assignment. For instance |
939 /// `a += b`. | 934 /// `a += b`. |
940 class CompoundStructure<R, A> implements SendStructure<R, A> { | 935 class CompoundStructure<R, A> implements SendStructure<R, A> { |
941 /// The target of the compound assignment, i.e. the left-hand side. | 936 /// The target of the compound assignment, i.e. the left-hand side. |
942 final AccessSemantics semantics; | 937 final AccessSemantics semantics; |
943 | 938 |
944 /// The assignment operator used in the compound assignment. | 939 /// The assignment operator used in the compound assignment. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 return visitor.visitUnresolvedSuperSetterCompound( | 1169 return visitor.visitUnresolvedSuperSetterCompound( |
1175 node, | 1170 node, |
1176 compoundSemantics.getter, | 1171 compoundSemantics.getter, |
1177 compoundSemantics.setter, | 1172 compoundSemantics.setter, |
1178 operator, | 1173 operator, |
1179 node.arguments.single, | 1174 node.arguments.single, |
1180 arg); | 1175 arg); |
1181 } | 1176 } |
1182 break; | 1177 break; |
1183 } | 1178 } |
1184 throw new SpannableAssertionFailure( | 1179 throw failedAt(node, "Invalid compound assigment: ${semantics}"); |
1185 node, "Invalid compound assigment: ${semantics}"); | |
1186 } | 1180 } |
1187 | 1181 |
1188 String toString() => 'compound($operator,$semantics)'; | 1182 String toString() => 'compound($operator,$semantics)'; |
1189 } | 1183 } |
1190 | 1184 |
1191 /// The structure for a [Send] that is an if-null assignment. For instance | 1185 /// The structure for a [Send] that is an if-null assignment. For instance |
1192 /// `a ??= b`. | 1186 /// `a ??= b`. |
1193 class SetIfNullStructure<R, A> implements SendStructure<R, A> { | 1187 class SetIfNullStructure<R, A> implements SendStructure<R, A> { |
1194 /// The target of the if-null assignment, i.e. the left-hand side. | 1188 /// The target of the if-null assignment, i.e. the left-hand side. |
1195 final AccessSemantics semantics; | 1189 final AccessSemantics semantics; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: | 1398 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
1405 return visitor.visitUnresolvedSuperSetterSetIfNull( | 1399 return visitor.visitUnresolvedSuperSetterSetIfNull( |
1406 node, | 1400 node, |
1407 compoundSemantics.getter, | 1401 compoundSemantics.getter, |
1408 compoundSemantics.setter, | 1402 compoundSemantics.setter, |
1409 node.arguments.single, | 1403 node.arguments.single, |
1410 arg); | 1404 arg); |
1411 } | 1405 } |
1412 break; | 1406 break; |
1413 } | 1407 } |
1414 throw new SpannableAssertionFailure( | 1408 throw failedAt(node, "Invalid if-null assigment: ${semantics}"); |
1415 node, "Invalid if-null assigment: ${semantics}"); | |
1416 } | 1409 } |
1417 | 1410 |
1418 String toString() => 'ifNull($semantics)'; | 1411 String toString() => 'ifNull($semantics)'; |
1419 } | 1412 } |
1420 | 1413 |
1421 /// The structure for a [Send] that is a compound assignment on the index | 1414 /// The structure for a [Send] that is a compound assignment on the index |
1422 /// operator. For instance `a[b] += c`. | 1415 /// operator. For instance `a[b] += c`. |
1423 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> { | 1416 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> { |
1424 /// The target of the index operations. | 1417 /// The target of the index operations. |
1425 final AccessSemantics semantics; | 1418 final AccessSemantics semantics; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 arg); | 1473 arg); |
1481 default: | 1474 default: |
1482 // This is not a valid case. | 1475 // This is not a valid case. |
1483 break; | 1476 break; |
1484 } | 1477 } |
1485 break; | 1478 break; |
1486 default: | 1479 default: |
1487 // This is not a valid case. | 1480 // This is not a valid case. |
1488 break; | 1481 break; |
1489 } | 1482 } |
1490 throw new SpannableAssertionFailure( | 1483 throw failedAt(node, "Invalid compound index set: ${semantics}"); |
1491 node, "Invalid compound index set: ${semantics}"); | |
1492 } | 1484 } |
1493 | 1485 |
1494 String toString() => 'compound []=($operator,$semantics)'; | 1486 String toString() => 'compound []=($operator,$semantics)'; |
1495 } | 1487 } |
1496 | 1488 |
1497 /// The structure for a [Send] that is a if-null assignment on the index | 1489 /// The structure for a [Send] that is a if-null assignment on the index |
1498 /// operator. For instance `a[b] ??= c`. | 1490 /// operator. For instance `a[b] ??= c`. |
1499 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> { | 1491 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> { |
1500 /// The target of the index operations. | 1492 /// The target of the index operations. |
1501 final AccessSemantics semantics; | 1493 final AccessSemantics semantics; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 arg); | 1541 arg); |
1550 default: | 1542 default: |
1551 // This is not a valid case. | 1543 // This is not a valid case. |
1552 break; | 1544 break; |
1553 } | 1545 } |
1554 break; | 1546 break; |
1555 default: | 1547 default: |
1556 // This is not a valid case. | 1548 // This is not a valid case. |
1557 break; | 1549 break; |
1558 } | 1550 } |
1559 throw new SpannableAssertionFailure( | 1551 throw failedAt(node, "Invalid index set if-null: ${semantics}"); |
1560 node, "Invalid index set if-null: ${semantics}"); | |
1561 } | 1552 } |
1562 | 1553 |
1563 String toString() => 'index set if-null []??=($semantics)'; | 1554 String toString() => 'index set if-null []??=($semantics)'; |
1564 } | 1555 } |
1565 | 1556 |
1566 /// The structure for a [Send] that is a prefix operations. For instance | 1557 /// The structure for a [Send] that is a prefix operations. For instance |
1567 /// `++a`. | 1558 /// `++a`. |
1568 class PrefixStructure<R, A> implements SendStructure<R, A> { | 1559 class PrefixStructure<R, A> implements SendStructure<R, A> { |
1569 /// The target of the prefix operation. | 1560 /// The target of the prefix operation. |
1570 final AccessSemantics semantics; | 1561 final AccessSemantics semantics; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 arg); | 1779 arg); |
1789 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: | 1780 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
1790 return visitor.visitUnresolvedSuperSetterPrefix( | 1781 return visitor.visitUnresolvedSuperSetterPrefix( |
1791 node, | 1782 node, |
1792 compoundSemantics.getter, | 1783 compoundSemantics.getter, |
1793 compoundSemantics.setter, | 1784 compoundSemantics.setter, |
1794 operator, | 1785 operator, |
1795 arg); | 1786 arg); |
1796 } | 1787 } |
1797 } | 1788 } |
1798 throw new SpannableAssertionFailure( | 1789 throw failedAt(node, "Invalid compound assigment: ${semantics}"); |
1799 node, "Invalid compound assigment: ${semantics}"); | |
1800 } | 1790 } |
1801 | 1791 |
1802 String toString() => 'prefix($operator,$semantics)'; | 1792 String toString() => 'prefix($operator,$semantics)'; |
1803 } | 1793 } |
1804 | 1794 |
1805 /// The structure for a [Send] that is a postfix operations. For instance | 1795 /// The structure for a [Send] that is a postfix operations. For instance |
1806 /// `a++`. | 1796 /// `a++`. |
1807 class PostfixStructure<R, A> implements SendStructure<R, A> { | 1797 class PostfixStructure<R, A> implements SendStructure<R, A> { |
1808 /// The target of the postfix operation. | 1798 /// The target of the postfix operation. |
1809 final AccessSemantics semantics; | 1799 final AccessSemantics semantics; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 arg); | 2010 arg); |
2021 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: | 2011 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: |
2022 return visitor.visitUnresolvedSuperSetterPostfix( | 2012 return visitor.visitUnresolvedSuperSetterPostfix( |
2023 node, | 2013 node, |
2024 compoundSemantics.getter, | 2014 compoundSemantics.getter, |
2025 compoundSemantics.setter, | 2015 compoundSemantics.setter, |
2026 operator, | 2016 operator, |
2027 arg); | 2017 arg); |
2028 } | 2018 } |
2029 } | 2019 } |
2030 throw new SpannableAssertionFailure( | 2020 throw failedAt(node, "Invalid compound assigment: ${semantics}"); |
2031 node, "Invalid compound assigment: ${semantics}"); | |
2032 } | 2021 } |
2033 | 2022 |
2034 String toString() => 'postfix($operator,$semantics)'; | 2023 String toString() => 'postfix($operator,$semantics)'; |
2035 } | 2024 } |
2036 | 2025 |
2037 /// The structure for a [Send] whose prefix is a prefix for a deferred library. | 2026 /// The structure for a [Send] whose prefix is a prefix for a deferred library. |
2038 /// For instance `deferred.a` where `deferred` is a deferred prefix. | 2027 /// For instance `deferred.a` where `deferred` is a deferred prefix. |
2039 class DeferredPrefixStructure<R, A> implements SendStructure<R, A> { | 2028 class DeferredPrefixStructure<R, A> implements SendStructure<R, A> { |
2040 /// The deferred prefix element. | 2029 /// The deferred prefix element. |
2041 final PrefixElement prefix; | 2030 final PrefixElement prefix; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 arg); | 2161 arg); |
2173 case ConstructorAccessKind.INCOMPATIBLE: | 2162 case ConstructorAccessKind.INCOMPATIBLE: |
2174 return visitor.visitConstructorIncompatibleInvoke( | 2163 return visitor.visitConstructorIncompatibleInvoke( |
2175 node, | 2164 node, |
2176 semantics.element, | 2165 semantics.element, |
2177 semantics.type, | 2166 semantics.type, |
2178 node.send.argumentsNode, | 2167 node.send.argumentsNode, |
2179 callStructure, | 2168 callStructure, |
2180 arg); | 2169 arg); |
2181 } | 2170 } |
2182 throw new SpannableAssertionFailure( | 2171 throw failedAt( |
2183 node, "Unhandled constructor invocation kind: ${semantics.kind}"); | 2172 node, "Unhandled constructor invocation kind: ${semantics.kind}"); |
2184 } | 2173 } |
2185 | 2174 |
2186 String toString() => 'new($semantics,$selector)'; | 2175 String toString() => 'new($semantics,$selector)'; |
2187 } | 2176 } |
2188 | 2177 |
2189 enum ConstantInvokeKind { | 2178 enum ConstantInvokeKind { |
2190 CONSTRUCTED, | 2179 CONSTRUCTED, |
2191 BOOL_FROM_ENVIRONMENT, | 2180 BOOL_FROM_ENVIRONMENT, |
2192 INT_FROM_ENVIRONMENT, | 2181 INT_FROM_ENVIRONMENT, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT: | 2248 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT: |
2260 kind = ConstantInvokeKind.BOOL_FROM_ENVIRONMENT; | 2249 kind = ConstantInvokeKind.BOOL_FROM_ENVIRONMENT; |
2261 break; | 2250 break; |
2262 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: | 2251 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: |
2263 kind = ConstantInvokeKind.INT_FROM_ENVIRONMENT; | 2252 kind = ConstantInvokeKind.INT_FROM_ENVIRONMENT; |
2264 break; | 2253 break; |
2265 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT: | 2254 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT: |
2266 kind = ConstantInvokeKind.STRING_FROM_ENVIRONMENT; | 2255 kind = ConstantInvokeKind.STRING_FROM_ENVIRONMENT; |
2267 break; | 2256 break; |
2268 default: | 2257 default: |
2269 throw new SpannableAssertionFailure( | 2258 throw failedAt( |
2270 node, "Unexpected constant kind $kind: ${constant.toDartText()}"); | 2259 node, "Unexpected constant kind $kind: ${constant.toDartText()}"); |
2271 } | 2260 } |
2272 return new ConstInvokeStructure(kind, constant); | 2261 return new ConstInvokeStructure(kind, constant); |
2273 } | 2262 } |
2274 } | 2263 } |
2275 | 2264 |
2276 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { | 2265 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { |
2277 Element element = elements[node.send]; | 2266 Element element = elements[node.send]; |
2278 Selector selector = elements.getSelector(node.send); | 2267 Selector selector = elements.getSelector(node.send); |
2279 ResolutionDartType type = elements.getType(node); | 2268 ResolutionDartType type = elements.getType(node); |
(...skipping 13 matching lines...) Expand all Loading... |
2293 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT: | 2282 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT: |
2294 return visitor.visitBoolFromEnvironmentConstructorInvoke( | 2283 return visitor.visitBoolFromEnvironmentConstructorInvoke( |
2295 node, constant, arg); | 2284 node, constant, arg); |
2296 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: | 2285 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: |
2297 return visitor.visitIntFromEnvironmentConstructorInvoke( | 2286 return visitor.visitIntFromEnvironmentConstructorInvoke( |
2298 node, constant, arg); | 2287 node, constant, arg); |
2299 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT: | 2288 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT: |
2300 return visitor.visitStringFromEnvironmentConstructorInvoke( | 2289 return visitor.visitStringFromEnvironmentConstructorInvoke( |
2301 node, constant, arg); | 2290 node, constant, arg); |
2302 default: | 2291 default: |
2303 throw new SpannableAssertionFailure( | 2292 throw failedAt( |
2304 node, "Unexpected constant kind $kind: ${constant.toDartText()}"); | 2293 node, "Unexpected constant kind $kind: ${constant.toDartText()}"); |
2305 } | 2294 } |
2306 } | 2295 } |
2307 } | 2296 } |
2308 } | 2297 } |
2309 | 2298 |
2310 /// The structure of a parameter declaration. | 2299 /// The structure of a parameter declaration. |
2311 abstract class ParameterStructure<R, A> { | 2300 abstract class ParameterStructure<R, A> { |
2312 final VariableDefinitions definitions; | 2301 final VariableDefinitions definitions; |
2313 final Node node; | 2302 final Node node; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2437 return visitor.visitTopLevelConstantDeclaration( | 2426 return visitor.visitTopLevelConstantDeclaration( |
2438 definitions, node, variable, constant, arg); | 2427 definitions, node, variable, constant, arg); |
2439 case VariableKind.STATIC_FIELD: | 2428 case VariableKind.STATIC_FIELD: |
2440 return visitor.visitStaticConstantDeclaration( | 2429 return visitor.visitStaticConstantDeclaration( |
2441 definitions, node, variable, constant, arg); | 2430 definitions, node, variable, constant, arg); |
2442 case VariableKind.LOCAL_VARIABLE: | 2431 case VariableKind.LOCAL_VARIABLE: |
2443 return visitor.visitLocalConstantDeclaration( | 2432 return visitor.visitLocalConstantDeclaration( |
2444 definitions, node, variable, constant, arg); | 2433 definitions, node, variable, constant, arg); |
2445 default: | 2434 default: |
2446 } | 2435 } |
2447 throw new SpannableAssertionFailure( | 2436 throw failedAt(node, "Invalid constant variable: $variable"); |
2448 node, "Invalid constant variable: $variable"); | |
2449 } | 2437 } |
2450 } | 2438 } |
2451 | 2439 |
2452 class InitializersStructure<R, A> { | 2440 class InitializersStructure<R, A> { |
2453 final List<InitializerStructure<R, A>> initializers; | 2441 final List<InitializerStructure<R, A>> initializers; |
2454 | 2442 |
2455 InitializersStructure(this.initializers); | 2443 InitializersStructure(this.initializers); |
2456 } | 2444 } |
2457 | 2445 |
2458 abstract class InitializerStructure<R, A> { | 2446 abstract class InitializerStructure<R, A> { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 ThisConstructorInvokeStructure( | 2503 ThisConstructorInvokeStructure( |
2516 this.node, this.constructor, this.callStructure); | 2504 this.node, this.constructor, this.callStructure); |
2517 | 2505 |
2518 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { | 2506 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { |
2519 return visitor.visitThisConstructorInvoke( | 2507 return visitor.visitThisConstructorInvoke( |
2520 node, constructor, node.argumentsNode, callStructure, arg); | 2508 node, constructor, node.argumentsNode, callStructure, arg); |
2521 } | 2509 } |
2522 | 2510 |
2523 bool get isConstructorInvoke => true; | 2511 bool get isConstructorInvoke => true; |
2524 } | 2512 } |
OLD | NEW |