diff options
Diffstat (limited to 'src/zisp/value.zig')
| -rw-r--r-- | src/zisp/value.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/zisp/value.zig b/src/zisp/value.zig index 4ecc70f..d39e225 100644 --- a/src/zisp/value.zig +++ b/src/zisp/value.zig @@ -153,17 +153,16 @@ const gc = @import("gc.zig"); pub const double = @import("value/double.zig"); pub const fixnum = @import("value/fixnum.zig"); -pub const ptr = @import("value/ptr.zig"); -pub const array = @import("value/array.zig"); - pub const rune = @import("value/rune.zig"); pub const char = @import("value/char.zig"); pub const misc = @import("value/misc.zig"); pub const sstr = @import("value/sstr.zig"); pub const boole = @import("value/boole.zig"); +pub const ptr = @import("value/ptr.zig"); pub const pair = @import("value/pair.zig"); pub const istr = @import("value/istr.zig"); +pub const array = @import("value/array.zig"); const endian = builtin.target.cpu.arch.endian(); @@ -216,6 +215,15 @@ pub const PtrTag = enum(u3) { array, /// Procedure proc, + + pub fn ptrType(self: PtrTag) type { + return switch (self) { + .pair => pair.PairPtr, + .istr => istr.IstrPtr, + .array => array.ArrayPtr, + else => @panic("not implemented"), + }; + } }; // Non-pointer high bits (sign=0,exp=MAX,quiet=0) but as a u13 field. @@ -395,7 +403,7 @@ pub const Value = packed union { /// the "high" pointer tags (49-51) that encode properties like weakness /// don't matter; we only care if it's some kind of valid heap pointer of /// the given type, so we only check the type tag in the low bits (0-2). - pub fn getPtr(v: Value, tag: PtrTag) ?Zptr { + pub fn getPtr(v: Value, comptime tag: PtrTag) ?tag.ptrType() { // Readable version: // // if (v.isPacked() and !v.ieee.sign and v.ieee.quiet ...) |
