summaryrefslogtreecommitdiff
path: root/src/libzisp/value/seq.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/libzisp/value/seq.zig')
-rw-r--r--src/libzisp/value/seq.zig56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/libzisp/value/seq.zig b/src/libzisp/value/seq.zig
new file mode 100644
index 0000000..5382a7e
--- /dev/null
+++ b/src/libzisp/value/seq.zig
@@ -0,0 +1,56 @@
+const builtin = @import("builtin");
+const std = @import("std");
+
+const value = @import("../value.zig");
+const gc = @import("../gc.zig");
+
+const Value = value.Value;
+
+const Endian = enum(u1) {
+ little,
+ big,
+
+ const native: Endian = switch (builtin.target.cpu.arch.endian()) {
+ .little => .little,
+ .big => .big,
+ };
+};
+
+pub const Header = packed struct(u64) {
+ type: enum(u2) {
+ values,
+ string,
+ ints,
+ floats,
+ },
+ info: packed union {
+ values: packed struct(u14) {
+ weak: bool = false,
+ _: u13 = 0,
+ },
+ string: packed struct(u14) {
+ enc: enum(u4) { utf8, utf16, utf24, utf32 },
+ endian: Endian = .native,
+ quoted: bool,
+ interned: bool,
+ _: u7 = 0,
+ },
+ ints: packed struct(u14) {
+ signed: bool,
+ endian: Endian = .native,
+ size: u12,
+ },
+ floats: packed struct(u14) {
+ double: bool,
+ endian: Endian = .native,
+ _: u12 = 0,
+ },
+ },
+ size: u48,
+
+ pub fn bytes(self: *Header) []u8 {
+ const ptr: [*]u8 = @ptrCast(self);
+ const end = 8 + self.size;
+ return ptr[8..end];
+ }
+};