]> git.lizzy.rs Git - uwu-lang.git/blobdiff - api/util.c
Add :ref module and refactor type handling
[uwu-lang.git] / api / util.c
diff --git a/api/util.c b/api/util.c
new file mode 100644 (file)
index 0000000..c3e8a38
--- /dev/null
@@ -0,0 +1,15 @@
+#include "../src/err.h"
+#include "util.h"
+#include "bool.h"
+
+UwUVMValue uwuutil_is_type(const char *fnname, UwUVMArgs *args, UwUVMType *type)
+{
+       if (args->num < 1)
+               error("error: %s requires at least one argument\n", fnname);
+
+       for (size_t i = 0; i < args->num; i++)
+               if (uwuvm_get_arg(args, i).type != type)
+                       return uwubool_create(false);
+
+       return uwubool_create(true);
+}