| ... | ... | @@ -17259,10 +17259,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17259 | 17259 | const vals = try sema.arena.alloc(InternPool.Index, names.len); |
| 17260 | 17260 | for (vals, 0..) |*field_val, i| { |
| 17261 | 17261 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17262 | | const name = try sema.arena.dupe(u8, ip.stringToSlice(names.get(ip)[i])); |
| 17262 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(names.get(ip)[i])); |
| 17263 | 17263 | const name_val = v: { |
| 17264 | 17264 | const new_decl_ty = try mod.arrayType(.{ |
| 17265 | 17265 | .len = name.len, |
| 17266 | .sentinel = .zero_u8, |
| 17266 | 17267 | .child = .u8_type, |
| 17267 | 17268 | }); |
| 17268 | 17269 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17270,17 +17271,17 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17270 | 17271 | .storage = .{ .bytes = name }, |
| 17271 | 17272 | } }); |
| 17272 | 17273 | break :v try mod.intern(.{ .ptr = .{ |
| 17273 | | .ty = .slice_const_u8_type, |
| 17274 | .ty = .slice_const_u8_sentinel_0_type, |
| 17274 | 17275 | .addr = .{ .anon_decl = .{ |
| 17275 | 17276 | .val = new_decl_val, |
| 17276 | | .orig_ty = .slice_const_u8_type, |
| 17277 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17277 | 17278 | } }, |
| 17278 | 17279 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17279 | 17280 | } }); |
| 17280 | 17281 | }; |
| 17281 | 17282 | |
| 17282 | 17283 | const error_field_fields = .{ |
| 17283 | | // name: []const u8, |
| 17284 | // name: [:0]const u8, |
| 17284 | 17285 | name_val, |
| 17285 | 17286 | }; |
| 17286 | 17287 | field_val.* = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17387,10 +17388,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17387 | 17388 | else |
| 17388 | 17389 | (try mod.intValue(Type.comptime_int, i)).toIntern(); |
| 17389 | 17390 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17390 | | const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); |
| 17391 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(enum_type.names.get(ip)[i])); |
| 17391 | 17392 | const name_val = v: { |
| 17392 | 17393 | const new_decl_ty = try mod.arrayType(.{ |
| 17393 | 17394 | .len = name.len, |
| 17395 | .sentinel = .zero_u8, |
| 17394 | 17396 | .child = .u8_type, |
| 17395 | 17397 | }); |
| 17396 | 17398 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17398,17 +17400,17 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17398 | 17400 | .storage = .{ .bytes = name }, |
| 17399 | 17401 | } }); |
| 17400 | 17402 | break :v try mod.intern(.{ .ptr = .{ |
| 17401 | | .ty = .slice_const_u8_type, |
| 17403 | .ty = .slice_const_u8_sentinel_0_type, |
| 17402 | 17404 | .addr = .{ .anon_decl = .{ |
| 17403 | 17405 | .val = new_decl_val, |
| 17404 | | .orig_ty = .slice_const_u8_type, |
| 17406 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17405 | 17407 | } }, |
| 17406 | 17408 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17407 | 17409 | } }); |
| 17408 | 17410 | }; |
| 17409 | 17411 | |
| 17410 | 17412 | const enum_field_fields = .{ |
| 17411 | | // name: []const u8, |
| 17413 | // name: [:0]const u8, |
| 17412 | 17414 | name_val, |
| 17413 | 17415 | // value: comptime_int, |
| 17414 | 17416 | value_val, |
| ... | ... | @@ -17512,10 +17514,11 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17512 | 17514 | |
| 17513 | 17515 | for (union_field_vals, 0..) |*field_val, i| { |
| 17514 | 17516 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17515 | | const name = try sema.arena.dupe(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i])); |
| 17517 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i])); |
| 17516 | 17518 | const name_val = v: { |
| 17517 | 17519 | const new_decl_ty = try mod.arrayType(.{ |
| 17518 | 17520 | .len = name.len, |
| 17521 | .sentinel = .zero_u8, |
| 17519 | 17522 | .child = .u8_type, |
| 17520 | 17523 | }); |
| 17521 | 17524 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17523,10 +17526,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17523 | 17526 | .storage = .{ .bytes = name }, |
| 17524 | 17527 | } }); |
| 17525 | 17528 | break :v try mod.intern(.{ .ptr = .{ |
| 17526 | | .ty = .slice_const_u8_type, |
| 17529 | .ty = .slice_const_u8_sentinel_0_type, |
| 17527 | 17530 | .addr = .{ .anon_decl = .{ |
| 17528 | 17531 | .val = new_decl_val, |
| 17529 | | .orig_ty = .slice_const_u8_type, |
| 17532 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17530 | 17533 | } }, |
| 17531 | 17534 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17532 | 17535 | } }); |
| ... | ... | @@ -17539,7 +17542,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17539 | 17542 | |
| 17540 | 17543 | const field_ty = union_obj.field_types.get(ip)[i]; |
| 17541 | 17544 | const union_field_fields = .{ |
| 17542 | | // name: []const u8, |
| 17545 | // name: [:0]const u8, |
| 17543 | 17546 | name_val, |
| 17544 | 17547 | // type: type, |
| 17545 | 17548 | field_ty, |
| ... | ... | @@ -17658,11 +17661,12 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17658 | 17661 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17659 | 17662 | const bytes = if (tuple.names.len != 0) |
| 17660 | 17663 | // https://github.com/ziglang/zig/issues/15709 |
| 17661 | | try sema.arena.dupe(u8, ip.stringToSlice(ip.indexToKey(ty.toIntern()).anon_struct_type.names.get(ip)[i])) |
| 17664 | try sema.arena.dupeZ(u8, ip.stringToSlice(ip.indexToKey(ty.toIntern()).anon_struct_type.names.get(ip)[i])) |
| 17662 | 17665 | else |
| 17663 | | try std.fmt.allocPrint(sema.arena, "{d}", .{i}); |
| 17666 | try std.fmt.allocPrintZ(sema.arena, "{d}", .{i}); |
| 17664 | 17667 | const new_decl_ty = try mod.arrayType(.{ |
| 17665 | 17668 | .len = bytes.len, |
| 17669 | .sentinel = .zero_u8, |
| 17666 | 17670 | .child = .u8_type, |
| 17667 | 17671 | }); |
| 17668 | 17672 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17670,10 +17674,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17670 | 17674 | .storage = .{ .bytes = bytes }, |
| 17671 | 17675 | } }); |
| 17672 | 17676 | break :v try mod.intern(.{ .ptr = .{ |
| 17673 | | .ty = .slice_const_u8_type, |
| 17677 | .ty = .slice_const_u8_sentinel_0_type, |
| 17674 | 17678 | .addr = .{ .anon_decl = .{ |
| 17675 | 17679 | .val = new_decl_val, |
| 17676 | | .orig_ty = .slice_const_u8_type, |
| 17680 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17677 | 17681 | } }, |
| 17678 | 17682 | .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(), |
| 17679 | 17683 | } }); |
| ... | ... | @@ -17685,7 +17689,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17685 | 17689 | const opt_default_val = if (is_comptime) Value.fromInterned(field_val) else null; |
| 17686 | 17690 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 17687 | 17691 | const struct_field_fields = .{ |
| 17688 | | // name: []const u8, |
| 17692 | // name: [:0]const u8, |
| 17689 | 17693 | name_val, |
| 17690 | 17694 | // type: type, |
| 17691 | 17695 | field_ty, |
| ... | ... | @@ -17713,7 +17717,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17713 | 17717 | for (struct_field_vals, 0..) |*field_val, i| { |
| 17714 | 17718 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17715 | 17719 | const name = if (struct_type.fieldName(ip, i).unwrap()) |name_nts| |
| 17716 | | try sema.arena.dupe(u8, ip.stringToSlice(name_nts)) |
| 17720 | try sema.arena.dupeZ(u8, ip.stringToSlice(name_nts)) |
| 17717 | 17721 | else |
| 17718 | 17722 | try std.fmt.allocPrintZ(sema.arena, "{d}", .{i}); |
| 17719 | 17723 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| ... | ... | @@ -17722,6 +17726,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17722 | 17726 | const name_val = v: { |
| 17723 | 17727 | const new_decl_ty = try mod.arrayType(.{ |
| 17724 | 17728 | .len = name.len, |
| 17729 | .sentinel = .zero_u8, |
| 17725 | 17730 | .child = .u8_type, |
| 17726 | 17731 | }); |
| 17727 | 17732 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17729,10 +17734,10 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17729 | 17734 | .storage = .{ .bytes = name }, |
| 17730 | 17735 | } }); |
| 17731 | 17736 | break :v try mod.intern(.{ .ptr = .{ |
| 17732 | | .ty = .slice_const_u8_type, |
| 17737 | .ty = .slice_const_u8_sentinel_0_type, |
| 17733 | 17738 | .addr = .{ .anon_decl = .{ |
| 17734 | 17739 | .val = new_decl_val, |
| 17735 | | .orig_ty = .slice_const_u8_type, |
| 17740 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17736 | 17741 | } }, |
| 17737 | 17742 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| 17738 | 17743 | } }); |
| ... | ... | @@ -17750,7 +17755,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17750 | 17755 | }; |
| 17751 | 17756 | |
| 17752 | 17757 | const struct_field_fields = .{ |
| 17753 | | // name: []const u8, |
| 17758 | // name: [:0]const u8, |
| 17754 | 17759 | name_val, |
| 17755 | 17760 | // type: type, |
| 17756 | 17761 | field_ty.toIntern(), |
| ... | ... | @@ -17957,9 +17962,10 @@ fn typeInfoNamespaceDecls( |
| 17957 | 17962 | if (decl.kind != .named or !decl.is_pub) continue; |
| 17958 | 17963 | const name_val = v: { |
| 17959 | 17964 | // TODO: write something like getCoercedInts to avoid needing to dupe |
| 17960 | | const name = try sema.arena.dupe(u8, ip.stringToSlice(decl.name)); |
| 17965 | const name = try sema.arena.dupeZ(u8, ip.stringToSlice(decl.name)); |
| 17961 | 17966 | const new_decl_ty = try mod.arrayType(.{ |
| 17962 | 17967 | .len = name.len, |
| 17968 | .sentinel = .zero_u8, |
| 17963 | 17969 | .child = .u8_type, |
| 17964 | 17970 | }); |
| 17965 | 17971 | const new_decl_val = try mod.intern(.{ .aggregate = .{ |
| ... | ... | @@ -17967,9 +17973,9 @@ fn typeInfoNamespaceDecls( |
| 17967 | 17973 | .storage = .{ .bytes = name }, |
| 17968 | 17974 | } }); |
| 17969 | 17975 | break :v try mod.intern(.{ .ptr = .{ |
| 17970 | | .ty = .slice_const_u8_type, |
| 17976 | .ty = .slice_const_u8_sentinel_0_type, |
| 17971 | 17977 | .addr = .{ .anon_decl = .{ |
| 17972 | | .orig_ty = .slice_const_u8_type, |
| 17978 | .orig_ty = .slice_const_u8_sentinel_0_type, |
| 17973 | 17979 | .val = new_decl_val, |
| 17974 | 17980 | } }, |
| 17975 | 17981 | .len = (try mod.intValue(Type.usize, name.len)).toIntern(), |
| ... | ... | @@ -17977,7 +17983,7 @@ fn typeInfoNamespaceDecls( |
| 17977 | 17983 | }; |
| 17978 | 17984 | |
| 17979 | 17985 | const fields = .{ |
| 17980 | | //name: []const u8, |
| 17986 | //name: [:0]const u8, |
| 17981 | 17987 | name_val, |
| 17982 | 17988 | }; |
| 17983 | 17989 | try decl_vals.append(try mod.intern(.{ .aggregate = .{ |