From 8ec6f730eff1f6008b7eba1c749824a4a5734e5f Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 17 Feb 2024 03:34:47 +0000 Subject: compiler: represent captures directly in InternPool These were previously associated with the type's namespace, but we need to store them directly in the InternPool for #18816. --- src/type.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/type.zig') diff --git a/src/type.zig b/src/type.zig index 2021a1aaea..d19ad6f02e 100644 --- a/src/type.zig +++ b/src/type.zig @@ -3294,6 +3294,18 @@ pub const Type = struct { }; } + /// Given a namespace type, returns its list of caotured values. + pub fn getCaptures(ty: Type, zcu: *const Zcu) InternPool.CaptureValue.Slice { + const ip = &zcu.intern_pool; + return switch (ip.indexToKey(ty.toIntern())) { + .struct_type => ip.loadStructType(ty.toIntern()).captures, + .union_type => ip.loadUnionType(ty.toIntern()).captures, + .enum_type => ip.loadEnumType(ty.toIntern()).captures, + .opaque_type => ip.loadOpaqueType(ty.toIntern()).captures, + else => unreachable, + }; + } + pub const @"u1": Type = .{ .ip_index = .u1_type }; pub const @"u8": Type = .{ .ip_index = .u8_type }; pub const @"u16": Type = .{ .ip_index = .u16_type }; -- cgit v1.2.3