aboutsummaryrefslogtreecommitdiff
path: root/std/ref.c
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-12-30 16:53:37 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-12-30 16:53:37 +0100
commit4c52777ca9e52edd0bff76168d886de9757ea457 (patch)
tree385c548fbae43f4b4764a1c32d5babe60c84aa4d /std/ref.c
parent058d954e80f83c26deb209008f11d87a5b59418e (diff)
downloaduwu-lang-4c52777ca9e52edd0bff76168d886de9757ea457.tar.xz
Add :ref module and refactor type handling
Diffstat (limited to 'std/ref.c')
-rw-r--r--std/ref.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/std/ref.c b/std/ref.c
new file mode 100644
index 0000000..f82bb50
--- /dev/null
+++ b/std/ref.c
@@ -0,0 +1,21 @@
+#include "../src/err.h"
+#include "../api/ref.h"
+#include "../api/util.h"
+
+UwUVMValue uwu_call(UwUVMArgs *args)
+{
+ if (args->num < 1)
+ error(":ref:call requires at least one argument\n");
+
+ UwUVMValue value = uwuvm_get_arg(args, 0);
+
+ if (value.type != &uwuref_type)
+ error(":ref:call requires a function reference as $0\n");
+
+ return uwuvm_call_function(value.data, args->num - 1, &args->unevaluated[1], args->super);
+}
+
+UwUVMValue uwu_is(UwUVMArgs *args)
+{
+ return uwuutil_is_type(":ref:is", args, &uwuref_type);
+}