aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/Callable.zig
blob: 6732c69ee477d18b2c5290d2499be45c076730df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 };
}