From 02582cc490fc0d753dd153211cc172eb28fbee5d Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Mon, 5 Oct 2026 15:33:46 +0200 Subject: first sketch of wasm environment --- src/z/Env/Future.zig | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/z/Env/Future.zig (limited to 'src/z/Env/Future.zig') diff --git a/src/z/Env/Future.zig b/src/z/Env/Future.zig new file mode 100644 index 0000000..17266b9 --- /dev/null +++ b/src/z/Env/Future.zig @@ -0,0 +1,29 @@ +const std = @import("std"); +const Env = @import("root.zig"); + +const Self = @This(); + +result: *Env.Value, + +pub fn await(self: *Self, env: *Env, comptime kind: Env.Value.Kind) kind.asType() { + const result = self.awaitAny(env); + std.debug.assert(kind == result.kind); + + return switch (kind) { + .uninit => @panic("uninitialized result"), + .string => result.value.string.ptr[0..result.value.string.len], + else => @field(result.value, @tagName(kind)), + }; +} + +pub fn awaitAny(self: *Self, env: *Env) Env.Value { + defer env.pool.destroy(self.result); + + if (self.result.kind != .uninit) { + return self.result.*; + } + + env.flush(); + + return self.result.*; +} -- cgit v1.2.3-70-g09d2