aboutsummaryrefslogtreecommitdiff
path: root/src/Air.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Air.zig')
-rw-r--r--src/Air.zig22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/Air.zig b/src/Air.zig
index 561ab86405..5a5070276c 100644
--- a/src/Air.zig
+++ b/src/Air.zig
@@ -1141,6 +1141,20 @@ pub const Inst = struct {
pub fn toType(ref: Ref) Type {
return .fromInterned(ref.toInterned().?);
}
+
+ pub fn fromIntern(ip_index: InternPool.Index) Ref {
+ return switch (ip_index) {
+ .none => .none,
+ else => {
+ assert(@intFromEnum(ip_index) >> 31 == 0);
+ return @enumFromInt(@as(u31, @intCast(@intFromEnum(ip_index))));
+ },
+ };
+ }
+
+ pub fn fromValue(v: Value) Ref {
+ return .fromIntern(v.toIntern());
+ }
};
/// All instructions have an 8-byte payload, which is contained within
@@ -1754,13 +1768,7 @@ pub fn deinit(air: *Air, gpa: std.mem.Allocator) void {
}
pub fn internedToRef(ip_index: InternPool.Index) Inst.Ref {
- return switch (ip_index) {
- .none => .none,
- else => {
- assert(@intFromEnum(ip_index) >> 31 == 0);
- return @enumFromInt(@as(u31, @intCast(@intFromEnum(ip_index))));
- },
- };
+ return .fromIntern(ip_index);
}
/// Returns `null` if runtime-known.