mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
InternPool: implement only_possible_value prong of indexToKey
for the new struct and packed struct encodings.
This commit is contained in:
parent
b65f3d8826
commit
483b3a3344
@ -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,20 +3872,33 @@ 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 => {
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user