aboutsummaryrefslogtreecommitdiff
path: root/src/z/Env/value.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-05 15:33:46 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-05 15:33:46 +0200
commit02582cc490fc0d753dd153211cc172eb28fbee5d (patch)
tree4add149d5e1ecf28cf20ecb497626fef85cdbd75 /src/z/Env/value.zig
parent2f3199622d9e7a97da4b5c31a2d81b170b7cdaa6 (diff)
first sketch of wasm environment
Diffstat (limited to 'src/z/Env/value.zig')
-rw-r--r--src/z/Env/value.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/z/Env/value.zig b/src/z/Env/value.zig
new file mode 100644
index 0000000..4630a76
--- /dev/null
+++ b/src/z/Env/value.zig
@@ -0,0 +1,36 @@
+pub const Value = extern struct {
+ kind: Kind,
+ value: extern union {
+ object: u32,
+ string: extern struct {
+ ptr: [*]const u8,
+ len: usize,
+ },
+ int: isize,
+ uint: usize,
+ float: f64,
+ undefined: void,
+ },
+
+ pub const Kind = enum(u8) {
+ uninit = 0,
+ object = 1,
+ string = 2,
+ int = 3,
+ uint = 4,
+ float = 5,
+ undefined = 6,
+
+ pub fn asType(comptime self: Kind) type {
+ return switch (self) {
+ .object => return u32,
+ .string => return []const u8,
+ .int => return isize,
+ .uint => return usize,
+ .float => f64,
+ .undefined => return void,
+ .uninit => @compileError("uninit has no associated type."),
+ };
+ }
+ };
+};