const std = @import("std"); const gc = @import("../gc.zig"); const value = @import("../value.zig"); const HeapType = value.HeapType; const Value = value.Value; const Zptr = value.Zptr; const max = std.math.maxInt; // Zig API pub fn check(v: Value) bool { return v.isPtrAny(); } pub fn assert(v: Value) void { if (!check(v)) { v.dump(); @panic("not pointer"); } } pub fn pack(comptime ht: HeapType, ptr: ht.PtrType()) Value { const index: u44 = @intCast(@intFromPtr(ptr) >> 4); return .{ .ptr = .{ .index = index, .htype = ht } }; } pub fn unpack(v: Value) struct { Zptr, HeapType } { assert(v); return v.getPtrAny() orelse unreachable; }