authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-23 19:48:00-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-25 19:57:02-07:00
logf841b265c5523147f69127b968806454b64e1944
tree31eae5e7f743df5653a922d52e7969e58adafe64
parent426b5982d77fc78a736829f6b1b618eab6535fe1

Sema: move `@typeInfo` anon decls to new mechanism


1 files changed, 136 insertions(+), 173 deletions(-)

src/Sema.zig+136-173
...@@ -16813,9 +16813,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16813,9 +16813,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16813 .val = .void_value,16813 .val = .void_value,
16814 } }))),16814 } }))),
16815 .Fn => {16815 .Fn => {
16816 var params_anon_decl = try block.startAnonDecl();
16817 defer params_anon_decl.deinit();
16818
16819 const fn_info_decl_index = (try sema.namespaceLookup(16816 const fn_info_decl_index = (try sema.namespaceLookup(
16820 block,16817 block,
16821 src,16818 src,
...@@ -16872,23 +16869,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16872,23 +16869,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16872 .len = param_vals.len,16869 .len = param_vals.len,
16873 .child = param_info_ty.toIntern(),16870 .child = param_info_ty.toIntern(),
16874 });16871 });
16875 const new_decl = try params_anon_decl.finish(16872 const new_decl_val = try mod.intern(.{ .aggregate = .{
16876 new_decl_ty,16873 .ty = new_decl_ty.toIntern(),
16877 (try mod.intern(.{ .aggregate = .{16874 .storage = .{ .elems = param_vals },
16878 .ty = new_decl_ty.toIntern(),16875 } });
16879 .storage = .{ .elems = param_vals },16876 const ptr_ty = (try sema.ptrType(.{
16880 } })).toValue(),16877 .child = param_info_ty.toIntern(),
16881 .none, // default alignment16878 .flags = .{
16882 );16879 .size = .Slice,
16880 .is_const = true,
16881 },
16882 })).toIntern();
16883 break :v try mod.intern(.{ .ptr = .{16883 break :v try mod.intern(.{ .ptr = .{
16884 .ty = (try sema.ptrType(.{16884 .ty = ptr_ty,
16885 .child = param_info_ty.toIntern(),16885 .addr = .{ .anon_decl = .{
16886 .flags = .{16886 .orig_ty = ptr_ty,
16887 .size = .Slice,16887 .val = new_decl_val,
16888 .is_const = true,16888 } },
16889 },
16890 })).toIntern(),
16891 .addr = .{ .decl = new_decl },
16892 .len = (try mod.intValue(Type.usize, param_vals.len)).toIntern(),16889 .len = (try mod.intValue(Type.usize, param_vals.len)).toIntern(),
16893 } });16890 } });
16894 };16891 };
...@@ -17133,9 +17130,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17133,9 +17130,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17133 } })));17130 } })));
17134 },17131 },
17135 .ErrorSet => {17132 .ErrorSet => {
17136 var fields_anon_decl = try block.startAnonDecl();
17137 defer fields_anon_decl.deinit();
17138
17139 // Get the Error type17133 // Get the Error type
17140 const error_field_ty = t: {17134 const error_field_ty = t: {
17141 const set_field_ty_decl_index = (try sema.namespaceLookup(17135 const set_field_ty_decl_index = (try sema.namespaceLookup(
...@@ -17164,23 +17158,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17164,23 +17158,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17164 // TODO: write something like getCoercedInts to avoid needing to dupe17158 // TODO: write something like getCoercedInts to avoid needing to dupe
17165 const name = try sema.arena.dupe(u8, ip.stringToSlice(names.get(ip)[i]));17159 const name = try sema.arena.dupe(u8, ip.stringToSlice(names.get(ip)[i]));
17166 const name_val = v: {17160 const name_val = v: {
17167 var anon_decl = try block.startAnonDecl();
17168 defer anon_decl.deinit();
17169 const new_decl_ty = try mod.arrayType(.{17161 const new_decl_ty = try mod.arrayType(.{
17170 .len = name.len,17162 .len = name.len,
17171 .child = .u8_type,17163 .child = .u8_type,
17172 });17164 });
17173 const new_decl = try anon_decl.finish(17165 const new_decl_val = try mod.intern(.{ .aggregate = .{
17174 new_decl_ty,17166 .ty = new_decl_ty.toIntern(),
17175 (try mod.intern(.{ .aggregate = .{17167 .storage = .{ .bytes = name },
17176 .ty = new_decl_ty.toIntern(),17168 } });
17177 .storage = .{ .bytes = name },
17178 } })).toValue(),
17179 .none, // default alignment
17180 );
17181 break :v try mod.intern(.{ .ptr = .{17169 break :v try mod.intern(.{ .ptr = .{
17182 .ty = .slice_const_u8_type,17170 .ty = .slice_const_u8_type,
17183 .addr = .{ .decl = new_decl },17171 .addr = .{ .anon_decl = .{
17172 .val = new_decl_val,
17173 .orig_ty = .slice_const_u8_type,
17174 } },
17184 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),17175 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),
17185 } });17176 } });
17186 };17177 };
...@@ -17213,17 +17204,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17213,17 +17204,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17213 .len = vals.len,17204 .len = vals.len,
17214 .child = error_field_ty.toIntern(),17205 .child = error_field_ty.toIntern(),
17215 });17206 });
17216 const new_decl = try fields_anon_decl.finish(17207 const new_decl_val = try mod.intern(.{ .aggregate = .{
17217 array_errors_ty,17208 .ty = array_errors_ty.toIntern(),
17218 (try mod.intern(.{ .aggregate = .{17209 .storage = .{ .elems = vals },
17219 .ty = array_errors_ty.toIntern(),17210 } });
17220 .storage = .{ .elems = vals },
17221 } })).toValue(),
17222 .none, // default alignment
17223 );
17224 break :v try mod.intern(.{ .ptr = .{17211 break :v try mod.intern(.{ .ptr = .{
17225 .ty = slice_errors_ty.toIntern(),17212 .ty = slice_errors_ty.toIntern(),
17226 .addr = .{ .decl = new_decl },17213 .addr = .{ .anon_decl = .{
17214 .orig_ty = slice_errors_ty.toIntern(),
17215 .val = new_decl_val,
17216 } },
17227 .len = (try mod.intValue(Type.usize, vals.len)).toIntern(),17217 .len = (try mod.intValue(Type.usize, vals.len)).toIntern(),
17228 } });17218 } });
17229 } else .none;17219 } else .none;
...@@ -17271,9 +17261,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17271,9 +17261,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17271 .Enum => {17261 .Enum => {
17272 const is_exhaustive = Value.makeBool(ip.indexToKey(ty.toIntern()).enum_type.tag_mode != .nonexhaustive);17262 const is_exhaustive = Value.makeBool(ip.indexToKey(ty.toIntern()).enum_type.tag_mode != .nonexhaustive);
1727317263
17274 var fields_anon_decl = try block.startAnonDecl();
17275 defer fields_anon_decl.deinit();
17276
17277 const enum_field_ty = t: {17264 const enum_field_ty = t: {
17278 const enum_field_ty_decl_index = (try sema.namespaceLookup(17265 const enum_field_ty_decl_index = (try sema.namespaceLookup(
17279 block,17266 block,
...@@ -17301,23 +17288,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17301,23 +17288,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17301 // TODO: write something like getCoercedInts to avoid needing to dupe17288 // TODO: write something like getCoercedInts to avoid needing to dupe
17302 const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i]));17289 const name = try sema.arena.dupe(u8, ip.stringToSlice(enum_type.names.get(ip)[i]));
17303 const name_val = v: {17290 const name_val = v: {
17304 var anon_decl = try block.startAnonDecl();
17305 defer anon_decl.deinit();
17306 const new_decl_ty = try mod.arrayType(.{17291 const new_decl_ty = try mod.arrayType(.{
17307 .len = name.len,17292 .len = name.len,
17308 .child = .u8_type,17293 .child = .u8_type,
17309 });17294 });
17310 const new_decl = try anon_decl.finish(17295 const new_decl_val = try mod.intern(.{ .aggregate = .{
17311 new_decl_ty,17296 .ty = new_decl_ty.toIntern(),
17312 (try mod.intern(.{ .aggregate = .{17297 .storage = .{ .bytes = name },
17313 .ty = new_decl_ty.toIntern(),17298 } });
17314 .storage = .{ .bytes = name },
17315 } })).toValue(),
17316 .none, // default alignment
17317 );
17318 break :v try mod.intern(.{ .ptr = .{17299 break :v try mod.intern(.{ .ptr = .{
17319 .ty = .slice_const_u8_type,17300 .ty = .slice_const_u8_type,
17320 .addr = .{ .decl = new_decl },17301 .addr = .{ .anon_decl = .{
17302 .val = new_decl_val,
17303 .orig_ty = .slice_const_u8_type,
17304 } },
17321 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),17305 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),
17322 } });17306 } });
17323 };17307 };
...@@ -17339,23 +17323,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17339,23 +17323,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17339 .len = enum_field_vals.len,17323 .len = enum_field_vals.len,
17340 .child = enum_field_ty.toIntern(),17324 .child = enum_field_ty.toIntern(),
17341 });17325 });
17342 const new_decl = try fields_anon_decl.finish(17326 const new_decl_val = try mod.intern(.{ .aggregate = .{
17343 fields_array_ty,17327 .ty = fields_array_ty.toIntern(),
17344 (try mod.intern(.{ .aggregate = .{17328 .storage = .{ .elems = enum_field_vals },
17345 .ty = fields_array_ty.toIntern(),17329 } });
17346 .storage = .{ .elems = enum_field_vals },17330 const ptr_ty = (try sema.ptrType(.{
17347 } })).toValue(),17331 .child = enum_field_ty.toIntern(),
17348 .none, // default alignment17332 .flags = .{
17349 );17333 .size = .Slice,
17334 .is_const = true,
17335 },
17336 })).toIntern();
17350 break :v try mod.intern(.{ .ptr = .{17337 break :v try mod.intern(.{ .ptr = .{
17351 .ty = (try sema.ptrType(.{17338 .ty = ptr_ty,
17352 .child = enum_field_ty.toIntern(),17339 .addr = .{ .anon_decl = .{
17353 .flags = .{17340 .val = new_decl_val,
17354 .size = .Slice,17341 .orig_ty = ptr_ty,
17355 .is_const = true,17342 } },
17356 },
17357 })).toIntern(),
17358 .addr = .{ .decl = new_decl },
17359 .len = (try mod.intValue(Type.usize, enum_field_vals.len)).toIntern(),17343 .len = (try mod.intValue(Type.usize, enum_field_vals.len)).toIntern(),
17360 } });17344 } });
17361 };17345 };
...@@ -17395,9 +17379,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17395,9 +17379,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17395 } })));17379 } })));
17396 },17380 },
17397 .Union => {17381 .Union => {
17398 var fields_anon_decl = try block.startAnonDecl();
17399 defer fields_anon_decl.deinit();
17400
17401 const type_union_ty = t: {17382 const type_union_ty = t: {
17402 const type_union_ty_decl_index = (try sema.namespaceLookup(17383 const type_union_ty_decl_index = (try sema.namespaceLookup(
17403 block,17384 block,
...@@ -17435,23 +17416,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17435,23 +17416,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17435 // TODO: write something like getCoercedInts to avoid needing to dupe17416 // TODO: write something like getCoercedInts to avoid needing to dupe
17436 const name = try sema.arena.dupe(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i]));17417 const name = try sema.arena.dupe(u8, ip.stringToSlice(union_obj.field_names.get(ip)[i]));
17437 const name_val = v: {17418 const name_val = v: {
17438 var anon_decl = try block.startAnonDecl();
17439 defer anon_decl.deinit();
17440 const new_decl_ty = try mod.arrayType(.{17419 const new_decl_ty = try mod.arrayType(.{
17441 .len = name.len,17420 .len = name.len,
17442 .child = .u8_type,17421 .child = .u8_type,
17443 });17422 });
17444 const new_decl = try anon_decl.finish(17423 const new_decl_val = try mod.intern(.{ .aggregate = .{
17445 new_decl_ty,17424 .ty = new_decl_ty.toIntern(),
17446 (try mod.intern(.{ .aggregate = .{17425 .storage = .{ .bytes = name },
17447 .ty = new_decl_ty.toIntern(),17426 } });
17448 .storage = .{ .bytes = name },
17449 } })).toValue(),
17450 .none, // default alignment
17451 );
17452 break :v try mod.intern(.{ .ptr = .{17427 break :v try mod.intern(.{ .ptr = .{
17453 .ty = .slice_const_u8_type,17428 .ty = .slice_const_u8_type,
17454 .addr = .{ .decl = new_decl },17429 .addr = .{ .anon_decl = .{
17430 .val = new_decl_val,
17431 .orig_ty = .slice_const_u8_type,
17432 } },
17455 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),17433 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),
17456 } });17434 } });
17457 };17435 };
...@@ -17481,23 +17459,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17481,23 +17459,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17481 .len = union_field_vals.len,17459 .len = union_field_vals.len,
17482 .child = union_field_ty.toIntern(),17460 .child = union_field_ty.toIntern(),
17483 });17461 });
17484 const new_decl = try fields_anon_decl.finish(17462 const new_decl_val = try mod.intern(.{ .aggregate = .{
17485 array_fields_ty,17463 .ty = array_fields_ty.toIntern(),
17486 (try mod.intern(.{ .aggregate = .{17464 .storage = .{ .elems = union_field_vals },
17487 .ty = array_fields_ty.toIntern(),17465 } });
17488 .storage = .{ .elems = union_field_vals },17466 const ptr_ty = (try sema.ptrType(.{
17489 } })).toValue(),17467 .child = union_field_ty.toIntern(),
17490 .none, // default alignment17468 .flags = .{
17491 );17469 .size = .Slice,
17470 .is_const = true,
17471 },
17472 })).toIntern();
17492 break :v try mod.intern(.{ .ptr = .{17473 break :v try mod.intern(.{ .ptr = .{
17493 .ty = (try sema.ptrType(.{17474 .ty = ptr_ty,
17494 .child = union_field_ty.toIntern(),17475 .addr = .{ .anon_decl = .{
17495 .flags = .{17476 .orig_ty = ptr_ty,
17496 .size = .Slice,17477 .val = new_decl_val,
17497 .is_const = true,17478 } },
17498 },
17499 })).toIntern(),
17500 .addr = .{ .decl = new_decl },
17501 .len = (try mod.intValue(Type.usize, union_field_vals.len)).toIntern(),17479 .len = (try mod.intValue(Type.usize, union_field_vals.len)).toIntern(),
17502 } });17480 } });
17503 };17481 };
...@@ -17543,9 +17521,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17543,9 +17521,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17543 } })));17521 } })));
17544 },17522 },
17545 .Struct => {17523 .Struct => {
17546 var fields_anon_decl = try block.startAnonDecl();
17547 defer fields_anon_decl.deinit();
17548
17549 const type_struct_ty = t: {17524 const type_struct_ty = t: {
17550 const type_struct_ty_decl_index = (try sema.namespaceLookup(17525 const type_struct_ty_decl_index = (try sema.namespaceLookup(
17551 block,17526 block,
...@@ -17585,8 +17560,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17585,8 +17560,6 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17585 const field_ty = anon_struct_type.types.get(ip)[i];17560 const field_ty = anon_struct_type.types.get(ip)[i];
17586 const field_val = anon_struct_type.values.get(ip)[i];17561 const field_val = anon_struct_type.values.get(ip)[i];
17587 const name_val = v: {17562 const name_val = v: {
17588 var anon_decl = try block.startAnonDecl();
17589 defer anon_decl.deinit();
17590 // TODO: write something like getCoercedInts to avoid needing to dupe17563 // TODO: write something like getCoercedInts to avoid needing to dupe
17591 const bytes = if (tuple.names.len != 0)17564 const bytes = if (tuple.names.len != 0)
17592 // https://github.com/ziglang/zig/issues/1570917565 // https://github.com/ziglang/zig/issues/15709
...@@ -17597,17 +17570,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17597,17 +17570,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17597 .len = bytes.len,17570 .len = bytes.len,
17598 .child = .u8_type,17571 .child = .u8_type,
17599 });17572 });
17600 const new_decl = try anon_decl.finish(17573 const new_decl_val = try mod.intern(.{ .aggregate = .{
17601 new_decl_ty,17574 .ty = new_decl_ty.toIntern(),
17602 (try mod.intern(.{ .aggregate = .{17575 .storage = .{ .bytes = bytes },
17603 .ty = new_decl_ty.toIntern(),17576 } });
17604 .storage = .{ .bytes = bytes },
17605 } })).toValue(),
17606 .none, // default alignment
17607 );
17608 break :v try mod.intern(.{ .ptr = .{17577 break :v try mod.intern(.{ .ptr = .{
17609 .ty = .slice_const_u8_type,17578 .ty = .slice_const_u8_type,
17610 .addr = .{ .decl = new_decl },17579 .addr = .{ .anon_decl = .{
17580 .val = new_decl_val,
17581 .orig_ty = .slice_const_u8_type,
17582 } },
17611 .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(),17583 .len = (try mod.intValue(Type.usize, bytes.len)).toIntern(),
17612 } });17584 } });
17613 };17585 };
...@@ -17651,23 +17623,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17651,23 +17623,20 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17651 const field_init = struct_type.fieldInit(ip, i);17623 const field_init = struct_type.fieldInit(ip, i);
17652 const field_is_comptime = struct_type.fieldIsComptime(ip, i);17624 const field_is_comptime = struct_type.fieldIsComptime(ip, i);
17653 const name_val = v: {17625 const name_val = v: {
17654 var anon_decl = try block.startAnonDecl();
17655 defer anon_decl.deinit();
17656 const new_decl_ty = try mod.arrayType(.{17626 const new_decl_ty = try mod.arrayType(.{
17657 .len = name.len,17627 .len = name.len,
17658 .child = .u8_type,17628 .child = .u8_type,
17659 });17629 });
17660 const new_decl = try anon_decl.finish(17630 const new_decl_val = try mod.intern(.{ .aggregate = .{
17661 new_decl_ty,17631 .ty = new_decl_ty.toIntern(),
17662 (try mod.intern(.{ .aggregate = .{17632 .storage = .{ .bytes = name },
17663 .ty = new_decl_ty.toIntern(),17633 } });
17664 .storage = .{ .bytes = name },
17665 } })).toValue(),
17666 .none, // default alignment
17667 );
17668 break :v try mod.intern(.{ .ptr = .{17634 break :v try mod.intern(.{ .ptr = .{
17669 .ty = .slice_const_u8_type,17635 .ty = .slice_const_u8_type,
17670 .addr = .{ .decl = new_decl },17636 .addr = .{ .anon_decl = .{
17637 .val = new_decl_val,
17638 .orig_ty = .slice_const_u8_type,
17639 } },
17671 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),17640 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),
17672 } });17641 } });
17673 };17642 };
...@@ -17707,23 +17676,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17707,23 +17676,23 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17707 .len = struct_field_vals.len,17676 .len = struct_field_vals.len,
17708 .child = struct_field_ty.toIntern(),17677 .child = struct_field_ty.toIntern(),
17709 });17678 });
17710 const new_decl = try fields_anon_decl.finish(17679 const new_decl_val = try mod.intern(.{ .aggregate = .{
17711 array_fields_ty,17680 .ty = array_fields_ty.toIntern(),
17712 (try mod.intern(.{ .aggregate = .{17681 .storage = .{ .elems = struct_field_vals },
17713 .ty = array_fields_ty.toIntern(),17682 } });
17714 .storage = .{ .elems = struct_field_vals },17683 const ptr_ty = (try sema.ptrType(.{
17715 } })).toValue(),17684 .child = struct_field_ty.toIntern(),
17716 .none, // default alignment17685 .flags = .{
17717 );17686 .size = .Slice,
17687 .is_const = true,
17688 },
17689 })).toIntern();
17718 break :v try mod.intern(.{ .ptr = .{17690 break :v try mod.intern(.{ .ptr = .{
17719 .ty = (try sema.ptrType(.{17691 .ty = ptr_ty,
17720 .child = struct_field_ty.toIntern(),17692 .addr = .{ .anon_decl = .{
17721 .flags = .{17693 .orig_ty = ptr_ty,
17722 .size = .Slice,17694 .val = new_decl_val,
17723 .is_const = true,17695 } },
17724 },
17725 })).toIntern(),
17726 .addr = .{ .decl = new_decl },
17727 .len = (try mod.intValue(Type.usize, struct_field_vals.len)).toIntern(),17696 .len = (try mod.intValue(Type.usize, struct_field_vals.len)).toIntern(),
17728 } });17697 } });
17729 };17698 };
...@@ -17819,9 +17788,6 @@ fn typeInfoDecls(...@@ -17819,9 +17788,6 @@ fn typeInfoDecls(
17819 const mod = sema.mod;17788 const mod = sema.mod;
17820 const gpa = sema.gpa;17789 const gpa = sema.gpa;
1782117790
17822 var decls_anon_decl = try block.startAnonDecl();
17823 defer decls_anon_decl.deinit();
17824
17825 const declaration_ty = t: {17791 const declaration_ty = t: {
17826 const declaration_ty_decl_index = (try sema.namespaceLookup(17792 const declaration_ty_decl_index = (try sema.namespaceLookup(
17827 block,17793 block,
...@@ -17851,23 +17817,23 @@ fn typeInfoDecls(...@@ -17851,23 +17817,23 @@ fn typeInfoDecls(
17851 .len = decl_vals.items.len,17817 .len = decl_vals.items.len,
17852 .child = declaration_ty.toIntern(),17818 .child = declaration_ty.toIntern(),
17853 });17819 });
17854 const new_decl = try decls_anon_decl.finish(17820 const new_decl_val = try mod.intern(.{ .aggregate = .{
17855 array_decl_ty,17821 .ty = array_decl_ty.toIntern(),
17856 (try mod.intern(.{ .aggregate = .{17822 .storage = .{ .elems = decl_vals.items },
17857 .ty = array_decl_ty.toIntern(),17823 } });
17858 .storage = .{ .elems = decl_vals.items },17824 const ptr_ty = (try sema.ptrType(.{
17859 } })).toValue(),17825 .child = declaration_ty.toIntern(),
17860 .none, // default alignment17826 .flags = .{
17861 );17827 .size = .Slice,
17828 .is_const = true,
17829 },
17830 })).toIntern();
17862 return try mod.intern(.{ .ptr = .{17831 return try mod.intern(.{ .ptr = .{
17863 .ty = (try sema.ptrType(.{17832 .ty = ptr_ty,
17864 .child = declaration_ty.toIntern(),17833 .addr = .{ .anon_decl = .{
17865 .flags = .{17834 .orig_ty = ptr_ty,
17866 .size = .Slice,17835 .val = new_decl_val,
17867 .is_const = true,17836 } },
17868 },
17869 })).toIntern(),
17870 .addr = .{ .decl = new_decl },
17871 .len = (try mod.intValue(Type.usize, decl_vals.items.len)).toIntern(),17837 .len = (try mod.intValue(Type.usize, decl_vals.items.len)).toIntern(),
17872 } });17838 } });
17873}17839}
...@@ -17896,25 +17862,22 @@ fn typeInfoNamespaceDecls(...@@ -17896,25 +17862,22 @@ fn typeInfoNamespaceDecls(
17896 }17862 }
17897 if (decl.kind != .named or !decl.is_pub) continue;17863 if (decl.kind != .named or !decl.is_pub) continue;
17898 const name_val = v: {17864 const name_val = v: {
17899 var anon_decl = try block.startAnonDecl();
17900 defer anon_decl.deinit();
17901 // TODO: write something like getCoercedInts to avoid needing to dupe17865 // TODO: write something like getCoercedInts to avoid needing to dupe
17902 const name = try sema.arena.dupe(u8, ip.stringToSlice(decl.name));17866 const name = try sema.arena.dupe(u8, ip.stringToSlice(decl.name));
17903 const new_decl_ty = try mod.arrayType(.{17867 const new_decl_ty = try mod.arrayType(.{
17904 .len = name.len,17868 .len = name.len,
17905 .child = .u8_type,17869 .child = .u8_type,
17906 });17870 });
17907 const new_decl = try anon_decl.finish(17871 const new_decl_val = try mod.intern(.{ .aggregate = .{
17908 new_decl_ty,17872 .ty = new_decl_ty.toIntern(),
17909 (try mod.intern(.{ .aggregate = .{17873 .storage = .{ .bytes = name },
17910 .ty = new_decl_ty.toIntern(),17874 } });
17911 .storage = .{ .bytes = name },
17912 } })).toValue(),
17913 .none, // default alignment
17914 );
17915 break :v try mod.intern(.{ .ptr = .{17875 break :v try mod.intern(.{ .ptr = .{
17916 .ty = .slice_const_u8_type,17876 .ty = .slice_const_u8_type,
17917 .addr = .{ .decl = new_decl },17877 .addr = .{ .anon_decl = .{
17878 .orig_ty = .slice_const_u8_type,
17879 .val = new_decl_val,
17880 } },
17918 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),17881 .len = (try mod.intValue(Type.usize, name.len)).toIntern(),
17919 } });17882 } });
17920 };17883 };