| ... | @@ -419,13 +419,16 @@ pub const Tree = struct { | ... | @@ -419,13 +419,16 @@ pub const Tree = struct { |
| 419 | n = extra.start; | 419 | n = extra.start; |
| 420 | }, | 420 | }, |
| 421 | | 421 | |
| | 422 | .AsmOutput, .AsmInput => { |
| | 423 | assert(token_tags[main_tokens[n] - 1] == .LBracket); |
| | 424 | return main_tokens[n] - 1; |
| | 425 | }, |
| | 426 | |
| 422 | .WhileSimple => unreachable, // TODO | 427 | .WhileSimple => unreachable, // TODO |
| 423 | .WhileCont => unreachable, // TODO | 428 | .WhileCont => unreachable, // TODO |
| 424 | .While => unreachable, // TODO | 429 | .While => unreachable, // TODO |
| 425 | .ForSimple => unreachable, // TODO | 430 | .ForSimple => unreachable, // TODO |
| 426 | .For => unreachable, // TODO | 431 | .For => unreachable, // TODO |
| 427 | .AsmOutput => unreachable, // TODO | | |
| 428 | .AsmInput => unreachable, // TODO | | |
| 429 | .ErrorValue => unreachable, // TODO | 432 | .ErrorValue => unreachable, // TODO |
| 430 | }; | 433 | }; |
| 431 | } | 434 | } |
| ... | @@ -515,6 +518,9 @@ pub const Tree = struct { | ... | @@ -515,6 +518,9 @@ pub const Tree = struct { |
| 515 | .GroupedExpression, | 518 | .GroupedExpression, |
| 516 | .StringLiteral, | 519 | .StringLiteral, |
| 517 | .ErrorSetDecl, | 520 | .ErrorSetDecl, |
| | 521 | .AsmSimple, |
| | 522 | .AsmOutput, |
| | 523 | .AsmInput, |
| 518 | => return datas[n].rhs + end_offset, | 524 | => return datas[n].rhs + end_offset, |
| 519 | | 525 | |
| 520 | .AnyType, | 526 | .AnyType, |
| ... | @@ -566,6 +572,10 @@ pub const Tree = struct { | ... | @@ -566,6 +572,10 @@ pub const Tree = struct { |
| 566 | n = tree.extra_data[members.end - 1]; // last parameter | 572 | n = tree.extra_data[members.end - 1]; // last parameter |
| 567 | } | 573 | } |
| 568 | }, | 574 | }, |
| | 575 | .Asm => { |
| | 576 | const extra = tree.extraData(datas[n].rhs, Node.Asm); |
| | 577 | return extra.rparen + end_offset; |
| | 578 | }, |
| 569 | .ContainerDeclArgComma, | 579 | .ContainerDeclArgComma, |
| 570 | .SwitchComma, | 580 | .SwitchComma, |
| 571 | => { | 581 | => { |
| ... | @@ -765,8 +775,6 @@ pub const Tree = struct { | ... | @@ -765,8 +775,6 @@ pub const Tree = struct { |
| 765 | .TaggedUnionEnumTagComma => unreachable, // TODO | 775 | .TaggedUnionEnumTagComma => unreachable, // TODO |
| 766 | .If => unreachable, // TODO | 776 | .If => unreachable, // TODO |
| 767 | .Continue => unreachable, // TODO | 777 | .Continue => unreachable, // TODO |
| 768 | .AsmSimple => unreachable, // TODO | | |
| 769 | .Asm => unreachable, // TODO | | |
| 770 | .SwitchRange => unreachable, // TODO | 778 | .SwitchRange => unreachable, // TODO |
| 771 | .ArrayType => unreachable, // TODO | 779 | .ArrayType => unreachable, // TODO |
| 772 | .ArrayTypeSentinel => unreachable, // TODO | 780 | .ArrayTypeSentinel => unreachable, // TODO |
| ... | @@ -778,8 +786,6 @@ pub const Tree = struct { | ... | @@ -778,8 +786,6 @@ pub const Tree = struct { |
| 778 | .FnProtoMulti => unreachable, // TODO | 786 | .FnProtoMulti => unreachable, // TODO |
| 779 | .FnProtoOne => unreachable, // TODO | 787 | .FnProtoOne => unreachable, // TODO |
| 780 | .FnProto => unreachable, // TODO | 788 | .FnProto => unreachable, // TODO |
| 781 | .AsmOutput => unreachable, // TODO | | |
| 782 | .AsmInput => unreachable, // TODO | | |
| 783 | .ErrorValue => unreachable, // TODO | 789 | .ErrorValue => unreachable, // TODO |
| 784 | }; | 790 | }; |
| 785 | } | 791 | } |
| ... | @@ -790,7 +796,7 @@ pub const Tree = struct { | ... | @@ -790,7 +796,7 @@ pub const Tree = struct { |
| 790 | return mem.indexOfScalar(u8, source, '\n') == null; | 796 | return mem.indexOfScalar(u8, source, '\n') == null; |
| 791 | } | 797 | } |
| 792 | | 798 | |
| 793 | pub fn globalVarDecl(tree: Tree, node: Node.Index) Full.VarDecl { | 799 | pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 794 | assert(tree.nodes.items(.tag)[node] == .GlobalVarDecl); | 800 | assert(tree.nodes.items(.tag)[node] == .GlobalVarDecl); |
| 795 | const data = tree.nodes.items(.data)[node]; | 801 | const data = tree.nodes.items(.data)[node]; |
| 796 | const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); | 802 | const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); |
| ... | @@ -803,7 +809,7 @@ pub const Tree = struct { | ... | @@ -803,7 +809,7 @@ pub const Tree = struct { |
| 803 | }); | 809 | }); |
| 804 | } | 810 | } |
| 805 | | 811 | |
| 806 | pub fn localVarDecl(tree: Tree, node: Node.Index) Full.VarDecl { | 812 | pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 807 | assert(tree.nodes.items(.tag)[node] == .LocalVarDecl); | 813 | assert(tree.nodes.items(.tag)[node] == .LocalVarDecl); |
| 808 | const data = tree.nodes.items(.data)[node]; | 814 | const data = tree.nodes.items(.data)[node]; |
| 809 | const extra = tree.extraData(data.lhs, Node.LocalVarDecl); | 815 | const extra = tree.extraData(data.lhs, Node.LocalVarDecl); |
| ... | @@ -816,7 +822,7 @@ pub const Tree = struct { | ... | @@ -816,7 +822,7 @@ pub const Tree = struct { |
| 816 | }); | 822 | }); |
| 817 | } | 823 | } |
| 818 | | 824 | |
| 819 | pub fn simpleVarDecl(tree: Tree, node: Node.Index) Full.VarDecl { | 825 | pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 820 | assert(tree.nodes.items(.tag)[node] == .SimpleVarDecl); | 826 | assert(tree.nodes.items(.tag)[node] == .SimpleVarDecl); |
| 821 | const data = tree.nodes.items(.data)[node]; | 827 | const data = tree.nodes.items(.data)[node]; |
| 822 | return tree.fullVarDecl(.{ | 828 | return tree.fullVarDecl(.{ |
| ... | @@ -828,7 +834,7 @@ pub const Tree = struct { | ... | @@ -828,7 +834,7 @@ pub const Tree = struct { |
| 828 | }); | 834 | }); |
| 829 | } | 835 | } |
| 830 | | 836 | |
| 831 | pub fn alignedVarDecl(tree: Tree, node: Node.Index) Full.VarDecl { | 837 | pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 832 | assert(tree.nodes.items(.tag)[node] == .AlignedVarDecl); | 838 | assert(tree.nodes.items(.tag)[node] == .AlignedVarDecl); |
| 833 | const data = tree.nodes.items(.data)[node]; | 839 | const data = tree.nodes.items(.data)[node]; |
| 834 | return tree.fullVarDecl(.{ | 840 | return tree.fullVarDecl(.{ |
| ... | @@ -840,7 +846,7 @@ pub const Tree = struct { | ... | @@ -840,7 +846,7 @@ pub const Tree = struct { |
| 840 | }); | 846 | }); |
| 841 | } | 847 | } |
| 842 | | 848 | |
| 843 | pub fn ifSimple(tree: Tree, node: Node.Index) Full.If { | 849 | pub fn ifSimple(tree: Tree, node: Node.Index) full.If { |
| 844 | assert(tree.nodes.items(.tag)[node] == .IfSimple); | 850 | assert(tree.nodes.items(.tag)[node] == .IfSimple); |
| 845 | const data = tree.nodes.items(.data)[node]; | 851 | const data = tree.nodes.items(.data)[node]; |
| 846 | return tree.fullIf(.{ | 852 | return tree.fullIf(.{ |
| ... | @@ -851,7 +857,7 @@ pub const Tree = struct { | ... | @@ -851,7 +857,7 @@ pub const Tree = struct { |
| 851 | }); | 857 | }); |
| 852 | } | 858 | } |
| 853 | | 859 | |
| 854 | pub fn ifFull(tree: Tree, node: Node.Index) Full.If { | 860 | pub fn ifFull(tree: Tree, node: Node.Index) full.If { |
| 855 | assert(tree.nodes.items(.tag)[node] == .If); | 861 | assert(tree.nodes.items(.tag)[node] == .If); |
| 856 | const data = tree.nodes.items(.data)[node]; | 862 | const data = tree.nodes.items(.data)[node]; |
| 857 | const extra = tree.extraData(data.rhs, Node.If); | 863 | const extra = tree.extraData(data.rhs, Node.If); |
| ... | @@ -863,7 +869,7 @@ pub const Tree = struct { | ... | @@ -863,7 +869,7 @@ pub const Tree = struct { |
| 863 | }); | 869 | }); |
| 864 | } | 870 | } |
| 865 | | 871 | |
| 866 | pub fn containerField(tree: Tree, node: Node.Index) Full.ContainerField { | 872 | pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField { |
| 867 | assert(tree.nodes.items(.tag)[node] == .ContainerField); | 873 | assert(tree.nodes.items(.tag)[node] == .ContainerField); |
| 868 | const data = tree.nodes.items(.data)[node]; | 874 | const data = tree.nodes.items(.data)[node]; |
| 869 | const extra = tree.extraData(data.rhs, Node.ContainerField); | 875 | const extra = tree.extraData(data.rhs, Node.ContainerField); |
| ... | @@ -875,7 +881,7 @@ pub const Tree = struct { | ... | @@ -875,7 +881,7 @@ pub const Tree = struct { |
| 875 | }); | 881 | }); |
| 876 | } | 882 | } |
| 877 | | 883 | |
| 878 | pub fn containerFieldInit(tree: Tree, node: Node.Index) Full.ContainerField { | 884 | pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField { |
| 879 | assert(tree.nodes.items(.tag)[node] == .ContainerFieldInit); | 885 | assert(tree.nodes.items(.tag)[node] == .ContainerFieldInit); |
| 880 | const data = tree.nodes.items(.data)[node]; | 886 | const data = tree.nodes.items(.data)[node]; |
| 881 | return tree.fullContainerField(.{ | 887 | return tree.fullContainerField(.{ |
| ... | @@ -886,7 +892,7 @@ pub const Tree = struct { | ... | @@ -886,7 +892,7 @@ pub const Tree = struct { |
| 886 | }); | 892 | }); |
| 887 | } | 893 | } |
| 888 | | 894 | |
| 889 | pub fn containerFieldAlign(tree: Tree, node: Node.Index) Full.ContainerField { | 895 | pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField { |
| 890 | assert(tree.nodes.items(.tag)[node] == .ContainerFieldAlign); | 896 | assert(tree.nodes.items(.tag)[node] == .ContainerFieldAlign); |
| 891 | const data = tree.nodes.items(.data)[node]; | 897 | const data = tree.nodes.items(.data)[node]; |
| 892 | return tree.fullContainerField(.{ | 898 | return tree.fullContainerField(.{ |
| ... | @@ -897,7 +903,7 @@ pub const Tree = struct { | ... | @@ -897,7 +903,7 @@ pub const Tree = struct { |
| 897 | }); | 903 | }); |
| 898 | } | 904 | } |
| 899 | | 905 | |
| 900 | pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) Full.FnProto { | 906 | pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { |
| 901 | assert(tree.nodes.items(.tag)[node] == .FnProtoSimple); | 907 | assert(tree.nodes.items(.tag)[node] == .FnProtoSimple); |
| 902 | const data = tree.nodes.items(.data)[node]; | 908 | const data = tree.nodes.items(.data)[node]; |
| 903 | buffer[0] = data.lhs; | 909 | buffer[0] = data.lhs; |
| ... | @@ -912,7 +918,7 @@ pub const Tree = struct { | ... | @@ -912,7 +918,7 @@ pub const Tree = struct { |
| 912 | }); | 918 | }); |
| 913 | } | 919 | } |
| 914 | | 920 | |
| 915 | pub fn fnProtoMulti(tree: Tree, node: Node.Index) Full.FnProto { | 921 | pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto { |
| 916 | assert(tree.nodes.items(.tag)[node] == .FnProtoMulti); | 922 | assert(tree.nodes.items(.tag)[node] == .FnProtoMulti); |
| 917 | const data = tree.nodes.items(.data)[node]; | 923 | const data = tree.nodes.items(.data)[node]; |
| 918 | const params_range = tree.extraData(data.lhs, Node.SubRange); | 924 | const params_range = tree.extraData(data.lhs, Node.SubRange); |
| ... | @@ -927,7 +933,7 @@ pub const Tree = struct { | ... | @@ -927,7 +933,7 @@ pub const Tree = struct { |
| 927 | }); | 933 | }); |
| 928 | } | 934 | } |
| 929 | | 935 | |
| 930 | pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) Full.FnProto { | 936 | pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { |
| 931 | assert(tree.nodes.items(.tag)[node] == .FnProtoOne); | 937 | assert(tree.nodes.items(.tag)[node] == .FnProtoOne); |
| 932 | const data = tree.nodes.items(.data)[node]; | 938 | const data = tree.nodes.items(.data)[node]; |
| 933 | const extra = tree.extraData(data.lhs, Node.FnProtoOne); | 939 | const extra = tree.extraData(data.lhs, Node.FnProtoOne); |
| ... | @@ -943,7 +949,7 @@ pub const Tree = struct { | ... | @@ -943,7 +949,7 @@ pub const Tree = struct { |
| 943 | }); | 949 | }); |
| 944 | } | 950 | } |
| 945 | | 951 | |
| 946 | pub fn fnProto(tree: Tree, node: Node.Index) Full.FnProto { | 952 | pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto { |
| 947 | assert(tree.nodes.items(.tag)[node] == .FnProto); | 953 | assert(tree.nodes.items(.tag)[node] == .FnProto); |
| 948 | const data = tree.nodes.items(.data)[node]; | 954 | const data = tree.nodes.items(.data)[node]; |
| 949 | const extra = tree.extraData(data.lhs, Node.FnProto); | 955 | const extra = tree.extraData(data.lhs, Node.FnProto); |
| ... | @@ -958,7 +964,7 @@ pub const Tree = struct { | ... | @@ -958,7 +964,7 @@ pub const Tree = struct { |
| 958 | }); | 964 | }); |
| 959 | } | 965 | } |
| 960 | | 966 | |
| 961 | pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) Full.StructInit { | 967 | pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit { |
| 962 | assert(tree.nodes.items(.tag)[node] == .StructInitOne); | 968 | assert(tree.nodes.items(.tag)[node] == .StructInitOne); |
| 963 | const data = tree.nodes.items(.data)[node]; | 969 | const data = tree.nodes.items(.data)[node]; |
| 964 | buffer[0] = data.rhs; | 970 | buffer[0] = data.rhs; |
| ... | @@ -970,7 +976,7 @@ pub const Tree = struct { | ... | @@ -970,7 +976,7 @@ pub const Tree = struct { |
| 970 | }); | 976 | }); |
| 971 | } | 977 | } |
| 972 | | 978 | |
| 973 | pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) Full.StructInit { | 979 | pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { |
| 974 | assert(tree.nodes.items(.tag)[node] == .StructInitDotTwo or | 980 | assert(tree.nodes.items(.tag)[node] == .StructInitDotTwo or |
| 975 | tree.nodes.items(.tag)[node] == .StructInitDotTwoComma); | 981 | tree.nodes.items(.tag)[node] == .StructInitDotTwoComma); |
| 976 | const data = tree.nodes.items(.data)[node]; | 982 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -988,7 +994,7 @@ pub const Tree = struct { | ... | @@ -988,7 +994,7 @@ pub const Tree = struct { |
| 988 | }); | 994 | }); |
| 989 | } | 995 | } |
| 990 | | 996 | |
| 991 | pub fn structInitDot(tree: Tree, node: Node.Index) Full.StructInit { | 997 | pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit { |
| 992 | assert(tree.nodes.items(.tag)[node] == .StructInitDot); | 998 | assert(tree.nodes.items(.tag)[node] == .StructInitDot); |
| 993 | const data = tree.nodes.items(.data)[node]; | 999 | const data = tree.nodes.items(.data)[node]; |
| 994 | return tree.fullStructInit(.{ | 1000 | return tree.fullStructInit(.{ |
| ... | @@ -998,7 +1004,7 @@ pub const Tree = struct { | ... | @@ -998,7 +1004,7 @@ pub const Tree = struct { |
| 998 | }); | 1004 | }); |
| 999 | } | 1005 | } |
| 1000 | | 1006 | |
| 1001 | pub fn structInit(tree: Tree, node: Node.Index) Full.StructInit { | 1007 | pub fn structInit(tree: Tree, node: Node.Index) full.StructInit { |
| 1002 | assert(tree.nodes.items(.tag)[node] == .StructInit); | 1008 | assert(tree.nodes.items(.tag)[node] == .StructInit); |
| 1003 | const data = tree.nodes.items(.data)[node]; | 1009 | const data = tree.nodes.items(.data)[node]; |
| 1004 | const fields_range = tree.extraData(data.rhs, Node.SubRange); | 1010 | const fields_range = tree.extraData(data.rhs, Node.SubRange); |
| ... | @@ -1009,7 +1015,7 @@ pub const Tree = struct { | ... | @@ -1009,7 +1015,7 @@ pub const Tree = struct { |
| 1009 | }); | 1015 | }); |
| 1010 | } | 1016 | } |
| 1011 | | 1017 | |
| 1012 | pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) Full.ArrayInit { | 1018 | pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { |
| 1013 | assert(tree.nodes.items(.tag)[node] == .ArrayInitOne); | 1019 | assert(tree.nodes.items(.tag)[node] == .ArrayInitOne); |
| 1014 | const data = tree.nodes.items(.data)[node]; | 1020 | const data = tree.nodes.items(.data)[node]; |
| 1015 | buffer[0] = data.rhs; | 1021 | buffer[0] = data.rhs; |
| ... | @@ -1023,7 +1029,7 @@ pub const Tree = struct { | ... | @@ -1023,7 +1029,7 @@ pub const Tree = struct { |
| 1023 | }; | 1029 | }; |
| 1024 | } | 1030 | } |
| 1025 | | 1031 | |
| 1026 | pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) Full.ArrayInit { | 1032 | pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit { |
| 1027 | assert(tree.nodes.items(.tag)[node] == .ArrayInitDotTwo or | 1033 | assert(tree.nodes.items(.tag)[node] == .ArrayInitDotTwo or |
| 1028 | tree.nodes.items(.tag)[node] == .ArrayInitDotTwoComma); | 1034 | tree.nodes.items(.tag)[node] == .ArrayInitDotTwoComma); |
| 1029 | const data = tree.nodes.items(.data)[node]; | 1035 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1043,7 +1049,7 @@ pub const Tree = struct { | ... | @@ -1043,7 +1049,7 @@ pub const Tree = struct { |
| 1043 | }; | 1049 | }; |
| 1044 | } | 1050 | } |
| 1045 | | 1051 | |
| 1046 | pub fn arrayInitDot(tree: Tree, node: Node.Index) Full.ArrayInit { | 1052 | pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit { |
| 1047 | assert(tree.nodes.items(.tag)[node] == .ArrayInitDot); | 1053 | assert(tree.nodes.items(.tag)[node] == .ArrayInitDot); |
| 1048 | const data = tree.nodes.items(.data)[node]; | 1054 | const data = tree.nodes.items(.data)[node]; |
| 1049 | return .{ | 1055 | return .{ |
| ... | @@ -1055,7 +1061,7 @@ pub const Tree = struct { | ... | @@ -1055,7 +1061,7 @@ pub const Tree = struct { |
| 1055 | }; | 1061 | }; |
| 1056 | } | 1062 | } |
| 1057 | | 1063 | |
| 1058 | pub fn arrayInit(tree: Tree, node: Node.Index) Full.ArrayInit { | 1064 | pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit { |
| 1059 | assert(tree.nodes.items(.tag)[node] == .ArrayInit); | 1065 | assert(tree.nodes.items(.tag)[node] == .ArrayInit); |
| 1060 | const data = tree.nodes.items(.data)[node]; | 1066 | const data = tree.nodes.items(.data)[node]; |
| 1061 | const elem_range = tree.extraData(data.rhs, Node.SubRange); | 1067 | const elem_range = tree.extraData(data.rhs, Node.SubRange); |
| ... | @@ -1068,7 +1074,7 @@ pub const Tree = struct { | ... | @@ -1068,7 +1074,7 @@ pub const Tree = struct { |
| 1068 | }; | 1074 | }; |
| 1069 | } | 1075 | } |
| 1070 | | 1076 | |
| 1071 | pub fn arrayType(tree: Tree, node: Node.Index) Full.ArrayType { | 1077 | pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType { |
| 1072 | assert(tree.nodes.items(.tag)[node] == .ArrayType); | 1078 | assert(tree.nodes.items(.tag)[node] == .ArrayType); |
| 1073 | const data = tree.nodes.items(.data)[node]; | 1079 | const data = tree.nodes.items(.data)[node]; |
| 1074 | return .{ | 1080 | return .{ |
| ... | @@ -1081,7 +1087,7 @@ pub const Tree = struct { | ... | @@ -1081,7 +1087,7 @@ pub const Tree = struct { |
| 1081 | }; | 1087 | }; |
| 1082 | } | 1088 | } |
| 1083 | | 1089 | |
| 1084 | pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) Full.ArrayType { | 1090 | pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType { |
| 1085 | assert(tree.nodes.items(.tag)[node] == .ArrayTypeSentinel); | 1091 | assert(tree.nodes.items(.tag)[node] == .ArrayTypeSentinel); |
| 1086 | const data = tree.nodes.items(.data)[node]; | 1092 | const data = tree.nodes.items(.data)[node]; |
| 1087 | const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel); | 1093 | const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel); |
| ... | @@ -1095,7 +1101,7 @@ pub const Tree = struct { | ... | @@ -1095,7 +1101,7 @@ pub const Tree = struct { |
| 1095 | }; | 1101 | }; |
| 1096 | } | 1102 | } |
| 1097 | | 1103 | |
| 1098 | pub fn ptrTypeAligned(tree: Tree, node: Node.Index) Full.PtrType { | 1104 | pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType { |
| 1099 | assert(tree.nodes.items(.tag)[node] == .PtrTypeAligned); | 1105 | assert(tree.nodes.items(.tag)[node] == .PtrTypeAligned); |
| 1100 | const data = tree.nodes.items(.data)[node]; | 1106 | const data = tree.nodes.items(.data)[node]; |
| 1101 | return tree.fullPtrType(.{ | 1107 | return tree.fullPtrType(.{ |
| ... | @@ -1108,7 +1114,7 @@ pub const Tree = struct { | ... | @@ -1108,7 +1114,7 @@ pub const Tree = struct { |
| 1108 | }); | 1114 | }); |
| 1109 | } | 1115 | } |
| 1110 | | 1116 | |
| 1111 | pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) Full.PtrType { | 1117 | pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType { |
| 1112 | assert(tree.nodes.items(.tag)[node] == .PtrTypeSentinel); | 1118 | assert(tree.nodes.items(.tag)[node] == .PtrTypeSentinel); |
| 1113 | const data = tree.nodes.items(.data)[node]; | 1119 | const data = tree.nodes.items(.data)[node]; |
| 1114 | return tree.fullPtrType(.{ | 1120 | return tree.fullPtrType(.{ |
| ... | @@ -1121,7 +1127,7 @@ pub const Tree = struct { | ... | @@ -1121,7 +1127,7 @@ pub const Tree = struct { |
| 1121 | }); | 1127 | }); |
| 1122 | } | 1128 | } |
| 1123 | | 1129 | |
| 1124 | pub fn ptrType(tree: Tree, node: Node.Index) Full.PtrType { | 1130 | pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType { |
| 1125 | assert(tree.nodes.items(.tag)[node] == .PtrType); | 1131 | assert(tree.nodes.items(.tag)[node] == .PtrType); |
| 1126 | const data = tree.nodes.items(.data)[node]; | 1132 | const data = tree.nodes.items(.data)[node]; |
| 1127 | const extra = tree.extraData(data.lhs, Node.PtrType); | 1133 | const extra = tree.extraData(data.lhs, Node.PtrType); |
| ... | @@ -1135,7 +1141,7 @@ pub const Tree = struct { | ... | @@ -1135,7 +1141,7 @@ pub const Tree = struct { |
| 1135 | }); | 1141 | }); |
| 1136 | } | 1142 | } |
| 1137 | | 1143 | |
| 1138 | pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) Full.PtrType { | 1144 | pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType { |
| 1139 | assert(tree.nodes.items(.tag)[node] == .PtrTypeBitRange); | 1145 | assert(tree.nodes.items(.tag)[node] == .PtrTypeBitRange); |
| 1140 | const data = tree.nodes.items(.data)[node]; | 1146 | const data = tree.nodes.items(.data)[node]; |
| 1141 | const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); | 1147 | const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); |
| ... | @@ -1149,7 +1155,7 @@ pub const Tree = struct { | ... | @@ -1149,7 +1155,7 @@ pub const Tree = struct { |
| 1149 | }); | 1155 | }); |
| 1150 | } | 1156 | } |
| 1151 | | 1157 | |
| 1152 | pub fn sliceOpen(tree: Tree, node: Node.Index) Full.Slice { | 1158 | pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice { |
| 1153 | assert(tree.nodes.items(.tag)[node] == .SliceOpen); | 1159 | assert(tree.nodes.items(.tag)[node] == .SliceOpen); |
| 1154 | const data = tree.nodes.items(.data)[node]; | 1160 | const data = tree.nodes.items(.data)[node]; |
| 1155 | return .{ | 1161 | return .{ |
| ... | @@ -1163,7 +1169,7 @@ pub const Tree = struct { | ... | @@ -1163,7 +1169,7 @@ pub const Tree = struct { |
| 1163 | }; | 1169 | }; |
| 1164 | } | 1170 | } |
| 1165 | | 1171 | |
| 1166 | pub fn slice(tree: Tree, node: Node.Index) Full.Slice { | 1172 | pub fn slice(tree: Tree, node: Node.Index) full.Slice { |
| 1167 | assert(tree.nodes.items(.tag)[node] == .Slice); | 1173 | assert(tree.nodes.items(.tag)[node] == .Slice); |
| 1168 | const data = tree.nodes.items(.data)[node]; | 1174 | const data = tree.nodes.items(.data)[node]; |
| 1169 | const extra = tree.extraData(data.rhs, Node.Slice); | 1175 | const extra = tree.extraData(data.rhs, Node.Slice); |
| ... | @@ -1178,7 +1184,7 @@ pub const Tree = struct { | ... | @@ -1178,7 +1184,7 @@ pub const Tree = struct { |
| 1178 | }; | 1184 | }; |
| 1179 | } | 1185 | } |
| 1180 | | 1186 | |
| 1181 | pub fn sliceSentinel(tree: Tree, node: Node.Index) Full.Slice { | 1187 | pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice { |
| 1182 | assert(tree.nodes.items(.tag)[node] == .SliceSentinel); | 1188 | assert(tree.nodes.items(.tag)[node] == .SliceSentinel); |
| 1183 | const data = tree.nodes.items(.data)[node]; | 1189 | const data = tree.nodes.items(.data)[node]; |
| 1184 | const extra = tree.extraData(data.rhs, Node.SliceSentinel); | 1190 | const extra = tree.extraData(data.rhs, Node.SliceSentinel); |
| ... | @@ -1193,7 +1199,7 @@ pub const Tree = struct { | ... | @@ -1193,7 +1199,7 @@ pub const Tree = struct { |
| 1193 | }; | 1199 | }; |
| 1194 | } | 1200 | } |
| 1195 | | 1201 | |
| 1196 | pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) Full.ContainerDecl { | 1202 | pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { |
| 1197 | assert(tree.nodes.items(.tag)[node] == .ContainerDeclTwo or | 1203 | assert(tree.nodes.items(.tag)[node] == .ContainerDeclTwo or |
| 1198 | tree.nodes.items(.tag)[node] == .ContainerDeclTwoComma); | 1204 | tree.nodes.items(.tag)[node] == .ContainerDeclTwoComma); |
| 1199 | const data = tree.nodes.items(.data)[node]; | 1205 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1212,7 +1218,7 @@ pub const Tree = struct { | ... | @@ -1212,7 +1218,7 @@ pub const Tree = struct { |
| 1212 | }); | 1218 | }); |
| 1213 | } | 1219 | } |
| 1214 | | 1220 | |
| 1215 | pub fn containerDecl(tree: Tree, node: Node.Index) Full.ContainerDecl { | 1221 | pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1216 | assert(tree.nodes.items(.tag)[node] == .ContainerDecl or | 1222 | assert(tree.nodes.items(.tag)[node] == .ContainerDecl or |
| 1217 | tree.nodes.items(.tag)[node] == .ContainerDeclComma); | 1223 | tree.nodes.items(.tag)[node] == .ContainerDeclComma); |
| 1218 | const data = tree.nodes.items(.data)[node]; | 1224 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1224,7 +1230,7 @@ pub const Tree = struct { | ... | @@ -1224,7 +1230,7 @@ pub const Tree = struct { |
| 1224 | }); | 1230 | }); |
| 1225 | } | 1231 | } |
| 1226 | | 1232 | |
| 1227 | pub fn containerDeclArg(tree: Tree, node: Node.Index) Full.ContainerDecl { | 1233 | pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1228 | assert(tree.nodes.items(.tag)[node] == .ContainerDeclArg or | 1234 | assert(tree.nodes.items(.tag)[node] == .ContainerDeclArg or |
| 1229 | tree.nodes.items(.tag)[node] == .ContainerDeclArgComma); | 1235 | tree.nodes.items(.tag)[node] == .ContainerDeclArgComma); |
| 1230 | const data = tree.nodes.items(.data)[node]; | 1236 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1237,7 +1243,7 @@ pub const Tree = struct { | ... | @@ -1237,7 +1243,7 @@ pub const Tree = struct { |
| 1237 | }); | 1243 | }); |
| 1238 | } | 1244 | } |
| 1239 | | 1245 | |
| 1240 | pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) Full.ContainerDecl { | 1246 | pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { |
| 1241 | assert(tree.nodes.items(.tag)[node] == .TaggedUnionTwo or | 1247 | assert(tree.nodes.items(.tag)[node] == .TaggedUnionTwo or |
| 1242 | tree.nodes.items(.tag)[node] == .TaggedUnionTwoComma); | 1248 | tree.nodes.items(.tag)[node] == .TaggedUnionTwoComma); |
| 1243 | const data = tree.nodes.items(.data)[node]; | 1249 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1257,7 +1263,7 @@ pub const Tree = struct { | ... | @@ -1257,7 +1263,7 @@ pub const Tree = struct { |
| 1257 | }); | 1263 | }); |
| 1258 | } | 1264 | } |
| 1259 | | 1265 | |
| 1260 | pub fn taggedUnion(tree: Tree, node: Node.Index) Full.ContainerDecl { | 1266 | pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1261 | assert(tree.nodes.items(.tag)[node] == .TaggedUnion or | 1267 | assert(tree.nodes.items(.tag)[node] == .TaggedUnion or |
| 1262 | tree.nodes.items(.tag)[node] == .TaggedUnionComma); | 1268 | tree.nodes.items(.tag)[node] == .TaggedUnionComma); |
| 1263 | const data = tree.nodes.items(.data)[node]; | 1269 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1270,7 +1276,7 @@ pub const Tree = struct { | ... | @@ -1270,7 +1276,7 @@ pub const Tree = struct { |
| 1270 | }); | 1276 | }); |
| 1271 | } | 1277 | } |
| 1272 | | 1278 | |
| 1273 | pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) Full.ContainerDecl { | 1279 | pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1274 | assert(tree.nodes.items(.tag)[node] == .TaggedUnionEnumTag or | 1280 | assert(tree.nodes.items(.tag)[node] == .TaggedUnionEnumTag or |
| 1275 | tree.nodes.items(.tag)[node] == .TaggedUnionEnumTagComma); | 1281 | tree.nodes.items(.tag)[node] == .TaggedUnionEnumTagComma); |
| 1276 | const data = tree.nodes.items(.data)[node]; | 1282 | const data = tree.nodes.items(.data)[node]; |
| ... | @@ -1284,7 +1290,7 @@ pub const Tree = struct { | ... | @@ -1284,7 +1290,7 @@ pub const Tree = struct { |
| 1284 | }); | 1290 | }); |
| 1285 | } | 1291 | } |
| 1286 | | 1292 | |
| 1287 | pub fn switchCaseOne(tree: Tree, node: Node.Index) Full.SwitchCase { | 1293 | pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase { |
| 1288 | const data = &tree.nodes.items(.data)[node]; | 1294 | const data = &tree.nodes.items(.data)[node]; |
| 1289 | return tree.fullSwitchCase(.{ | 1295 | return tree.fullSwitchCase(.{ |
| 1290 | .values = if (data.lhs == 0) &.{} else @ptrCast([*]Node.Index, &data.lhs)[0..1], | 1296 | .values = if (data.lhs == 0) &.{} else @ptrCast([*]Node.Index, &data.lhs)[0..1], |
| ... | @@ -1293,7 +1299,7 @@ pub const Tree = struct { | ... | @@ -1293,7 +1299,7 @@ pub const Tree = struct { |
| 1293 | }); | 1299 | }); |
| 1294 | } | 1300 | } |
| 1295 | | 1301 | |
| 1296 | pub fn switchCase(tree: Tree, node: Node.Index) Full.SwitchCase { | 1302 | pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase { |
| 1297 | const data = tree.nodes.items(.data)[node]; | 1303 | const data = tree.nodes.items(.data)[node]; |
| 1298 | const extra = tree.extraData(data.lhs, Node.SubRange); | 1304 | const extra = tree.extraData(data.lhs, Node.SubRange); |
| 1299 | return tree.fullSwitchCase(.{ | 1305 | return tree.fullSwitchCase(.{ |
| ... | @@ -1303,9 +1309,30 @@ pub const Tree = struct { | ... | @@ -1303,9 +1309,30 @@ pub const Tree = struct { |
| 1303 | }); | 1309 | }); |
| 1304 | } | 1310 | } |
| 1305 | | 1311 | |
| 1306 | fn fullVarDecl(tree: Tree, info: Full.VarDecl.Ast) Full.VarDecl { | 1312 | pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm { |
| | 1313 | const data = tree.nodes.items(.data)[node]; |
| | 1314 | return tree.fullAsm(.{ |
| | 1315 | .asm_token = tree.nodes.items(.main_token)[node], |
| | 1316 | .template = data.lhs, |
| | 1317 | .items = &.{}, |
| | 1318 | .rparen = data.rhs, |
| | 1319 | }); |
| | 1320 | } |
| | 1321 | |
| | 1322 | pub fn asmFull(tree: Tree, node: Node.Index) full.Asm { |
| | 1323 | const data = tree.nodes.items(.data)[node]; |
| | 1324 | const extra = tree.extraData(data.rhs, Node.Asm); |
| | 1325 | return tree.fullAsm(.{ |
| | 1326 | .asm_token = tree.nodes.items(.main_token)[node], |
| | 1327 | .template = data.lhs, |
| | 1328 | .items = tree.extra_data[extra.items_start..extra.items_end], |
| | 1329 | .rparen = extra.rparen, |
| | 1330 | }); |
| | 1331 | } |
| | 1332 | |
| | 1333 | fn fullVarDecl(tree: Tree, info: full.VarDecl.Ast) full.VarDecl { |
| 1307 | const token_tags = tree.tokens.items(.tag); | 1334 | const token_tags = tree.tokens.items(.tag); |
| 1308 | var result: Full.VarDecl = .{ | 1335 | var result: full.VarDecl = .{ |
| 1309 | .ast = info, | 1336 | .ast = info, |
| 1310 | .visib_token = null, | 1337 | .visib_token = null, |
| 1311 | .extern_export_token = null, | 1338 | .extern_export_token = null, |
| ... | @@ -1328,9 +1355,9 @@ pub const Tree = struct { | ... | @@ -1328,9 +1355,9 @@ pub const Tree = struct { |
| 1328 | return result; | 1355 | return result; |
| 1329 | } | 1356 | } |
| 1330 | | 1357 | |
| 1331 | fn fullIf(tree: Tree, info: Full.If.Ast) Full.If { | 1358 | fn fullIf(tree: Tree, info: full.If.Ast) full.If { |
| 1332 | const token_tags = tree.tokens.items(.tag); | 1359 | const token_tags = tree.tokens.items(.tag); |
| 1333 | var result: Full.If = .{ | 1360 | var result: full.If = .{ |
| 1334 | .ast = info, | 1361 | .ast = info, |
| 1335 | .payload_token = null, | 1362 | .payload_token = null, |
| 1336 | .error_token = null, | 1363 | .error_token = null, |
| ... | @@ -1353,9 +1380,9 @@ pub const Tree = struct { | ... | @@ -1353,9 +1380,9 @@ pub const Tree = struct { |
| 1353 | return result; | 1380 | return result; |
| 1354 | } | 1381 | } |
| 1355 | | 1382 | |
| 1356 | fn fullContainerField(tree: Tree, info: Full.ContainerField.Ast) Full.ContainerField { | 1383 | fn fullContainerField(tree: Tree, info: full.ContainerField.Ast) full.ContainerField { |
| 1357 | const token_tags = tree.tokens.items(.tag); | 1384 | const token_tags = tree.tokens.items(.tag); |
| 1358 | var result: Full.ContainerField = .{ | 1385 | var result: full.ContainerField = .{ |
| 1359 | .ast = info, | 1386 | .ast = info, |
| 1360 | .comptime_token = null, | 1387 | .comptime_token = null, |
| 1361 | }; | 1388 | }; |
| ... | @@ -1367,27 +1394,27 @@ pub const Tree = struct { | ... | @@ -1367,27 +1394,27 @@ pub const Tree = struct { |
| 1367 | return result; | 1394 | return result; |
| 1368 | } | 1395 | } |
| 1369 | | 1396 | |
| 1370 | fn fullFnProto(tree: Tree, info: Full.FnProto.Ast) Full.FnProto { | 1397 | fn fullFnProto(tree: Tree, info: full.FnProto.Ast) full.FnProto { |
| 1371 | const token_tags = tree.tokens.items(.tag); | 1398 | const token_tags = tree.tokens.items(.tag); |
| 1372 | var result: Full.FnProto = .{ | 1399 | var result: full.FnProto = .{ |
| 1373 | .ast = info, | 1400 | .ast = info, |
| 1374 | }; | 1401 | }; |
| 1375 | return result; | 1402 | return result; |
| 1376 | } | 1403 | } |
| 1377 | | 1404 | |
| 1378 | fn fullStructInit(tree: Tree, info: Full.StructInit.Ast) Full.StructInit { | 1405 | fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit { |
| 1379 | const token_tags = tree.tokens.items(.tag); | 1406 | const token_tags = tree.tokens.items(.tag); |
| 1380 | var result: Full.StructInit = .{ | 1407 | var result: full.StructInit = .{ |
| 1381 | .ast = info, | 1408 | .ast = info, |
| 1382 | }; | 1409 | }; |
| 1383 | return result; | 1410 | return result; |
| 1384 | } | 1411 | } |
| 1385 | | 1412 | |
| 1386 | fn fullPtrType(tree: Tree, info: Full.PtrType.Ast) Full.PtrType { | 1413 | fn fullPtrType(tree: Tree, info: full.PtrType.Ast) full.PtrType { |
| 1387 | const token_tags = tree.tokens.items(.tag); | 1414 | const token_tags = tree.tokens.items(.tag); |
| 1388 | // TODO: looks like stage1 isn't quite smart enough to handle enum | 1415 | // TODO: looks like stage1 isn't quite smart enough to handle enum |
| 1389 | // literals in some places here | 1416 | // literals in some places here |
| 1390 | const Kind = Full.PtrType.Kind; | 1417 | const Kind = full.PtrType.Kind; |
| 1391 | const kind: Kind = switch (token_tags[info.main_token]) { | 1418 | const kind: Kind = switch (token_tags[info.main_token]) { |
| 1392 | .Asterisk => switch (token_tags[info.main_token + 1]) { | 1419 | .Asterisk => switch (token_tags[info.main_token + 1]) { |
| 1393 | .RBracket => .many, | 1420 | .RBracket => .many, |
| ... | @@ -1402,7 +1429,7 @@ pub const Tree = struct { | ... | @@ -1402,7 +1429,7 @@ pub const Tree = struct { |
| 1402 | }, | 1429 | }, |
| 1403 | else => unreachable, | 1430 | else => unreachable, |
| 1404 | }; | 1431 | }; |
| 1405 | var result: Full.PtrType = .{ | 1432 | var result: full.PtrType = .{ |
| 1406 | .kind = kind, | 1433 | .kind = kind, |
| 1407 | .allowzero_token = null, | 1434 | .allowzero_token = null, |
| 1408 | .const_token = null, | 1435 | .const_token = null, |
| ... | @@ -1441,9 +1468,9 @@ pub const Tree = struct { | ... | @@ -1441,9 +1468,9 @@ pub const Tree = struct { |
| 1441 | return result; | 1468 | return result; |
| 1442 | } | 1469 | } |
| 1443 | | 1470 | |
| 1444 | fn fullContainerDecl(tree: Tree, info: Full.ContainerDecl.Ast) Full.ContainerDecl { | 1471 | fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Ast) full.ContainerDecl { |
| 1445 | const token_tags = tree.tokens.items(.tag); | 1472 | const token_tags = tree.tokens.items(.tag); |
| 1446 | var result: Full.ContainerDecl = .{ | 1473 | var result: full.ContainerDecl = .{ |
| 1447 | .ast = info, | 1474 | .ast = info, |
| 1448 | .layout_token = null, | 1475 | .layout_token = null, |
| 1449 | }; | 1476 | }; |
| ... | @@ -1454,9 +1481,9 @@ pub const Tree = struct { | ... | @@ -1454,9 +1481,9 @@ pub const Tree = struct { |
| 1454 | return result; | 1481 | return result; |
| 1455 | } | 1482 | } |
| 1456 | | 1483 | |
| 1457 | fn fullSwitchCase(tree: Tree, info: Full.SwitchCase.Ast) Full.SwitchCase { | 1484 | fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Ast) full.SwitchCase { |
| 1458 | const token_tags = tree.tokens.items(.tag); | 1485 | const token_tags = tree.tokens.items(.tag); |
| 1459 | var result: Full.SwitchCase = .{ | 1486 | var result: full.SwitchCase = .{ |
| 1460 | .ast = info, | 1487 | .ast = info, |
| 1461 | .payload_token = null, | 1488 | .payload_token = null, |
| 1462 | }; | 1489 | }; |
| ... | @@ -1465,10 +1492,67 @@ pub const Tree = struct { | ... | @@ -1465,10 +1492,67 @@ pub const Tree = struct { |
| 1465 | } | 1492 | } |
| 1466 | return result; | 1493 | return result; |
| 1467 | } | 1494 | } |
| | 1495 | |
| | 1496 | fn fullAsm(tree: Tree, info: full.Asm.Ast) full.Asm { |
| | 1497 | const token_tags = tree.tokens.items(.tag); |
| | 1498 | const node_tags = tree.nodes.items(.tag); |
| | 1499 | var result: full.Asm = .{ |
| | 1500 | .ast = info, |
| | 1501 | .volatile_token = null, |
| | 1502 | .inputs = &.{}, |
| | 1503 | .outputs = &.{}, |
| | 1504 | .first_clobber = null, |
| | 1505 | }; |
| | 1506 | if (token_tags[info.asm_token + 1] == .Keyword_volatile) { |
| | 1507 | result.volatile_token = info.asm_token + 1; |
| | 1508 | } |
| | 1509 | const outputs_end: usize = for (info.items) |item, i| { |
| | 1510 | switch (node_tags[item]) { |
| | 1511 | .AsmOutput => continue, |
| | 1512 | else => break i, |
| | 1513 | } |
| | 1514 | } else info.items.len; |
| | 1515 | |
| | 1516 | result.outputs = info.items[0..outputs_end]; |
| | 1517 | result.inputs = info.items[outputs_end..]; |
| | 1518 | |
| | 1519 | if (info.items.len == 0) { |
| | 1520 | // asm ("foo" ::: "a", "b"); |
| | 1521 | const template_token = tree.lastToken(info.template); |
| | 1522 | if (token_tags[template_token + 1] == .Colon and |
| | 1523 | token_tags[template_token + 2] == .Colon and |
| | 1524 | token_tags[template_token + 3] == .Colon and |
| | 1525 | token_tags[template_token + 4] == .StringLiteral) |
| | 1526 | { |
| | 1527 | result.first_clobber = template_token + 4; |
| | 1528 | } |
| | 1529 | } else if (result.inputs.len != 0) { |
| | 1530 | // asm ("foo" :: [_] "" (y) : "a", "b"); |
| | 1531 | const last_input = result.inputs[result.inputs.len - 1]; |
| | 1532 | const rparen = tree.lastToken(last_input); |
| | 1533 | if (token_tags[rparen + 1] == .Colon and |
| | 1534 | token_tags[rparen + 2] == .StringLiteral) |
| | 1535 | { |
| | 1536 | result.first_clobber = rparen + 2; |
| | 1537 | } |
| | 1538 | } else { |
| | 1539 | // asm ("foo" : [_] "" (x) :: "a", "b"); |
| | 1540 | const last_output = result.outputs[result.outputs.len - 1]; |
| | 1541 | const rparen = tree.lastToken(last_output); |
| | 1542 | if (token_tags[rparen + 1] == .Colon and |
| | 1543 | token_tags[rparen + 2] == .Colon and |
| | 1544 | token_tags[rparen + 3] == .StringLiteral) |
| | 1545 | { |
| | 1546 | result.first_clobber = rparen + 3; |
| | 1547 | } |
| | 1548 | } |
| | 1549 | |
| | 1550 | return result; |
| | 1551 | } |
| 1468 | }; | 1552 | }; |
| 1469 | | 1553 | |
| 1470 | /// Fully assembled AST node information. | 1554 | /// Fully assembled AST node information. |
| 1471 | pub const Full = struct { | 1555 | pub const full = struct { |
| 1472 | pub const VarDecl = struct { | 1556 | pub const VarDecl = struct { |
| 1473 | visib_token: ?TokenIndex, | 1557 | visib_token: ?TokenIndex, |
| 1474 | extern_export_token: ?TokenIndex, | 1558 | extern_export_token: ?TokenIndex, |
| ... | @@ -1624,6 +1708,21 @@ pub const Full = struct { | ... | @@ -1624,6 +1708,21 @@ pub const Full = struct { |
| 1624 | target_expr: Node.Index, | 1708 | target_expr: Node.Index, |
| 1625 | }; | 1709 | }; |
| 1626 | }; | 1710 | }; |
| | 1711 | |
| | 1712 | pub const Asm = struct { |
| | 1713 | ast: Ast, |
| | 1714 | volatile_token: ?TokenIndex, |
| | 1715 | first_clobber: ?TokenIndex, |
| | 1716 | outputs: []const Node.Index, |
| | 1717 | inputs: []const Node.Index, |
| | 1718 | |
| | 1719 | pub const Ast = struct { |
| | 1720 | asm_token: TokenIndex, |
| | 1721 | template: Node.Index, |
| | 1722 | items: []const Node.Index, |
| | 1723 | rparen: TokenIndex, |
| | 1724 | }; |
| | 1725 | }; |
| 1627 | }; | 1726 | }; |
| 1628 | | 1727 | |
| 1629 | pub const Error = union(enum) { | 1728 | pub const Error = union(enum) { |
| ... | @@ -2234,15 +2333,15 @@ pub const Node = struct { | ... | @@ -2234,15 +2333,15 @@ pub const Node = struct { |
| 2234 | Block, | 2333 | Block, |
| 2235 | /// Same as BlockTwo but there is known to be a semicolon before the rbrace. | 2334 | /// Same as BlockTwo but there is known to be a semicolon before the rbrace. |
| 2236 | BlockSemicolon, | 2335 | BlockSemicolon, |
| 2237 | /// `asm(lhs)`. rhs unused. | 2336 | /// `asm(lhs)`. rhs is the token index of the rparen. |
| 2238 | AsmSimple, | 2337 | AsmSimple, |
| 2239 | /// `asm(lhs, a)`. `sub_range_list[rhs]`. | 2338 | /// `asm(lhs, a)`. `Asm[rhs]`. |
| 2240 | Asm, | 2339 | Asm, |
| 2241 | /// `[a] "b" (c)`. lhs is string literal token index, rhs is 0. | 2340 | /// `[a] "b" (c)`. lhs is 0, rhs is token index of the rparen. |
| 2242 | /// `[a] "b" (-> rhs)`. lhs is the string literal token index, rhs is type expr. | 2341 | /// `[a] "b" (-> lhs)`. rhs is token index of the rparen. |
| 2243 | /// main_token is `a`. | 2342 | /// main_token is `a`. |
| 2244 | AsmOutput, | 2343 | AsmOutput, |
| 2245 | /// `[a] "b" (rhs)`. lhs is string literal token index. | 2344 | /// `[a] "b" (lhs)`. rhs is token index of the rparen. |
| 2246 | /// main_token is `a`. | 2345 | /// main_token is `a`. |
| 2247 | AsmInput, | 2346 | AsmInput, |
| 2248 | /// `error.a`. lhs is token index of `.`. rhs is token index of `a`. | 2347 | /// `error.a`. lhs is token index of `.`. rhs is token index of `a`. |
| ... | @@ -2355,4 +2454,11 @@ pub const Node = struct { | ... | @@ -2355,4 +2454,11 @@ pub const Node = struct { |
| 2355 | /// Populated if callconv(A) is present. | 2454 | /// Populated if callconv(A) is present. |
| 2356 | callconv_expr: Index, | 2455 | callconv_expr: Index, |
| 2357 | }; | 2456 | }; |
| | 2457 | |
| | 2458 | pub const Asm = struct { |
| | 2459 | items_start: Index, |
| | 2460 | items_end: Index, |
| | 2461 | /// Needed to make lastToken() work. |
| | 2462 | rparen: TokenIndex, |
| | 2463 | }; |
| 2358 | }; | 2464 | }; |