diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-06 20:22:52 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-06 20:22:52 +0200 |
| commit | 0d989d4b7c5507899721ae208b4ca605b4017e37 (patch) | |
| tree | a7a49ab182c000399e58112bb6d937b01d8f1998 /src/zisp/value.zig | |
| parent | afcc02f4f4af6cd462e20e0cecb20c35f1d9c198 (diff) | |
Cleanup.
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 ...) |
