| author | |
| committer | |
| log | e0b01bd4a98e2605f197a04f84e0c281ccc90f81 |
| tree | 0bac6d2e6d24d57e0d6312dcf637e2a7915288be |
| parent | 31d8efc6b32a6b60b7ab292ac50e0f6c02bc140e |
| signature | Commit is signed but in an unrecognized format. |
5 files changed, 98 insertions(+), 4 deletions(-)
src-self-hosted/astgen.zig+9-1| ... | @@ -130,6 +130,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr | ... | @@ -130,6 +130,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr |
| 130 | .GroupedExpression => return expr(mod, scope, rl, node.castTag(.GroupedExpression).?.expr), | 130 | .GroupedExpression => return expr(mod, scope, rl, node.castTag(.GroupedExpression).?.expr), |
| 131 | .ArrayType => return rlWrap(mod, scope, rl, try arrayType(mod, scope, node.castTag(.ArrayType).?)), | 131 | .ArrayType => return rlWrap(mod, scope, rl, try arrayType(mod, scope, node.castTag(.ArrayType).?)), |
| 132 | .ArrayTypeSentinel => return rlWrap(mod, scope, rl, try arrayTypeSentinel(mod, scope, node.castTag(.ArrayTypeSentinel).?)), | 132 | .ArrayTypeSentinel => return rlWrap(mod, scope, rl, try arrayTypeSentinel(mod, scope, node.castTag(.ArrayTypeSentinel).?)), |
| 133 | .EnumLiteral => return rlWrap(mod, scope, rl, try enumLiteral(mod, scope, node.castTag(.EnumLiteral).?)), | ||
| 133 | 134 | ||
| 134 | .Defer => return mod.failNode(scope, node, "TODO implement astgen.expr for .Defer", .{}), | 135 | .Defer => return mod.failNode(scope, node, "TODO implement astgen.expr for .Defer", .{}), |
| 135 | .Catch => return mod.failNode(scope, node, "TODO implement astgen.expr for .Catch", .{}), | 136 | .Catch => return mod.failNode(scope, node, "TODO implement astgen.expr for .Catch", .{}), |
| ... | @@ -158,7 +159,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr | ... | @@ -158,7 +159,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr |
| 158 | .ErrorType => return mod.failNode(scope, node, "TODO implement astgen.expr for .ErrorType", .{}), | 159 | .ErrorType => return mod.failNode(scope, node, "TODO implement astgen.expr for .ErrorType", .{}), |
| 159 | .FnProto => return mod.failNode(scope, node, "TODO implement astgen.expr for .FnProto", .{}), | 160 | .FnProto => return mod.failNode(scope, node, "TODO implement astgen.expr for .FnProto", .{}), |
| 160 | .AnyFrameType => return mod.failNode(scope, node, "TODO implement astgen.expr for .AnyFrameType", .{}), | 161 | .AnyFrameType => return mod.failNode(scope, node, "TODO implement astgen.expr for .AnyFrameType", .{}), |
| 161 | .EnumLiteral => return mod.failNode(scope, node, "TODO implement astgen.expr for .EnumLiteral", .{}), | ||
| 162 | .MultilineStringLiteral => return mod.failNode(scope, node, "TODO implement astgen.expr for .MultilineStringLiteral", .{}), | 162 | .MultilineStringLiteral => return mod.failNode(scope, node, "TODO implement astgen.expr for .MultilineStringLiteral", .{}), |
| 163 | .CharLiteral => return mod.failNode(scope, node, "TODO implement astgen.expr for .CharLiteral", .{}), | 163 | .CharLiteral => return mod.failNode(scope, node, "TODO implement astgen.expr for .CharLiteral", .{}), |
| 164 | .ErrorSetDecl => return mod.failNode(scope, node, "TODO implement astgen.expr for .ErrorSetDecl", .{}), | 164 | .ErrorSetDecl => return mod.failNode(scope, node, "TODO implement astgen.expr for .ErrorSetDecl", .{}), |
| ... | @@ -527,6 +527,14 @@ fn arrayTypeSentinel(mod: *Module, scope: *Scope, node: *ast.Node.ArrayTypeSenti | ... | @@ -527,6 +527,14 @@ fn arrayTypeSentinel(mod: *Module, scope: *Scope, node: *ast.Node.ArrayTypeSenti |
| 527 | }, .{}); | 527 | }, .{}); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | fn enumLiteral(mod: *Module, scope: *Scope, node: *ast.Node.EnumLiteral) !*zir.Inst { | ||
| 531 | const tree = scope.tree(); | ||
| 532 | const src = tree.token_locs[node.name].start; | ||
| 533 | const name = try identifierTokenString(mod, scope, node.name); | ||
| 534 | |||
| 535 | return addZIRInst(mod, scope, src, zir.Inst.EnumLiteral, .{ .name = name }, .{}); | ||
| 536 | } | ||
| 537 | |||
| 530 | fn unwrapOptional(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node.SimpleSuffixOp) InnerError!*zir.Inst { | 538 | fn unwrapOptional(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node.SimpleSuffixOp) InnerError!*zir.Inst { |
| 531 | const tree = scope.tree(); | 539 | const tree = scope.tree(); |
| 532 | const src = tree.token_locs[node.rtoken].start; | 540 | const src = tree.token_locs[node.rtoken].start; |
src-self-hosted/type.zig+29-1| ... | @@ -75,6 +75,7 @@ pub const Type = extern union { | ... | @@ -75,6 +75,7 @@ pub const Type = extern union { |
| 75 | .optional_single_const_pointer, | 75 | .optional_single_const_pointer, |
| 76 | .optional_single_mut_pointer, | 76 | .optional_single_mut_pointer, |
| 77 | => return .Optional, | 77 | => return .Optional, |
| 78 | .enum_literal => return .EnumLiteral, | ||
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | 81 | ||
| ... | @@ -127,6 +128,7 @@ pub const Type = extern union { | ... | @@ -127,6 +128,7 @@ pub const Type = extern union { |
| 127 | if (zig_tag_a != zig_tag_b) | 128 | if (zig_tag_a != zig_tag_b) |
| 128 | return false; | 129 | return false; |
| 129 | switch (zig_tag_a) { | 130 | switch (zig_tag_a) { |
| 131 | .EnumLiteral => return true, | ||
| 130 | .Type => return true, | 132 | .Type => return true, |
| 131 | .Void => return true, | 133 | .Void => return true, |
| 132 | .Bool => return true, | 134 | .Bool => return true, |
| ... | @@ -211,7 +213,6 @@ pub const Type = extern union { | ... | @@ -211,7 +213,6 @@ pub const Type = extern union { |
| 211 | .Frame, | 213 | .Frame, |
| 212 | .AnyFrame, | 214 | .AnyFrame, |
| 213 | .Vector, | 215 | .Vector, |
| 214 | .EnumLiteral, | ||
| 215 | => std.debug.panic("TODO implement Type equality comparison of {} and {}", .{ a, b }), | 216 | => std.debug.panic("TODO implement Type equality comparison of {} and {}", .{ a, b }), |
| 216 | } | 217 | } |
| 217 | } | 218 | } |
| ... | @@ -327,6 +328,7 @@ pub const Type = extern union { | ... | @@ -327,6 +328,7 @@ pub const Type = extern union { |
| 327 | .fn_ccc_void_no_args, | 328 | .fn_ccc_void_no_args, |
| 328 | .single_const_pointer_to_comptime_int, | 329 | .single_const_pointer_to_comptime_int, |
| 329 | .const_slice_u8, | 330 | .const_slice_u8, |
| 331 | .enum_literal, | ||
| 330 | => unreachable, | 332 | => unreachable, |
| 331 | 333 | ||
| 332 | .array_u8_sentinel_0 => return self.copyPayloadShallow(allocator, Payload.Array_u8_Sentinel0), | 334 | .array_u8_sentinel_0 => return self.copyPayloadShallow(allocator, Payload.Array_u8_Sentinel0), |
| ... | @@ -437,6 +439,7 @@ pub const Type = extern union { | ... | @@ -437,6 +439,7 @@ pub const Type = extern union { |
| 437 | .noreturn, | 439 | .noreturn, |
| 438 | => return out_stream.writeAll(@tagName(t)), | 440 | => return out_stream.writeAll(@tagName(t)), |
| 439 | 441 | ||
| 442 | .enum_literal => return out_stream.writeAll("@TypeOf(.EnumLiteral)"), | ||
| 440 | .@"null" => return out_stream.writeAll("@TypeOf(null)"), | 443 | .@"null" => return out_stream.writeAll("@TypeOf(null)"), |
| 441 | .@"undefined" => return out_stream.writeAll("@TypeOf(undefined)"), | 444 | .@"undefined" => return out_stream.writeAll("@TypeOf(undefined)"), |
| 442 | 445 | ||
| ... | @@ -561,6 +564,7 @@ pub const Type = extern union { | ... | @@ -561,6 +564,7 @@ pub const Type = extern union { |
| 561 | .fn_ccc_void_no_args => return Value.initTag(.fn_ccc_void_no_args_type), | 564 | .fn_ccc_void_no_args => return Value.initTag(.fn_ccc_void_no_args_type), |
| 562 | .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type), | 565 | .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type), |
| 563 | .const_slice_u8 => return Value.initTag(.const_slice_u8_type), | 566 | .const_slice_u8 => return Value.initTag(.const_slice_u8_type), |
| 567 | .enum_literal => return Value.initTag(.enum_literal_type), | ||
| 564 | else => { | 568 | else => { |
| 565 | const ty_payload = try allocator.create(Value.Payload.Ty); | 569 | const ty_payload = try allocator.create(Value.Payload.Ty); |
| 566 | ty_payload.* = .{ .ty = self }; | 570 | ty_payload.* = .{ .ty = self }; |
| ... | @@ -625,6 +629,7 @@ pub const Type = extern union { | ... | @@ -625,6 +629,7 @@ pub const Type = extern union { |
| 625 | .noreturn, | 629 | .noreturn, |
| 626 | .@"null", | 630 | .@"null", |
| 627 | .@"undefined", | 631 | .@"undefined", |
| 632 | .enum_literal, | ||
| 628 | => false, | 633 | => false, |
| 629 | }; | 634 | }; |
| 630 | } | 635 | } |
| ... | @@ -716,6 +721,7 @@ pub const Type = extern union { | ... | @@ -716,6 +721,7 @@ pub const Type = extern union { |
| 716 | .noreturn, | 721 | .noreturn, |
| 717 | .@"null", | 722 | .@"null", |
| 718 | .@"undefined", | 723 | .@"undefined", |
| 724 | .enum_literal, | ||
| 719 | => unreachable, | 725 | => unreachable, |
| 720 | }; | 726 | }; |
| 721 | } | 727 | } |
| ... | @@ -736,6 +742,7 @@ pub const Type = extern union { | ... | @@ -736,6 +742,7 @@ pub const Type = extern union { |
| 736 | .noreturn => unreachable, | 742 | .noreturn => unreachable, |
| 737 | .@"null" => unreachable, | 743 | .@"null" => unreachable, |
| 738 | .@"undefined" => unreachable, | 744 | .@"undefined" => unreachable, |
| 745 | .enum_literal => unreachable, | ||
| 739 | 746 | ||
| 740 | .u8, | 747 | .u8, |
| 741 | .i8, | 748 | .i8, |
| ... | @@ -863,6 +870,7 @@ pub const Type = extern union { | ... | @@ -863,6 +870,7 @@ pub const Type = extern union { |
| 863 | .optional, | 870 | .optional, |
| 864 | .optional_single_mut_pointer, | 871 | .optional_single_mut_pointer, |
| 865 | .optional_single_const_pointer, | 872 | .optional_single_const_pointer, |
| 873 | .enum_literal, | ||
| 866 | => false, | 874 | => false, |
| 867 | 875 | ||
| 868 | .single_const_pointer, | 876 | .single_const_pointer, |
| ... | @@ -924,6 +932,7 @@ pub const Type = extern union { | ... | @@ -924,6 +932,7 @@ pub const Type = extern union { |
| 924 | .optional, | 932 | .optional, |
| 925 | .optional_single_mut_pointer, | 933 | .optional_single_mut_pointer, |
| 926 | .optional_single_const_pointer, | 934 | .optional_single_const_pointer, |
| 935 | .enum_literal, | ||
| 927 | => false, | 936 | => false, |
| 928 | 937 | ||
| 929 | .const_slice_u8 => true, | 938 | .const_slice_u8 => true, |
| ... | @@ -980,6 +989,7 @@ pub const Type = extern union { | ... | @@ -980,6 +989,7 @@ pub const Type = extern union { |
| 980 | .optional, | 989 | .optional, |
| 981 | .optional_single_mut_pointer, | 990 | .optional_single_mut_pointer, |
| 982 | .optional_single_const_pointer, | 991 | .optional_single_const_pointer, |
| 992 | .enum_literal, | ||
| 983 | => false, | 993 | => false, |
| 984 | 994 | ||
| 985 | .single_const_pointer, | 995 | .single_const_pointer, |
| ... | @@ -1042,6 +1052,7 @@ pub const Type = extern union { | ... | @@ -1042,6 +1052,7 @@ pub const Type = extern union { |
| 1042 | .optional, | 1052 | .optional, |
| 1043 | .optional_single_mut_pointer, | 1053 | .optional_single_mut_pointer, |
| 1044 | .optional_single_const_pointer, | 1054 | .optional_single_const_pointer, |
| 1055 | .enum_literal, | ||
| 1045 | => false, | 1056 | => false, |
| 1046 | }; | 1057 | }; |
| 1047 | } | 1058 | } |
| ... | @@ -1147,6 +1158,7 @@ pub const Type = extern union { | ... | @@ -1147,6 +1158,7 @@ pub const Type = extern union { |
| 1147 | .optional, | 1158 | .optional, |
| 1148 | .optional_single_const_pointer, | 1159 | .optional_single_const_pointer, |
| 1149 | .optional_single_mut_pointer, | 1160 | .optional_single_mut_pointer, |
| 1161 | .enum_literal, | ||
| 1150 | => unreachable, | 1162 | => unreachable, |
| 1151 | 1163 | ||
| 1152 | .array => self.cast(Payload.Array).?.elem_type, | 1164 | .array => self.cast(Payload.Array).?.elem_type, |
| ... | @@ -1252,6 +1264,7 @@ pub const Type = extern union { | ... | @@ -1252,6 +1264,7 @@ pub const Type = extern union { |
| 1252 | .optional, | 1264 | .optional, |
| 1253 | .optional_single_mut_pointer, | 1265 | .optional_single_mut_pointer, |
| 1254 | .optional_single_const_pointer, | 1266 | .optional_single_const_pointer, |
| 1267 | .enum_literal, | ||
| 1255 | => unreachable, | 1268 | => unreachable, |
| 1256 | 1269 | ||
| 1257 | .array => self.cast(Payload.Array).?.len, | 1270 | .array => self.cast(Payload.Array).?.len, |
| ... | @@ -1311,6 +1324,7 @@ pub const Type = extern union { | ... | @@ -1311,6 +1324,7 @@ pub const Type = extern union { |
| 1311 | .optional, | 1324 | .optional, |
| 1312 | .optional_single_mut_pointer, | 1325 | .optional_single_mut_pointer, |
| 1313 | .optional_single_const_pointer, | 1326 | .optional_single_const_pointer, |
| 1327 | .enum_literal, | ||
| 1314 | => unreachable, | 1328 | => unreachable, |
| 1315 | 1329 | ||
| 1316 | .array, .array_u8 => return null, | 1330 | .array, .array_u8 => return null, |
| ... | @@ -1368,6 +1382,7 @@ pub const Type = extern union { | ... | @@ -1368,6 +1382,7 @@ pub const Type = extern union { |
| 1368 | .optional, | 1382 | .optional, |
| 1369 | .optional_single_mut_pointer, | 1383 | .optional_single_mut_pointer, |
| 1370 | .optional_single_const_pointer, | 1384 | .optional_single_const_pointer, |
| 1385 | .enum_literal, | ||
| 1371 | => false, | 1386 | => false, |
| 1372 | 1387 | ||
| 1373 | .int_signed, | 1388 | .int_signed, |
| ... | @@ -1428,6 +1443,7 @@ pub const Type = extern union { | ... | @@ -1428,6 +1443,7 @@ pub const Type = extern union { |
| 1428 | .optional, | 1443 | .optional, |
| 1429 | .optional_single_mut_pointer, | 1444 | .optional_single_mut_pointer, |
| 1430 | .optional_single_const_pointer, | 1445 | .optional_single_const_pointer, |
| 1446 | .enum_literal, | ||
| 1431 | => false, | 1447 | => false, |
| 1432 | 1448 | ||
| 1433 | .int_unsigned, | 1449 | .int_unsigned, |
| ... | @@ -1478,6 +1494,7 @@ pub const Type = extern union { | ... | @@ -1478,6 +1494,7 @@ pub const Type = extern union { |
| 1478 | .optional, | 1494 | .optional, |
| 1479 | .optional_single_mut_pointer, | 1495 | .optional_single_mut_pointer, |
| 1480 | .optional_single_const_pointer, | 1496 | .optional_single_const_pointer, |
| 1497 | .enum_literal, | ||
| 1481 | => unreachable, | 1498 | => unreachable, |
| 1482 | 1499 | ||
| 1483 | .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits }, | 1500 | .int_unsigned => .{ .signed = false, .bits = self.cast(Payload.IntUnsigned).?.bits }, |
| ... | @@ -1546,6 +1563,7 @@ pub const Type = extern union { | ... | @@ -1546,6 +1563,7 @@ pub const Type = extern union { |
| 1546 | .optional, | 1563 | .optional, |
| 1547 | .optional_single_mut_pointer, | 1564 | .optional_single_mut_pointer, |
| 1548 | .optional_single_const_pointer, | 1565 | .optional_single_const_pointer, |
| 1566 | .enum_literal, | ||
| 1549 | => false, | 1567 | => false, |
| 1550 | 1568 | ||
| 1551 | .usize, | 1569 | .usize, |
| ... | @@ -1643,6 +1661,7 @@ pub const Type = extern union { | ... | @@ -1643,6 +1661,7 @@ pub const Type = extern union { |
| 1643 | .optional, | 1661 | .optional, |
| 1644 | .optional_single_mut_pointer, | 1662 | .optional_single_mut_pointer, |
| 1645 | .optional_single_const_pointer, | 1663 | .optional_single_const_pointer, |
| 1664 | .enum_literal, | ||
| 1646 | => unreachable, | 1665 | => unreachable, |
| 1647 | }; | 1666 | }; |
| 1648 | } | 1667 | } |
| ... | @@ -1706,6 +1725,7 @@ pub const Type = extern union { | ... | @@ -1706,6 +1725,7 @@ pub const Type = extern union { |
| 1706 | .optional, | 1725 | .optional, |
| 1707 | .optional_single_mut_pointer, | 1726 | .optional_single_mut_pointer, |
| 1708 | .optional_single_const_pointer, | 1727 | .optional_single_const_pointer, |
| 1728 | .enum_literal, | ||
| 1709 | => unreachable, | 1729 | => unreachable, |
| 1710 | } | 1730 | } |
| 1711 | } | 1731 | } |
| ... | @@ -1768,6 +1788,7 @@ pub const Type = extern union { | ... | @@ -1768,6 +1788,7 @@ pub const Type = extern union { |
| 1768 | .optional, | 1788 | .optional, |
| 1769 | .optional_single_mut_pointer, | 1789 | .optional_single_mut_pointer, |
| 1770 | .optional_single_const_pointer, | 1790 | .optional_single_const_pointer, |
| 1791 | .enum_literal, | ||
| 1771 | => unreachable, | 1792 | => unreachable, |
| 1772 | } | 1793 | } |
| 1773 | } | 1794 | } |
| ... | @@ -1830,6 +1851,7 @@ pub const Type = extern union { | ... | @@ -1830,6 +1851,7 @@ pub const Type = extern union { |
| 1830 | .optional, | 1851 | .optional, |
| 1831 | .optional_single_mut_pointer, | 1852 | .optional_single_mut_pointer, |
| 1832 | .optional_single_const_pointer, | 1853 | .optional_single_const_pointer, |
| 1854 | .enum_literal, | ||
| 1833 | => unreachable, | 1855 | => unreachable, |
| 1834 | }; | 1856 | }; |
| 1835 | } | 1857 | } |
| ... | @@ -1889,6 +1911,7 @@ pub const Type = extern union { | ... | @@ -1889,6 +1911,7 @@ pub const Type = extern union { |
| 1889 | .optional, | 1911 | .optional, |
| 1890 | .optional_single_mut_pointer, | 1912 | .optional_single_mut_pointer, |
| 1891 | .optional_single_const_pointer, | 1913 | .optional_single_const_pointer, |
| 1914 | .enum_literal, | ||
| 1892 | => unreachable, | 1915 | => unreachable, |
| 1893 | }; | 1916 | }; |
| 1894 | } | 1917 | } |
| ... | @@ -1948,6 +1971,7 @@ pub const Type = extern union { | ... | @@ -1948,6 +1971,7 @@ pub const Type = extern union { |
| 1948 | .optional, | 1971 | .optional, |
| 1949 | .optional_single_mut_pointer, | 1972 | .optional_single_mut_pointer, |
| 1950 | .optional_single_const_pointer, | 1973 | .optional_single_const_pointer, |
| 1974 | .enum_literal, | ||
| 1951 | => unreachable, | 1975 | => unreachable, |
| 1952 | }; | 1976 | }; |
| 1953 | } | 1977 | } |
| ... | @@ -2007,6 +2031,7 @@ pub const Type = extern union { | ... | @@ -2007,6 +2031,7 @@ pub const Type = extern union { |
| 2007 | .optional, | 2031 | .optional, |
| 2008 | .optional_single_mut_pointer, | 2032 | .optional_single_mut_pointer, |
| 2009 | .optional_single_const_pointer, | 2033 | .optional_single_const_pointer, |
| 2034 | .enum_literal, | ||
| 2010 | => false, | 2035 | => false, |
| 2011 | }; | 2036 | }; |
| 2012 | } | 2037 | } |
| ... | @@ -2055,6 +2080,7 @@ pub const Type = extern union { | ... | @@ -2055,6 +2080,7 @@ pub const Type = extern union { |
| 2055 | .optional, | 2080 | .optional, |
| 2056 | .optional_single_mut_pointer, | 2081 | .optional_single_mut_pointer, |
| 2057 | .optional_single_const_pointer, | 2082 | .optional_single_const_pointer, |
| 2083 | .enum_literal, | ||
| 2058 | => return null, | 2084 | => return null, |
| 2059 | 2085 | ||
| 2060 | .void => return Value.initTag(.void_value), | 2086 | .void => return Value.initTag(.void_value), |
| ... | @@ -2143,6 +2169,7 @@ pub const Type = extern union { | ... | @@ -2143,6 +2169,7 @@ pub const Type = extern union { |
| 2143 | .optional, | 2169 | .optional, |
| 2144 | .optional_single_mut_pointer, | 2170 | .optional_single_mut_pointer, |
| 2145 | .optional_single_const_pointer, | 2171 | .optional_single_const_pointer, |
| 2172 | .enum_literal, | ||
| 2146 | => return false, | 2173 | => return false, |
| 2147 | }; | 2174 | }; |
| 2148 | } | 2175 | } |
| ... | @@ -2186,6 +2213,7 @@ pub const Type = extern union { | ... | @@ -2186,6 +2213,7 @@ pub const Type = extern union { |
| 2186 | comptime_int, | 2213 | comptime_int, |
| 2187 | comptime_float, | 2214 | comptime_float, |
| 2188 | noreturn, | 2215 | noreturn, |
| 2216 | enum_literal, | ||
| 2189 | @"null", | 2217 | @"null", |
| 2190 | @"undefined", | 2218 | @"undefined", |
| 2191 | fn_noreturn_no_args, | 2219 | fn_noreturn_no_args, |
src-self-hosted/value.zig+33-2| ... | @@ -60,6 +60,7 @@ pub const Value = extern union { | ... | @@ -60,6 +60,7 @@ pub const Value = extern union { |
| 60 | fn_ccc_void_no_args_type, | 60 | fn_ccc_void_no_args_type, |
| 61 | single_const_pointer_to_comptime_int_type, | 61 | single_const_pointer_to_comptime_int_type, |
| 62 | const_slice_u8_type, | 62 | const_slice_u8_type, |
| 63 | enum_literal_type, | ||
| 63 | 64 | ||
| 64 | undef, | 65 | undef, |
| 65 | zero, | 66 | zero, |
| ... | @@ -87,6 +88,7 @@ pub const Value = extern union { | ... | @@ -87,6 +88,7 @@ pub const Value = extern union { |
| 87 | float_32, | 88 | float_32, |
| 88 | float_64, | 89 | float_64, |
| 89 | float_128, | 90 | float_128, |
| 91 | enum_literal, | ||
| 90 | 92 | ||
| 91 | pub const last_no_payload_tag = Tag.bool_false; | 93 | pub const last_no_payload_tag = Tag.bool_false; |
| 92 | pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; | 94 | pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; |
| ... | @@ -164,6 +166,7 @@ pub const Value = extern union { | ... | @@ -164,6 +166,7 @@ pub const Value = extern union { |
| 164 | .fn_ccc_void_no_args_type, | 166 | .fn_ccc_void_no_args_type, |
| 165 | .single_const_pointer_to_comptime_int_type, | 167 | .single_const_pointer_to_comptime_int_type, |
| 166 | .const_slice_u8_type, | 168 | .const_slice_u8_type, |
| 169 | .enum_literal_type, | ||
| 167 | .undef, | 170 | .undef, |
| 168 | .zero, | 171 | .zero, |
| 169 | .void_value, | 172 | .void_value, |
| ... | @@ -213,7 +216,7 @@ pub const Value = extern union { | ... | @@ -213,7 +216,7 @@ pub const Value = extern union { |
| 213 | }; | 216 | }; |
| 214 | return Value{ .ptr_otherwise = &new_payload.base }; | 217 | return Value{ .ptr_otherwise = &new_payload.base }; |
| 215 | }, | 218 | }, |
| 216 | .bytes => return self.copyPayloadShallow(allocator, Payload.Bytes), | 219 | .enum_literal, .bytes => return self.copyPayloadShallow(allocator, Payload.Bytes), |
| 217 | .repeated => { | 220 | .repeated => { |
| 218 | const payload = @fieldParentPtr(Payload.Repeated, "base", self.ptr_otherwise); | 221 | const payload = @fieldParentPtr(Payload.Repeated, "base", self.ptr_otherwise); |
| 219 | const new_payload = try allocator.create(Payload.Repeated); | 222 | const new_payload = try allocator.create(Payload.Repeated); |
| ... | @@ -285,6 +288,7 @@ pub const Value = extern union { | ... | @@ -285,6 +288,7 @@ pub const Value = extern union { |
| 285 | .fn_ccc_void_no_args_type => return out_stream.writeAll("fn() callconv(.C) void"), | 288 | .fn_ccc_void_no_args_type => return out_stream.writeAll("fn() callconv(.C) void"), |
| 286 | .single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"), | 289 | .single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"), |
| 287 | .const_slice_u8_type => return out_stream.writeAll("[]const u8"), | 290 | .const_slice_u8_type => return out_stream.writeAll("[]const u8"), |
| 291 | .enum_literal_type => return out_stream.writeAll("@TypeOf(.EnumLiteral)"), | ||
| 288 | 292 | ||
| 289 | .null_value => return out_stream.writeAll("null"), | 293 | .null_value => return out_stream.writeAll("null"), |
| 290 | .undef => return out_stream.writeAll("undefined"), | 294 | .undef => return out_stream.writeAll("undefined"), |
| ... | @@ -318,7 +322,7 @@ pub const Value = extern union { | ... | @@ -318,7 +322,7 @@ pub const Value = extern union { |
| 318 | val = elem_ptr.array_ptr; | 322 | val = elem_ptr.array_ptr; |
| 319 | }, | 323 | }, |
| 320 | .empty_array => return out_stream.writeAll(".{}"), | 324 | .empty_array => return out_stream.writeAll(".{}"), |
| 321 | .bytes => return std.zig.renderStringLiteral(self.cast(Payload.Bytes).?.data, out_stream), | 325 | .enum_literal, .bytes => return std.zig.renderStringLiteral(self.cast(Payload.Bytes).?.data, out_stream), |
| 322 | .repeated => { | 326 | .repeated => { |
| 323 | try out_stream.writeAll("(repeated) "); | 327 | try out_stream.writeAll("(repeated) "); |
| 324 | val = val.cast(Payload.Repeated).?.val; | 328 | val = val.cast(Payload.Repeated).?.val; |
| ... | @@ -391,6 +395,7 @@ pub const Value = extern union { | ... | @@ -391,6 +395,7 @@ pub const Value = extern union { |
| 391 | .fn_ccc_void_no_args_type => Type.initTag(.fn_ccc_void_no_args), | 395 | .fn_ccc_void_no_args_type => Type.initTag(.fn_ccc_void_no_args), |
| 392 | .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int), | 396 | .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int), |
| 393 | .const_slice_u8_type => Type.initTag(.const_slice_u8), | 397 | .const_slice_u8_type => Type.initTag(.const_slice_u8), |
| 398 | .enum_literal_type => Type.initTag(.enum_literal), | ||
| 394 | 399 | ||
| 395 | .undef, | 400 | .undef, |
| 396 | .zero, | 401 | .zero, |
| ... | @@ -414,6 +419,7 @@ pub const Value = extern union { | ... | @@ -414,6 +419,7 @@ pub const Value = extern union { |
| 414 | .float_32, | 419 | .float_32, |
| 415 | .float_64, | 420 | .float_64, |
| 416 | .float_128, | 421 | .float_128, |
| 422 | .enum_literal, | ||
| 417 | => unreachable, | 423 | => unreachable, |
| 418 | }; | 424 | }; |
| 419 | } | 425 | } |
| ... | @@ -462,6 +468,7 @@ pub const Value = extern union { | ... | @@ -462,6 +468,7 @@ pub const Value = extern union { |
| 462 | .fn_ccc_void_no_args_type, | 468 | .fn_ccc_void_no_args_type, |
| 463 | .single_const_pointer_to_comptime_int_type, | 469 | .single_const_pointer_to_comptime_int_type, |
| 464 | .const_slice_u8_type, | 470 | .const_slice_u8_type, |
| 471 | .enum_literal_type, | ||
| 465 | .null_value, | 472 | .null_value, |
| 466 | .function, | 473 | .function, |
| 467 | .ref_val, | 474 | .ref_val, |
| ... | @@ -476,6 +483,7 @@ pub const Value = extern union { | ... | @@ -476,6 +483,7 @@ pub const Value = extern union { |
| 476 | .void_value, | 483 | .void_value, |
| 477 | .unreachable_value, | 484 | .unreachable_value, |
| 478 | .empty_array, | 485 | .empty_array, |
| 486 | .enum_literal, | ||
| 479 | => unreachable, | 487 | => unreachable, |
| 480 | 488 | ||
| 481 | .undef => unreachable, | 489 | .undef => unreachable, |
| ... | @@ -537,6 +545,7 @@ pub const Value = extern union { | ... | @@ -537,6 +545,7 @@ pub const Value = extern union { |
| 537 | .fn_ccc_void_no_args_type, | 545 | .fn_ccc_void_no_args_type, |
| 538 | .single_const_pointer_to_comptime_int_type, | 546 | .single_const_pointer_to_comptime_int_type, |
| 539 | .const_slice_u8_type, | 547 | .const_slice_u8_type, |
| 548 | .enum_literal_type, | ||
| 540 | .null_value, | 549 | .null_value, |
| 541 | .function, | 550 | .function, |
| 542 | .ref_val, | 551 | .ref_val, |
| ... | @@ -551,6 +560,7 @@ pub const Value = extern union { | ... | @@ -551,6 +560,7 @@ pub const Value = extern union { |
| 551 | .void_value, | 560 | .void_value, |
| 552 | .unreachable_value, | 561 | .unreachable_value, |
| 553 | .empty_array, | 562 | .empty_array, |
| 563 | .enum_literal, | ||
| 554 | => unreachable, | 564 | => unreachable, |
| 555 | 565 | ||
| 556 | .undef => unreachable, | 566 | .undef => unreachable, |
| ... | @@ -612,6 +622,7 @@ pub const Value = extern union { | ... | @@ -612,6 +622,7 @@ pub const Value = extern union { |
| 612 | .fn_ccc_void_no_args_type, | 622 | .fn_ccc_void_no_args_type, |
| 613 | .single_const_pointer_to_comptime_int_type, | 623 | .single_const_pointer_to_comptime_int_type, |
| 614 | .const_slice_u8_type, | 624 | .const_slice_u8_type, |
| 625 | .enum_literal_type, | ||
| 615 | .null_value, | 626 | .null_value, |
| 616 | .function, | 627 | .function, |
| 617 | .ref_val, | 628 | .ref_val, |
| ... | @@ -626,6 +637,7 @@ pub const Value = extern union { | ... | @@ -626,6 +637,7 @@ pub const Value = extern union { |
| 626 | .void_value, | 637 | .void_value, |
| 627 | .unreachable_value, | 638 | .unreachable_value, |
| 628 | .empty_array, | 639 | .empty_array, |
| 640 | .enum_literal, | ||
| 629 | => unreachable, | 641 | => unreachable, |
| 630 | 642 | ||
| 631 | .undef => unreachable, | 643 | .undef => unreachable, |
| ... | @@ -713,6 +725,7 @@ pub const Value = extern union { | ... | @@ -713,6 +725,7 @@ pub const Value = extern union { |
| 713 | .fn_ccc_void_no_args_type, | 725 | .fn_ccc_void_no_args_type, |
| 714 | .single_const_pointer_to_comptime_int_type, | 726 | .single_const_pointer_to_comptime_int_type, |
| 715 | .const_slice_u8_type, | 727 | .const_slice_u8_type, |
| 728 | .enum_literal_type, | ||
| 716 | .null_value, | 729 | .null_value, |
| 717 | .function, | 730 | .function, |
| 718 | .ref_val, | 731 | .ref_val, |
| ... | @@ -728,6 +741,7 @@ pub const Value = extern union { | ... | @@ -728,6 +741,7 @@ pub const Value = extern union { |
| 728 | .void_value, | 741 | .void_value, |
| 729 | .unreachable_value, | 742 | .unreachable_value, |
| 730 | .empty_array, | 743 | .empty_array, |
| 744 | .enum_literal, | ||
| 731 | => unreachable, | 745 | => unreachable, |
| 732 | 746 | ||
| 733 | .zero, | 747 | .zero, |
| ... | @@ -793,6 +807,7 @@ pub const Value = extern union { | ... | @@ -793,6 +807,7 @@ pub const Value = extern union { |
| 793 | .fn_ccc_void_no_args_type, | 807 | .fn_ccc_void_no_args_type, |
| 794 | .single_const_pointer_to_comptime_int_type, | 808 | .single_const_pointer_to_comptime_int_type, |
| 795 | .const_slice_u8_type, | 809 | .const_slice_u8_type, |
| 810 | .enum_literal_type, | ||
| 796 | .null_value, | 811 | .null_value, |
| 797 | .function, | 812 | .function, |
| 798 | .ref_val, | 813 | .ref_val, |
| ... | @@ -807,6 +822,7 @@ pub const Value = extern union { | ... | @@ -807,6 +822,7 @@ pub const Value = extern union { |
| 807 | .void_value, | 822 | .void_value, |
| 808 | .unreachable_value, | 823 | .unreachable_value, |
| 809 | .empty_array, | 824 | .empty_array, |
| 825 | .enum_literal, | ||
| 810 | => unreachable, | 826 | => unreachable, |
| 811 | 827 | ||
| 812 | .zero, | 828 | .zero, |
| ... | @@ -953,6 +969,7 @@ pub const Value = extern union { | ... | @@ -953,6 +969,7 @@ pub const Value = extern union { |
| 953 | .fn_ccc_void_no_args_type, | 969 | .fn_ccc_void_no_args_type, |
| 954 | .single_const_pointer_to_comptime_int_type, | 970 | .single_const_pointer_to_comptime_int_type, |
| 955 | .const_slice_u8_type, | 971 | .const_slice_u8_type, |
| 972 | .enum_literal_type, | ||
| 956 | .bool_true, | 973 | .bool_true, |
| 957 | .bool_false, | 974 | .bool_false, |
| 958 | .null_value, | 975 | .null_value, |
| ... | @@ -970,6 +987,7 @@ pub const Value = extern union { | ... | @@ -970,6 +987,7 @@ pub const Value = extern union { |
| 970 | .empty_array, | 987 | .empty_array, |
| 971 | .void_value, | 988 | .void_value, |
| 972 | .unreachable_value, | 989 | .unreachable_value, |
| 990 | .enum_literal, | ||
| 973 | => unreachable, | 991 | => unreachable, |
| 974 | 992 | ||
| 975 | .zero => false, | 993 | .zero => false, |
| ... | @@ -1025,6 +1043,7 @@ pub const Value = extern union { | ... | @@ -1025,6 +1043,7 @@ pub const Value = extern union { |
| 1025 | .fn_ccc_void_no_args_type, | 1043 | .fn_ccc_void_no_args_type, |
| 1026 | .single_const_pointer_to_comptime_int_type, | 1044 | .single_const_pointer_to_comptime_int_type, |
| 1027 | .const_slice_u8_type, | 1045 | .const_slice_u8_type, |
| 1046 | .enum_literal_type, | ||
| 1028 | .null_value, | 1047 | .null_value, |
| 1029 | .function, | 1048 | .function, |
| 1030 | .ref_val, | 1049 | .ref_val, |
| ... | @@ -1036,6 +1055,7 @@ pub const Value = extern union { | ... | @@ -1036,6 +1055,7 @@ pub const Value = extern union { |
| 1036 | .void_value, | 1055 | .void_value, |
| 1037 | .unreachable_value, | 1056 | .unreachable_value, |
| 1038 | .empty_array, | 1057 | .empty_array, |
| 1058 | .enum_literal, | ||
| 1039 | => unreachable, | 1059 | => unreachable, |
| 1040 | 1060 | ||
| 1041 | .zero, | 1061 | .zero, |
| ... | @@ -1102,6 +1122,11 @@ pub const Value = extern union { | ... | @@ -1102,6 +1122,11 @@ pub const Value = extern union { |
| 1102 | } | 1122 | } |
| 1103 | 1123 | ||
| 1104 | pub fn eql(a: Value, b: Value) bool { | 1124 | pub fn eql(a: Value, b: Value) bool { |
| 1125 | if (a.tag() == b.tag() and a.tag() == .enum_literal) { | ||
| 1126 | const a_name = @fieldParentPtr(Payload.Bytes, "base", a.ptr_otherwise).data; | ||
| 1127 | const b_name = @fieldParentPtr(Payload.Bytes, "base", b.ptr_otherwise).data; | ||
| 1128 | return std.mem.eql(u8, a_name, b_name); | ||
| 1129 | } | ||
| 1105 | // TODO non numerical comparisons | 1130 | // TODO non numerical comparisons |
| 1106 | return compare(a, .eq, b); | 1131 | return compare(a, .eq, b); |
| 1107 | } | 1132 | } |
| ... | @@ -1151,6 +1176,7 @@ pub const Value = extern union { | ... | @@ -1151,6 +1176,7 @@ pub const Value = extern union { |
| 1151 | .fn_ccc_void_no_args_type, | 1176 | .fn_ccc_void_no_args_type, |
| 1152 | .single_const_pointer_to_comptime_int_type, | 1177 | .single_const_pointer_to_comptime_int_type, |
| 1153 | .const_slice_u8_type, | 1178 | .const_slice_u8_type, |
| 1179 | .enum_literal_type, | ||
| 1154 | .zero, | 1180 | .zero, |
| 1155 | .bool_true, | 1181 | .bool_true, |
| 1156 | .bool_false, | 1182 | .bool_false, |
| ... | @@ -1170,6 +1196,7 @@ pub const Value = extern union { | ... | @@ -1170,6 +1196,7 @@ pub const Value = extern union { |
| 1170 | .void_value, | 1196 | .void_value, |
| 1171 | .unreachable_value, | 1197 | .unreachable_value, |
| 1172 | .empty_array, | 1198 | .empty_array, |
| 1199 | .enum_literal, | ||
| 1173 | => unreachable, | 1200 | => unreachable, |
| 1174 | 1201 | ||
| 1175 | .ref_val => self.cast(Payload.RefVal).?.val, | 1202 | .ref_val => self.cast(Payload.RefVal).?.val, |
| ... | @@ -1227,6 +1254,7 @@ pub const Value = extern union { | ... | @@ -1227,6 +1254,7 @@ pub const Value = extern union { |
| 1227 | .fn_ccc_void_no_args_type, | 1254 | .fn_ccc_void_no_args_type, |
| 1228 | .single_const_pointer_to_comptime_int_type, | 1255 | .single_const_pointer_to_comptime_int_type, |
| 1229 | .const_slice_u8_type, | 1256 | .const_slice_u8_type, |
| 1257 | .enum_literal_type, | ||
| 1230 | .zero, | 1258 | .zero, |
| 1231 | .bool_true, | 1259 | .bool_true, |
| 1232 | .bool_false, | 1260 | .bool_false, |
| ... | @@ -1246,6 +1274,7 @@ pub const Value = extern union { | ... | @@ -1246,6 +1274,7 @@ pub const Value = extern union { |
| 1246 | .float_128, | 1274 | .float_128, |
| 1247 | .void_value, | 1275 | .void_value, |
| 1248 | .unreachable_value, | 1276 | .unreachable_value, |
| 1277 | .enum_literal, | ||
| 1249 | => unreachable, | 1278 | => unreachable, |
| 1250 | 1279 | ||
| 1251 | .empty_array => unreachable, // out of bounds array index | 1280 | .empty_array => unreachable, // out of bounds array index |
| ... | @@ -1320,6 +1349,7 @@ pub const Value = extern union { | ... | @@ -1320,6 +1349,7 @@ pub const Value = extern union { |
| 1320 | .fn_ccc_void_no_args_type, | 1349 | .fn_ccc_void_no_args_type, |
| 1321 | .single_const_pointer_to_comptime_int_type, | 1350 | .single_const_pointer_to_comptime_int_type, |
| 1322 | .const_slice_u8_type, | 1351 | .const_slice_u8_type, |
| 1352 | .enum_literal_type, | ||
| 1323 | .zero, | 1353 | .zero, |
| 1324 | .empty_array, | 1354 | .empty_array, |
| 1325 | .bool_true, | 1355 | .bool_true, |
| ... | @@ -1339,6 +1369,7 @@ pub const Value = extern union { | ... | @@ -1339,6 +1369,7 @@ pub const Value = extern union { |
| 1339 | .float_64, | 1369 | .float_64, |
| 1340 | .float_128, | 1370 | .float_128, |
| 1341 | .void_value, | 1371 | .void_value, |
| 1372 | .enum_literal, | ||
| 1342 | => false, | 1373 | => false, |
| 1343 | 1374 | ||
| 1344 | .undef => unreachable, | 1375 | .undef => unreachable, |
src-self-hosted/zir.zig+14| ... | @@ -231,6 +231,8 @@ pub const Inst = struct { | ... | @@ -231,6 +231,8 @@ pub const Inst = struct { |
| 231 | unwrap_err_unsafe, | 231 | unwrap_err_unsafe, |
| 232 | /// Takes a *E!T and raises a compiler error if T != void | 232 | /// Takes a *E!T and raises a compiler error if T != void |
| 233 | ensure_err_payload_void, | 233 | ensure_err_payload_void, |
| 234 | /// Enum literal | ||
| 235 | enum_literal, | ||
| 234 | 236 | ||
| 235 | pub fn Type(tag: Tag) type { | 237 | pub fn Type(tag: Tag) type { |
| 236 | return switch (tag) { | 238 | return switch (tag) { |
| ... | @@ -326,6 +328,7 @@ pub const Inst = struct { | ... | @@ -326,6 +328,7 @@ pub const Inst = struct { |
| 326 | .elemptr => ElemPtr, | 328 | .elemptr => ElemPtr, |
| 327 | .condbr => CondBr, | 329 | .condbr => CondBr, |
| 328 | .ptr_type => PtrType, | 330 | .ptr_type => PtrType, |
| 331 | .enum_literal => EnumLiteral, | ||
| 329 | }; | 332 | }; |
| 330 | } | 333 | } |
| 331 | 334 | ||
| ... | @@ -410,6 +413,7 @@ pub const Inst = struct { | ... | @@ -410,6 +413,7 @@ pub const Inst = struct { |
| 410 | .unwrap_err_unsafe, | 413 | .unwrap_err_unsafe, |
| 411 | .ptr_type, | 414 | .ptr_type, |
| 412 | .ensure_err_payload_void, | 415 | .ensure_err_payload_void, |
| 416 | .enum_literal, | ||
| 413 | => false, | 417 | => false, |
| 414 | 418 | ||
| 415 | .@"break", | 419 | .@"break", |
| ... | @@ -869,6 +873,16 @@ pub const Inst = struct { | ... | @@ -869,6 +873,16 @@ pub const Inst = struct { |
| 869 | }, | 873 | }, |
| 870 | kw_args: struct {}, | 874 | kw_args: struct {}, |
| 871 | }; | 875 | }; |
| 876 | |||
| 877 | pub const EnumLiteral = struct { | ||
| 878 | pub const base_tag = Tag.enum_literal; | ||
| 879 | base: Inst, | ||
| 880 | |||
| 881 | positionals: struct { | ||
| 882 | name: []const u8, | ||
| 883 | }, | ||
| 884 | kw_args: struct {}, | ||
| 885 | }; | ||
| 872 | }; | 886 | }; |
| 873 | 887 | ||
| 874 | pub const ErrorMsg = struct { | 888 | pub const ErrorMsg = struct { |
src-self-hosted/zir_sema.zig+13| ... | @@ -115,6 +115,7 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! | ... | @@ -115,6 +115,7 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! |
| 115 | .ensure_err_payload_void => return analyzeInstEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), | 115 | .ensure_err_payload_void => return analyzeInstEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), |
| 116 | .array_type => return analyzeInstArrayType(mod, scope, old_inst.castTag(.array_type).?), | 116 | .array_type => return analyzeInstArrayType(mod, scope, old_inst.castTag(.array_type).?), |
| 117 | .array_type_sentinel => return analyzeInstArrayTypeSentinel(mod, scope, old_inst.castTag(.array_type_sentinel).?), | 117 | .array_type_sentinel => return analyzeInstArrayTypeSentinel(mod, scope, old_inst.castTag(.array_type_sentinel).?), |
| 118 | .enum_literal => return analyzeInstEnumLiteral(mod, scope, old_inst.castTag(.enum_literal).?), | ||
| 118 | } | 119 | } |
| 119 | } | 120 | } |
| 120 | 121 | ||
| ... | @@ -701,6 +702,18 @@ fn analyzeInstArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.Ar | ... | @@ -701,6 +702,18 @@ fn analyzeInstArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.Ar |
| 701 | return mod.constType(scope, array.base.src, try mod.arrayType(scope, len.val.toUnsignedInt(), sentinel.val, elem_type)); | 702 | return mod.constType(scope, array.base.src, try mod.arrayType(scope, len.val.toUnsignedInt(), sentinel.val, elem_type)); |
| 702 | } | 703 | } |
| 703 | 704 | ||
| 705 | fn analyzeInstEnumLiteral(mod: *Module, scope: *Scope, inst: *zir.Inst.EnumLiteral) InnerError!*Inst { | ||
| 706 | const payload = try scope.arena().create(Value.Payload.Bytes); | ||
| 707 | payload.* = .{ | ||
| 708 | .base = .{ .tag = .enum_literal }, | ||
| 709 | .data = try scope.arena().dupe(u8, inst.positionals.name), | ||
| 710 | }; | ||
| 711 | return mod.constInst(scope, inst.base.src, .{ | ||
| 712 | .ty = Type.initTag(.enum_literal), | ||
| 713 | .val = Value.initPayload(&payload.base), | ||
| 714 | }); | ||
| 715 | } | ||
| 716 | |||
| 704 | fn analyzeInstUnwrapOptional(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, safety_check: bool) InnerError!*Inst { | 717 | fn analyzeInstUnwrapOptional(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, safety_check: bool) InnerError!*Inst { |
| 705 | const operand = try resolveInst(mod, scope, unwrap.positionals.operand); | 718 | const operand = try resolveInst(mod, scope, unwrap.positionals.operand); |
| 706 | assert(operand.ty.zigTypeTag() == .Pointer); | 719 | assert(operand.ty.zigTypeTag() == .Pointer); |