diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-17 10:13:13 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-17 10:13:13 +0200 |
| commit | b1b4df39abb41a4ae71733e2d139dc70cc71acd8 (patch) | |
| tree | 3d72b1dd75841e0b950282099ec9c837aa03d869 /src/zilch/Callable.zig | |
| parent | dd24e86dad0402917b1713d1afeefaf65c3d1e51 (diff) | |
zilch: implement callable and promise
Diffstat (limited to 'src/zilch/Callable.zig')
| -rw-r--r-- | src/zilch/Callable.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/zilch/Callable.zig b/src/zilch/Callable.zig new file mode 100644 index 0000000..6732c69 --- /dev/null +++ b/src/zilch/Callable.zig @@ -0,0 +1,27 @@ +const mod = @import("root.zig"); +const Options = mod.Options; +const Env = mod.Env; +const AnyFuture = Env.AnyFuture; +const Function = Env.Function; + +const Self = @This(); + +pub inline fn call(self: *Self, env: *Env, args: anytype) AnyFuture { + return env.call(bindings.call, .{ self } ++ args); +} + +pub const bindings = struct { + pub const call: Function = .from( + \\function(target, ...args) { + \\ return target(...args); + \\} + ); +}; + +pub const functions = [_]Function{ + bindings.call, +}; + +pub fn global(tag: @EnumLiteral()) Options.Global { + return .{ .name = @tagName(tag), .type = *Self }; +} |