aboutsummaryrefslogtreecommitdiff
path: root/std/bool.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/bool.c
parent058d954e80f83c26deb209008f11d87a5b59418e (diff)
downloaduwu-lang-4c52777ca9e52edd0bff76168d886de9757ea457.tar.xz
Add :ref module and refactor type handling
Diffstat (limited to 'std/bool.c')
-rw-r--r--std/bool.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/std/bool.c b/std/bool.c
index 02aa887..4386dc3 100644
--- a/std/bool.c
+++ b/std/bool.c
@@ -2,8 +2,10 @@
#include <stdlib.h>
#include "../src/err.h"
#include "../api/vm.h"
+#include "../api/util.h"
#include "../api/bool.h"
+
static inline bool get_bool_arg(UwUVMArgs *args, size_t i)
{
return uwubool_get(uwuvm_get_arg(args, i));
@@ -14,7 +16,7 @@ UwUVMValue uwu_if(UwUVMArgs *args)
if (args->num != 3)
error("error: :bool:if requires exactly 3 arguments\n");
- return uwuvm_copy_value(get_bool_arg(args, 0)
+ return uwuvm_clone_value(get_bool_arg(args, 0)
? uwuvm_get_arg(args, 1)
: uwuvm_get_arg(args, 2)
);
@@ -84,12 +86,5 @@ UwUVMValue uwu_false(UwUVMArgs *args)
UwUVMValue uwu_is(UwUVMArgs *args)
{
- if (args->num < 1)
- error("error: :bool:is requires at least 1 argument\n");
-
- for (size_t i = 0; i < args->num; i++)
- if (uwuvm_get_arg(args, i).type != &uwubool_type)
- return uwubool_create(false);
-
- return uwubool_create(true);
+ return uwuutil_is_type(":bool:is", args, &uwubool_type);
}