aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-02-17 03:34:47 +0000
committermlugg <mlugg@mlugg.co.uk>2024-03-06 21:26:37 +0000
commit8ec6f730eff1f6008b7eba1c749824a4a5734e5f (patch)
tree34cf9c0ef9ab1d5ee6338984440deb1db1d7ec2e /src/type.zig
parent975b859377dee450418ae9ed572ec9d3c0b77312 (diff)
downloadzig-8ec6f730eff1f6008b7eba1c749824a4a5734e5f.tar.gz
zig-8ec6f730eff1f6008b7eba1c749824a4a5734e5f.zip
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.
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig12
1 files changed, 12 insertions, 0 deletions
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 };