diff options
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig index 9ca2822204..f53145a9d7 100644 --- a/src/type.zig +++ b/src/type.zig @@ -4,6 +4,7 @@ const Value = @import("value.zig").Value; const assert = std.debug.assert; const Target = std.Target; const Module = @import("Module.zig"); +const Zcu = Module; const log = std.log.scoped(.Type); const target_util = @import("target.zig"); const TypedValue = @import("TypedValue.zig"); @@ -3228,6 +3229,17 @@ pub const Type = struct { }; } + pub fn typeDeclInst(ty: Type, zcu: *const Zcu) ?InternPool.TrackedInst.Index { + return switch (zcu.intern_pool.indexToKey(ty.toIntern())) { + inline .struct_type, + .union_type, + .enum_type, + .opaque_type, + => |info| info.zir_index.unwrap(), + else => null, + }; + } + pub const @"u1": Type = .{ .ip_index = .u1_type }; pub const @"u8": Type = .{ .ip_index = .u8_type }; pub const @"u16": Type = .{ .ip_index = .u16_type }; |
