summaryrefslogtreecommitdiff
path: root/src/zisp/value.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/zisp/value.zig')
-rw-r--r--src/zisp/value.zig39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/zisp/value.zig b/src/zisp/value.zig
index 3450bfd..4ecc70f 100644
--- a/src/zisp/value.zig
+++ b/src/zisp/value.zig
@@ -272,6 +272,22 @@ pub const Value = packed union {
_: u13 = non_ptr,
},
+ /// For initializing and reading short strings.
+ sstr: packed struct {
+ // actually [6]u8 but packed struct cannot contain arrays
+ bytes: u48,
+ _tag: u3 = 0b001,
+ _: u13 = non_ptr,
+ },
+
+ /// For initializing and reading small rats (rational numbers).
+ srat: packed struct {
+ q: u24,
+ p: u25,
+ _tag: u2 = 0b01,
+ _: u13 = non_ptr,
+ },
+
// TODO: Use a general Small Value type registration mechanism.
/// For initializing and reading characters.
char: packed struct {
@@ -290,22 +306,6 @@ pub const Value = packed union {
_: u13 = non_ptr,
},
- /// For initializing and reading short strings.
- sstr: packed struct {
- // actually [6]u8 but packed struct cannot contain arrays
- string: u48,
- _tag: u3 = 0b001,
- _: u13 = non_ptr,
- },
-
- /// For initializing and reading small rats (rational numbers).
- srat: packed struct {
- q: u24,
- p: u25,
- _tag: u2 = 0b01,
- _: u13 = non_ptr,
- },
-
// Disjoint masks where a specific bit or bit-group are set.
// zig fmt: off
const mask_sign: u64 = 1 << 63 ; // 1 sign bit
@@ -329,7 +329,12 @@ pub const Value = packed union {
}
/// To treat the 64-bit value as an 8-byte array.
- pub fn bytes(v: *const Value) *const [8]u8 {
+ pub fn bufRO(v: *const Value) *const [8]u8 {
+ return @ptrCast(v);
+ }
+
+ /// To treat the 64-bit value as an 8-byte array.
+ pub fn bufRW(v: *Value) *[8]u8 {
return @ptrCast(v);
}