diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/InternPool.zig | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index c5eaa41ead..2fb0b11088 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -3859,7 +3859,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .func_decl => .{ .func = ip.extraFuncDecl(data) }, .func_coerced => .{ .func = ip.extraFuncCoerced(data) }, .only_possible_value => { - const ty = @as(Index, @enumFromInt(data)); + const ty: Index = @enumFromInt(data); const ty_item = ip.items.get(@intFromEnum(ty)); return switch (ty_item.tag) { .type_array_big => { @@ -3872,22 +3872,35 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .storage = .{ .elems = sentinel[0..@intFromBool(sentinel[0] != .none)] }, } }; }, - .type_array_small, .type_vector => .{ .aggregate = .{ - .ty = ty, - .storage = .{ .elems = &.{} }, - } }, - // TODO: migrate structs to properly use the InternPool rather - // than using the SegmentedList trick, then the struct type will - // have a slice of comptime values that can be used here for when - // the struct has one possible value due to all fields comptime (same - // as the tuple case below). - .type_struct, .type_struct_ns => .{ .aggregate = .{ + .type_array_small, + .type_vector, + .type_struct_ns, + .type_struct_packed, + => .{ .aggregate = .{ .ty = ty, .storage = .{ .elems = &.{} }, } }, // There is only one possible value precisely due to the // fact that this values slice is fully populated! + .type_struct => { + const info = extraStructType(ip, ty_item.data); + return .{ .aggregate = .{ + .ty = ty, + .storage = .{ .elems = @ptrCast(info.field_inits.get(ip)) }, + } }; + }, + + .type_struct_packed_inits => { + const info = extraPackedStructType(ip, ty_item.data, true); + return .{ .aggregate = .{ + .ty = ty, + .storage = .{ .elems = @ptrCast(info.field_inits.get(ip)) }, + } }; + }, + + // There is only one possible value precisely due to the + // fact that this values slice is fully populated! .type_struct_anon, .type_tuple_anon => { const type_struct_anon = ip.extraDataTrail(TypeStructAnon, ty_item.data); const fields_len = type_struct_anon.data.fields_len; @@ -3898,11 +3911,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { } }; }, - .type_struct_packed, .type_struct_packed_inits => { - // a packed struct has a 0-bit backing type - @panic("TODO"); - }, - .type_enum_auto, .type_enum_explicit, .type_union, |
