diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-22 18:22:36 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-22 18:22:36 +0200 |
| commit | 476632d9559b1e3bacbd226df336116cac8544ea (patch) | |
| tree | 5ad54d955ca676033538c9e93828093f039239d1 /src/zisp/value.zig | |
| parent | 0245f1c238b232834a1a1b76d660aa3b626d832f (diff) | |
Improvements.
Diffstat (limited to 'src/zisp/value.zig')
| -rw-r--r-- | src/zisp/value.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/zisp/value.zig b/src/zisp/value.zig index 4ce6cd2..2ae0524 100644 --- a/src/zisp/value.zig +++ b/src/zisp/value.zig @@ -269,16 +269,16 @@ pub const Value = packed union { } /// Checks for a pointer and returns the value and tag separately, or null - /// if this isn't a pointer or null. Could be useful for a dispatch table. - pub fn getPtrAny(v: Value) ?struct { Zptr, HeapType } { + /// if this isn't a pointer at all. Could be useful for a dispatch table. + /// Note that unlike getPtr(), this can actually return a null pointer as + /// such, not conflating it with the "not a heap pointer" case. + pub fn getPtrAny(v: Value) ?struct { ?Zptr, HeapType } { const hi16_bits: u16 = @intCast(v.bits >> 48); if (hi16_bits != hi16_tag_ptr) return null; - const ptr_val: u48 = @intCast(v.bits << 20 >> 16); - if (ptr_val == 0) return null; - - const ht_val: u4 = @intCast(v.bits << 16 >> 60); - return .{ @ptrFromInt(ptr_val), @enumFromInt(ht_val) }; + const ht: u4 = @truncate(hi16_bits); + const pval: u48 = @intCast(v.bits << 20 >> 16); + return .{ @ptrFromInt(pval), @enumFromInt(ht) }; } /// Checks if the value is a list pointer. |
