| ... | @@ -90,7 +90,9 @@ pub const Type = extern union { | ... | @@ -90,7 +90,9 @@ pub const Type = extern union { |
| 90 | | 90 | |
| 91 | .anyframe_T, .@"anyframe" => return .AnyFrame, | 91 | .anyframe_T, .@"anyframe" => return .AnyFrame, |
| 92 | | 92 | |
| 93 | .empty_struct => return .Struct, | 93 | .@"struct", .empty_struct => return .Struct, |
| | 94 | .@"enum" => return .Enum, |
| | 95 | .@"union" => return .Union, |
| 94 | } | 96 | } |
| 95 | } | 97 | } |
| 96 | | 98 | |
| ... | @@ -442,6 +444,11 @@ pub const Type = extern union { | ... | @@ -442,6 +444,11 @@ pub const Type = extern union { |
| 442 | .error_set => return self.copyPayloadShallow(allocator, Payload.ErrorSet), | 444 | .error_set => return self.copyPayloadShallow(allocator, Payload.ErrorSet), |
| 443 | .error_set_single => return self.copyPayloadShallow(allocator, Payload.ErrorSetSingle), | 445 | .error_set_single => return self.copyPayloadShallow(allocator, Payload.ErrorSetSingle), |
| 444 | .empty_struct => return self.copyPayloadShallow(allocator, Payload.EmptyStruct), | 446 | .empty_struct => return self.copyPayloadShallow(allocator, Payload.EmptyStruct), |
| | 447 | |
| | 448 | // memory managed by the decl |
| | 449 | .@"enum" => return self, |
| | 450 | .@"struct" => return self, |
| | 451 | .@"union" => return self, |
| 445 | } | 452 | } |
| 446 | } | 453 | } |
| 447 | | 454 | |
| ... | @@ -673,6 +680,10 @@ pub const Type = extern union { | ... | @@ -673,6 +680,10 @@ pub const Type = extern union { |
| 673 | const payload = @fieldParentPtr(Payload.ErrorSetSingle, "base", ty.ptr_otherwise); | 680 | const payload = @fieldParentPtr(Payload.ErrorSetSingle, "base", ty.ptr_otherwise); |
| 674 | return out_stream.print("error{{{}}}", .{payload.name}); | 681 | return out_stream.print("error{{{}}}", .{payload.name}); |
| 675 | }, | 682 | }, |
| | 683 | // TODO improve |
| | 684 | .@"enum" => return out_stream.writeAll("enum {}"), |
| | 685 | .@"struct" => return out_stream.writeAll("struct {}"), |
| | 686 | .@"union" => return out_stream.writeAll("union {}"), |
| 676 | } | 687 | } |
| 677 | unreachable; | 688 | unreachable; |
| 678 | } | 689 | } |
| ... | @@ -784,6 +795,10 @@ pub const Type = extern union { | ... | @@ -784,6 +795,10 @@ pub const Type = extern union { |
| 784 | return payload.error_set.hasCodeGenBits() or payload.payload.hasCodeGenBits(); | 795 | return payload.error_set.hasCodeGenBits() or payload.payload.hasCodeGenBits(); |
| 785 | }, | 796 | }, |
| 786 | | 797 | |
| | 798 | .@"enum" => @panic("TODO"), |
| | 799 | .@"struct" => @panic("TODO"), |
| | 800 | .@"union" => @panic("TODO"), |
| | 801 | |
| 787 | .c_void, | 802 | .c_void, |
| 788 | .void, | 803 | .void, |
| 789 | .type, | 804 | .type, |
| ... | @@ -908,6 +923,10 @@ pub const Type = extern union { | ... | @@ -908,6 +923,10 @@ pub const Type = extern union { |
| 908 | @panic("TODO abiAlignment error union"); | 923 | @panic("TODO abiAlignment error union"); |
| 909 | }, | 924 | }, |
| 910 | | 925 | |
| | 926 | .@"enum" => self.cast(Payload.Enum).?.abiAlignment(), |
| | 927 | .@"struct" => @panic("TODO"), |
| | 928 | .@"union" => @panic("TODO"), |
| | 929 | |
| 911 | .c_void, | 930 | .c_void, |
| 912 | .void, | 931 | .void, |
| 913 | .type, | 932 | .type, |
| ... | @@ -1050,6 +1069,10 @@ pub const Type = extern union { | ... | @@ -1050,6 +1069,10 @@ pub const Type = extern union { |
| 1050 | } | 1069 | } |
| 1051 | @panic("TODO abiSize error union"); | 1070 | @panic("TODO abiSize error union"); |
| 1052 | }, | 1071 | }, |
| | 1072 | |
| | 1073 | .@"enum" => @panic("TODO"), |
| | 1074 | .@"struct" => @panic("TODO"), |
| | 1075 | .@"union" => @panic("TODO"), |
| 1053 | }; | 1076 | }; |
| 1054 | } | 1077 | } |
| 1055 | | 1078 | |
| ... | @@ -1117,6 +1140,9 @@ pub const Type = extern union { | ... | @@ -1117,6 +1140,9 @@ pub const Type = extern union { |
| 1117 | .error_set, | 1140 | .error_set, |
| 1118 | .error_set_single, | 1141 | .error_set_single, |
| 1119 | .empty_struct, | 1142 | .empty_struct, |
| | 1143 | .@"enum", |
| | 1144 | .@"struct", |
| | 1145 | .@"union", |
| 1120 | => false, | 1146 | => false, |
| 1121 | | 1147 | |
| 1122 | .single_const_pointer, | 1148 | .single_const_pointer, |
| ... | @@ -1192,6 +1218,9 @@ pub const Type = extern union { | ... | @@ -1192,6 +1218,9 @@ pub const Type = extern union { |
| 1192 | .error_set, | 1218 | .error_set, |
| 1193 | .error_set_single, | 1219 | .error_set_single, |
| 1194 | .empty_struct, | 1220 | .empty_struct, |
| | 1221 | .@"enum", |
| | 1222 | .@"struct", |
| | 1223 | .@"union", |
| 1195 | => false, | 1224 | => false, |
| 1196 | | 1225 | |
| 1197 | .const_slice, | 1226 | .const_slice, |
| ... | @@ -1264,6 +1293,9 @@ pub const Type = extern union { | ... | @@ -1264,6 +1293,9 @@ pub const Type = extern union { |
| 1264 | .error_set, | 1293 | .error_set, |
| 1265 | .error_set_single, | 1294 | .error_set_single, |
| 1266 | .empty_struct, | 1295 | .empty_struct, |
| | 1296 | .@"enum", |
| | 1297 | .@"struct", |
| | 1298 | .@"union", |
| 1267 | => false, | 1299 | => false, |
| 1268 | | 1300 | |
| 1269 | .single_const_pointer, | 1301 | .single_const_pointer, |
| ... | @@ -1345,6 +1377,9 @@ pub const Type = extern union { | ... | @@ -1345,6 +1377,9 @@ pub const Type = extern union { |
| 1345 | .error_set, | 1377 | .error_set, |
| 1346 | .error_set_single, | 1378 | .error_set_single, |
| 1347 | .empty_struct, | 1379 | .empty_struct, |
| | 1380 | .@"enum", |
| | 1381 | .@"struct", |
| | 1382 | .@"union", |
| 1348 | => false, | 1383 | => false, |
| 1349 | | 1384 | |
| 1350 | .pointer => { | 1385 | .pointer => { |
| ... | @@ -1421,6 +1456,9 @@ pub const Type = extern union { | ... | @@ -1421,6 +1456,9 @@ pub const Type = extern union { |
| 1421 | .error_set, | 1456 | .error_set, |
| 1422 | .error_set_single, | 1457 | .error_set_single, |
| 1423 | .empty_struct, | 1458 | .empty_struct, |
| | 1459 | .@"enum", |
| | 1460 | .@"struct", |
| | 1461 | .@"union", |
| 1424 | => false, | 1462 | => false, |
| 1425 | | 1463 | |
| 1426 | .pointer => { | 1464 | .pointer => { |
| ... | @@ -1539,6 +1577,9 @@ pub const Type = extern union { | ... | @@ -1539,6 +1577,9 @@ pub const Type = extern union { |
| 1539 | .error_set, | 1577 | .error_set, |
| 1540 | .error_set_single, | 1578 | .error_set_single, |
| 1541 | .empty_struct, | 1579 | .empty_struct, |
| | 1580 | .@"enum", |
| | 1581 | .@"struct", |
| | 1582 | .@"union", |
| 1542 | => unreachable, | 1583 | => unreachable, |
| 1543 | | 1584 | |
| 1544 | .array => self.cast(Payload.Array).?.elem_type, | 1585 | .array => self.cast(Payload.Array).?.elem_type, |
| ... | @@ -1667,6 +1708,9 @@ pub const Type = extern union { | ... | @@ -1667,6 +1708,9 @@ pub const Type = extern union { |
| 1667 | .error_set, | 1708 | .error_set, |
| 1668 | .error_set_single, | 1709 | .error_set_single, |
| 1669 | .empty_struct, | 1710 | .empty_struct, |
| | 1711 | .@"enum", |
| | 1712 | .@"struct", |
| | 1713 | .@"union", |
| 1670 | => unreachable, | 1714 | => unreachable, |
| 1671 | | 1715 | |
| 1672 | .array => self.cast(Payload.Array).?.len, | 1716 | .array => self.cast(Payload.Array).?.len, |
| ... | @@ -1733,6 +1777,9 @@ pub const Type = extern union { | ... | @@ -1733,6 +1777,9 @@ pub const Type = extern union { |
| 1733 | .error_set, | 1777 | .error_set, |
| 1734 | .error_set_single, | 1778 | .error_set_single, |
| 1735 | .empty_struct, | 1779 | .empty_struct, |
| | 1780 | .@"enum", |
| | 1781 | .@"struct", |
| | 1782 | .@"union", |
| 1736 | => unreachable, | 1783 | => unreachable, |
| 1737 | | 1784 | |
| 1738 | .single_const_pointer, | 1785 | .single_const_pointer, |
| ... | @@ -1816,6 +1863,9 @@ pub const Type = extern union { | ... | @@ -1816,6 +1863,9 @@ pub const Type = extern union { |
| 1816 | .error_set, | 1863 | .error_set, |
| 1817 | .error_set_single, | 1864 | .error_set_single, |
| 1818 | .empty_struct, | 1865 | .empty_struct, |
| | 1866 | .@"enum", |
| | 1867 | .@"struct", |
| | 1868 | .@"union", |
| 1819 | => false, | 1869 | => false, |
| 1820 | | 1870 | |
| 1821 | .int_signed, | 1871 | .int_signed, |
| ... | @@ -1891,6 +1941,9 @@ pub const Type = extern union { | ... | @@ -1891,6 +1941,9 @@ pub const Type = extern union { |
| 1891 | .error_set, | 1941 | .error_set, |
| 1892 | .error_set_single, | 1942 | .error_set_single, |
| 1893 | .empty_struct, | 1943 | .empty_struct, |
| | 1944 | .@"enum", |
| | 1945 | .@"struct", |
| | 1946 | .@"union", |
| 1894 | => false, | 1947 | => false, |
| 1895 | | 1948 | |
| 1896 | .int_unsigned, | 1949 | .int_unsigned, |
| ... | @@ -1956,6 +2009,9 @@ pub const Type = extern union { | ... | @@ -1956,6 +2009,9 @@ pub const Type = extern union { |
| 1956 | .error_set, | 2009 | .error_set, |
| 1957 | .error_set_single, | 2010 | .error_set_single, |
| 1958 | .empty_struct, | 2011 | .empty_struct, |
| | 2012 | .@"enum", |
| | 2013 | .@"struct", |
| | 2014 | .@"union", |
| 1959 | => unreachable, | 2015 | => unreachable, |
| 1960 | | 2016 | |
| 1961 | .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits }, | 2017 | .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits }, |
| ... | @@ -2039,6 +2095,9 @@ pub const Type = extern union { | ... | @@ -2039,6 +2095,9 @@ pub const Type = extern union { |
| 2039 | .error_set, | 2095 | .error_set, |
| 2040 | .error_set_single, | 2096 | .error_set_single, |
| 2041 | .empty_struct, | 2097 | .empty_struct, |
| | 2098 | .@"enum", |
| | 2099 | .@"struct", |
| | 2100 | .@"union", |
| 2042 | => false, | 2101 | => false, |
| 2043 | | 2102 | |
| 2044 | .usize, | 2103 | .usize, |
| ... | @@ -2151,6 +2210,9 @@ pub const Type = extern union { | ... | @@ -2151,6 +2210,9 @@ pub const Type = extern union { |
| 2151 | .error_set, | 2210 | .error_set, |
| 2152 | .error_set_single, | 2211 | .error_set_single, |
| 2153 | .empty_struct, | 2212 | .empty_struct, |
| | 2213 | .@"enum", |
| | 2214 | .@"struct", |
| | 2215 | .@"union", |
| 2154 | => unreachable, | 2216 | => unreachable, |
| 2155 | }; | 2217 | }; |
| 2156 | } | 2218 | } |
| ... | @@ -2229,6 +2291,9 @@ pub const Type = extern union { | ... | @@ -2229,6 +2291,9 @@ pub const Type = extern union { |
| 2229 | .error_set, | 2291 | .error_set, |
| 2230 | .error_set_single, | 2292 | .error_set_single, |
| 2231 | .empty_struct, | 2293 | .empty_struct, |
| | 2294 | .@"enum", |
| | 2295 | .@"struct", |
| | 2296 | .@"union", |
| 2232 | => unreachable, | 2297 | => unreachable, |
| 2233 | } | 2298 | } |
| 2234 | } | 2299 | } |
| ... | @@ -2306,6 +2371,9 @@ pub const Type = extern union { | ... | @@ -2306,6 +2371,9 @@ pub const Type = extern union { |
| 2306 | .error_set, | 2371 | .error_set, |
| 2307 | .error_set_single, | 2372 | .error_set_single, |
| 2308 | .empty_struct, | 2373 | .empty_struct, |
| | 2374 | .@"enum", |
| | 2375 | .@"struct", |
| | 2376 | .@"union", |
| 2309 | => unreachable, | 2377 | => unreachable, |
| 2310 | } | 2378 | } |
| 2311 | } | 2379 | } |
| ... | @@ -2383,6 +2451,9 @@ pub const Type = extern union { | ... | @@ -2383,6 +2451,9 @@ pub const Type = extern union { |
| 2383 | .error_set, | 2451 | .error_set, |
| 2384 | .error_set_single, | 2452 | .error_set_single, |
| 2385 | .empty_struct, | 2453 | .empty_struct, |
| | 2454 | .@"enum", |
| | 2455 | .@"struct", |
| | 2456 | .@"union", |
| 2386 | => unreachable, | 2457 | => unreachable, |
| 2387 | }; | 2458 | }; |
| 2388 | } | 2459 | } |
| ... | @@ -2457,6 +2528,9 @@ pub const Type = extern union { | ... | @@ -2457,6 +2528,9 @@ pub const Type = extern union { |
| 2457 | .error_set, | 2528 | .error_set, |
| 2458 | .error_set_single, | 2529 | .error_set_single, |
| 2459 | .empty_struct, | 2530 | .empty_struct, |
| | 2531 | .@"enum", |
| | 2532 | .@"struct", |
| | 2533 | .@"union", |
| 2460 | => unreachable, | 2534 | => unreachable, |
| 2461 | }; | 2535 | }; |
| 2462 | } | 2536 | } |
| ... | @@ -2531,6 +2605,9 @@ pub const Type = extern union { | ... | @@ -2531,6 +2605,9 @@ pub const Type = extern union { |
| 2531 | .error_set, | 2605 | .error_set, |
| 2532 | .error_set_single, | 2606 | .error_set_single, |
| 2533 | .empty_struct, | 2607 | .empty_struct, |
| | 2608 | .@"enum", |
| | 2609 | .@"struct", |
| | 2610 | .@"union", |
| 2534 | => unreachable, | 2611 | => unreachable, |
| 2535 | }; | 2612 | }; |
| 2536 | } | 2613 | } |
| ... | @@ -2605,6 +2682,9 @@ pub const Type = extern union { | ... | @@ -2605,6 +2682,9 @@ pub const Type = extern union { |
| 2605 | .error_set, | 2682 | .error_set, |
| 2606 | .error_set_single, | 2683 | .error_set_single, |
| 2607 | .empty_struct, | 2684 | .empty_struct, |
| | 2685 | .@"enum", |
| | 2686 | .@"struct", |
| | 2687 | .@"union", |
| 2608 | => false, | 2688 | => false, |
| 2609 | }; | 2689 | }; |
| 2610 | } | 2690 | } |
| ... | @@ -2664,6 +2744,10 @@ pub const Type = extern union { | ... | @@ -2664,6 +2744,10 @@ pub const Type = extern union { |
| 2664 | .error_set_single, | 2744 | .error_set_single, |
| 2665 | => return null, | 2745 | => return null, |
| 2666 | | 2746 | |
| | 2747 | .@"enum" => @panic("TODO onePossibleValue enum"), |
| | 2748 | .@"struct" => @panic("TODO onePossibleValue struct"), |
| | 2749 | .@"union" => @panic("TODO onePossibleValue union"), |
| | 2750 | |
| 2667 | .empty_struct => return Value.initTag(.empty_struct_value), | 2751 | .empty_struct => return Value.initTag(.empty_struct_value), |
| 2668 | .void => return Value.initTag(.void_value), | 2752 | .void => return Value.initTag(.void_value), |
| 2669 | .noreturn => return Value.initTag(.unreachable_value), | 2753 | .noreturn => return Value.initTag(.unreachable_value), |
| ... | @@ -2773,6 +2857,9 @@ pub const Type = extern union { | ... | @@ -2773,6 +2857,9 @@ pub const Type = extern union { |
| 2773 | .error_set, | 2857 | .error_set, |
| 2774 | .error_set_single, | 2858 | .error_set_single, |
| 2775 | .empty_struct, | 2859 | .empty_struct, |
| | 2860 | .@"enum", |
| | 2861 | .@"struct", |
| | 2862 | .@"union", |
| 2776 | => return false, | 2863 | => return false, |
| 2777 | | 2864 | |
| 2778 | .c_const_pointer, | 2865 | .c_const_pointer, |
| ... | @@ -2861,6 +2948,9 @@ pub const Type = extern union { | ... | @@ -2861,6 +2948,9 @@ pub const Type = extern union { |
| 2861 | => unreachable, | 2948 | => unreachable, |
| 2862 | | 2949 | |
| 2863 | .empty_struct => self.cast(Type.Payload.EmptyStruct).?.scope, | 2950 | .empty_struct => self.cast(Type.Payload.EmptyStruct).?.scope, |
| | 2951 | .@"enum" => &self.cast(Type.Payload.Enum).?.scope, |
| | 2952 | .@"struct" => &self.cast(Type.Payload.Struct).?.scope, |
| | 2953 | .@"union" => &self.cast(Type.Payload.Union).?.scope, |
| 2864 | }; | 2954 | }; |
| 2865 | } | 2955 | } |
| 2866 | | 2956 | |
| ... | @@ -3012,6 +3102,9 @@ pub const Type = extern union { | ... | @@ -3012,6 +3102,9 @@ pub const Type = extern union { |
| 3012 | error_set, | 3102 | error_set, |
| 3013 | error_set_single, | 3103 | error_set_single, |
| 3014 | empty_struct, | 3104 | empty_struct, |
| | 3105 | @"enum", |
| | 3106 | @"struct", |
| | 3107 | @"union", |
| 3015 | | 3108 | |
| 3016 | pub const last_no_payload_tag = Tag.const_slice_u8; | 3109 | pub const last_no_payload_tag = Tag.const_slice_u8; |
| 3017 | pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; | 3110 | pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; |
| ... | @@ -3127,6 +3220,10 @@ pub const Type = extern union { | ... | @@ -3127,6 +3220,10 @@ pub const Type = extern union { |
| 3127 | | 3220 | |
| 3128 | scope: *Module.Scope.Container, | 3221 | scope: *Module.Scope.Container, |
| 3129 | }; | 3222 | }; |
| | 3223 | |
| | 3224 | pub const Enum = @import("value/Enum.zig"); |
| | 3225 | pub const Struct = @import("value/Struct.zig"); |
| | 3226 | pub const Union = @import("value/Union.zig"); |
| 3130 | }; | 3227 | }; |
| 3131 | }; | 3228 | }; |
| 3132 | | 3229 | |