diff options
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 }; +} |