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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 } | 759 } |
760 | 760 |
761 String toString() => 'set($selector,$semantics)'; | 761 String toString() => 'set($selector,$semantics)'; |
762 } | 762 } |
763 | 763 |
764 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. | 764 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. |
765 class NotStructure<R, A> implements SendStructure<R, A> { | 765 class NotStructure<R, A> implements SendStructure<R, A> { |
766 /// The target of the negation. | 766 /// The target of the negation. |
767 final AccessSemantics semantics; | 767 final AccessSemantics semantics; |
768 | 768 |
769 // TODO(johnniwinther): Should we store this? | 769 NotStructure(this.semantics); |
770 final Selector selector; | |
771 | |
772 NotStructure(this.semantics, this.selector); | |
773 | 770 |
774 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 771 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
775 switch (semantics.kind) { | 772 switch (semantics.kind) { |
776 case AccessKind.DYNAMIC_PROPERTY: | 773 case AccessKind.DYNAMIC_PROPERTY: |
777 return visitor.visitNot( | 774 return visitor.visitNot( |
778 node, | 775 node, |
779 node.receiver, | 776 node.receiver, |
780 arg); | 777 arg); |
781 default: | 778 default: |
782 // This is not a valid case. | 779 // This is not a valid case. |
783 break; | 780 break; |
784 } | 781 } |
785 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}"); | 782 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}"); |
786 } | 783 } |
787 | 784 |
788 String toString() => 'not($selector,$semantics)'; | 785 String toString() => 'not($semantics)'; |
789 } | 786 } |
790 | 787 |
791 /// The structure for a [Send] that is an invocation of a user definable unary | 788 /// The structure for a [Send] that is an invocation of a user definable unary |
792 /// operator. | 789 /// operator. |
793 class UnaryStructure<R, A> implements SendStructure<R, A> { | 790 class UnaryStructure<R, A> implements SendStructure<R, A> { |
794 /// The target of the unary operation. | 791 /// The target of the unary operation. |
795 final AccessSemantics semantics; | 792 final AccessSemantics semantics; |
796 | 793 |
797 /// The user definable unary operator. | 794 /// The user definable unary operator. |
798 final UnaryOperator operator; | 795 final UnaryOperator operator; |
799 | 796 |
800 // TODO(johnniwinther): Should we store this? | 797 UnaryStructure(this.semantics, this.operator); |
801 /// The [Selector] for the unary operator invocation. | |
802 final Selector selector; | |
803 | |
804 UnaryStructure(this.semantics, this.operator, this.selector); | |
805 | 798 |
806 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 799 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
807 switch (semantics.kind) { | 800 switch (semantics.kind) { |
808 case AccessKind.DYNAMIC_PROPERTY: | 801 case AccessKind.DYNAMIC_PROPERTY: |
809 return visitor.visitUnary( | 802 return visitor.visitUnary( |
810 node, | 803 node, |
811 operator, | 804 operator, |
812 node.receiver, | 805 node.receiver, |
813 arg); | 806 arg); |
814 case AccessKind.SUPER_METHOD: | 807 case AccessKind.SUPER_METHOD: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 | 842 |
850 String toString() => 'invalid unary'; | 843 String toString() => 'invalid unary'; |
851 } | 844 } |
852 | 845 |
853 /// The structure for a [Send] that is an index expression, i.e. of the form | 846 /// The structure for a [Send] that is an index expression, i.e. of the form |
854 /// `a[b]`. | 847 /// `a[b]`. |
855 class IndexStructure<R, A> implements SendStructure<R, A> { | 848 class IndexStructure<R, A> implements SendStructure<R, A> { |
856 /// The target of the left operand. | 849 /// The target of the left operand. |
857 final AccessSemantics semantics; | 850 final AccessSemantics semantics; |
858 | 851 |
859 // TODO(johnniwinther): Should we store this? | 852 IndexStructure(this.semantics); |
860 /// The [Selector] for the `[]` invocation. | |
861 final Selector selector; | |
862 | |
863 IndexStructure(this.semantics, this.selector); | |
864 | 853 |
865 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 854 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
866 switch (semantics.kind) { | 855 switch (semantics.kind) { |
867 case AccessKind.DYNAMIC_PROPERTY: | 856 case AccessKind.DYNAMIC_PROPERTY: |
868 return visitor.visitIndex( | 857 return visitor.visitIndex( |
869 node, | 858 node, |
870 node.receiver, | 859 node.receiver, |
871 node.arguments.single, | 860 node.arguments.single, |
872 arg); | 861 arg); |
873 case AccessKind.SUPER_METHOD: | 862 case AccessKind.SUPER_METHOD: |
(...skipping 15 matching lines...) Expand all Loading... |
889 throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}"); | 878 throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}"); |
890 } | 879 } |
891 } | 880 } |
892 | 881 |
893 /// The structure for a [Send] that is an equals test, i.e. of the form | 882 /// The structure for a [Send] that is an equals test, i.e. of the form |
894 /// `a == b`. | 883 /// `a == b`. |
895 class EqualsStructure<R, A> implements SendStructure<R, A> { | 884 class EqualsStructure<R, A> implements SendStructure<R, A> { |
896 /// The target of the left operand. | 885 /// The target of the left operand. |
897 final AccessSemantics semantics; | 886 final AccessSemantics semantics; |
898 | 887 |
899 // TODO(johnniwinther): Should we store this? | 888 EqualsStructure(this.semantics); |
900 /// The [Selector] for the `==` invocation. | |
901 final Selector selector; | |
902 | |
903 EqualsStructure(this.semantics, this.selector); | |
904 | 889 |
905 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 890 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
906 switch (semantics.kind) { | 891 switch (semantics.kind) { |
907 case AccessKind.DYNAMIC_PROPERTY: | 892 case AccessKind.DYNAMIC_PROPERTY: |
908 return visitor.visitEquals( | 893 return visitor.visitEquals( |
909 node, | 894 node, |
910 node.receiver, | 895 node.receiver, |
911 node.arguments.single, | 896 node.arguments.single, |
912 arg); | 897 arg); |
913 case AccessKind.SUPER_METHOD: | 898 case AccessKind.SUPER_METHOD: |
(...skipping 11 matching lines...) Expand all Loading... |
925 | 910 |
926 String toString() => '==($semantics)'; | 911 String toString() => '==($semantics)'; |
927 } | 912 } |
928 | 913 |
929 /// The structure for a [Send] that is a not-equals test, i.e. of the form | 914 /// The structure for a [Send] that is a not-equals test, i.e. of the form |
930 /// `a != b`. | 915 /// `a != b`. |
931 class NotEqualsStructure<R, A> implements SendStructure<R, A> { | 916 class NotEqualsStructure<R, A> implements SendStructure<R, A> { |
932 /// The target of the left operand. | 917 /// The target of the left operand. |
933 final AccessSemantics semantics; | 918 final AccessSemantics semantics; |
934 | 919 |
935 // TODO(johnniwinther): Should we store this? | 920 NotEqualsStructure(this.semantics); |
936 /// The [Selector] for the underlying `==` invocation. | |
937 final Selector selector; | |
938 | |
939 NotEqualsStructure(this.semantics, this.selector); | |
940 | 921 |
941 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 922 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
942 switch (semantics.kind) { | 923 switch (semantics.kind) { |
943 case AccessKind.DYNAMIC_PROPERTY: | 924 case AccessKind.DYNAMIC_PROPERTY: |
944 return visitor.visitNotEquals( | 925 return visitor.visitNotEquals( |
945 node, | 926 node, |
946 node.receiver, | 927 node.receiver, |
947 node.arguments.single, | 928 node.arguments.single, |
948 arg); | 929 arg); |
949 case AccessKind.SUPER_METHOD: | 930 case AccessKind.SUPER_METHOD: |
(...skipping 15 matching lines...) Expand all Loading... |
965 | 946 |
966 /// The structure for a [Send] that is an invocation of a user-definable binary | 947 /// The structure for a [Send] that is an invocation of a user-definable binary |
967 /// operator. | 948 /// operator. |
968 class BinaryStructure<R, A> implements SendStructure<R, A> { | 949 class BinaryStructure<R, A> implements SendStructure<R, A> { |
969 /// The target of the left operand. | 950 /// The target of the left operand. |
970 final AccessSemantics semantics; | 951 final AccessSemantics semantics; |
971 | 952 |
972 /// The user definable binary operator. | 953 /// The user definable binary operator. |
973 final BinaryOperator operator; | 954 final BinaryOperator operator; |
974 | 955 |
975 // TODO(johnniwinther): Should we store this? | 956 BinaryStructure(this.semantics, this.operator); |
976 /// The [Selector] for the binary operator invocation. | |
977 final Selector selector; | |
978 | |
979 BinaryStructure(this.semantics, this.operator, this.selector); | |
980 | 957 |
981 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 958 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
982 switch (semantics.kind) { | 959 switch (semantics.kind) { |
983 case AccessKind.DYNAMIC_PROPERTY: | 960 case AccessKind.DYNAMIC_PROPERTY: |
984 return visitor.visitBinary( | 961 return visitor.visitBinary( |
985 node, | 962 node, |
986 node.receiver, | 963 node.receiver, |
987 operator, | 964 operator, |
988 node.arguments.single, | 965 node.arguments.single, |
989 arg); | 966 arg); |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2530 final ConstructorElement constructor; | 2507 final ConstructorElement constructor; |
2531 final Selector selector; | 2508 final Selector selector; |
2532 | 2509 |
2533 ThisConstructorInvokeStructure(this.constructor, this.selector); | 2510 ThisConstructorInvokeStructure(this.constructor, this.selector); |
2534 | 2511 |
2535 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { | 2512 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { |
2536 return visitor.visitThisConstructorInvoke( | 2513 return visitor.visitThisConstructorInvoke( |
2537 node, constructor, node.argumentsNode, selector, arg); | 2514 node, constructor, node.argumentsNode, selector, arg); |
2538 } | 2515 } |
2539 } | 2516 } |
OLD | NEW |