]> git.lizzy.rs Git - uwu-lang.git/blob - std/ref.c
Add :ref module and refactor type handling
[uwu-lang.git] / std / ref.c
1 #include "../src/err.h"
2 #include "../api/ref.h"
3 #include "../api/util.h"
4
5 UwUVMValue uwu_call(UwUVMArgs *args)
6 {
7         if (args->num < 1)
8                 error(":ref:call requires at least one argument\n");
9
10         UwUVMValue value = uwuvm_get_arg(args, 0);
11
12         if (value.type != &uwuref_type)
13                 error(":ref:call requires a function reference as $0\n");
14
15         return uwuvm_call_function(value.data, args->num - 1, &args->unevaluated[1], args->super);
16 }
17
18 UwUVMValue uwu_is(UwUVMArgs *args)
19 {
20         return uwuutil_is_type(":ref:is", args, &uwuref_type);
21 }