aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile2
-rw-r--r--doc/std.md4
-rw-r--r--example/test.uwu3
-rw-r--r--std/bool.c1
-rw-r--r--std/int.c2
-rw-r--r--std/nil.c10
7 files changed, 21 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index c6127b3..0154d1f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,3 +50,6 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf
+
+# Executable
+uwu
diff --git a/Makefile b/Makefile
index f218bdb..8dbf5d8 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ uwu: src/*.c src/*.h
.PHONY: std api
-std: std/bool.so std/int.so std/str.so
+std: std/bool.so std/int.so std/str.so std/nil.so
api: api/api.so
std/%.so: std/%.c
diff --git a/doc/std.md b/doc/std.md
index 1ebd6db..debf460 100644
--- a/doc/std.md
+++ b/doc/std.md
@@ -1,5 +1,9 @@
# Standard library
+## The `:nil` module
+
+- `:nil:nil`: The nil constant
+
## The `:bool` module
- `:bool:if`: Requires exactly 3 arguments of arbitrary type. If $0 is a truthy value, evaluate and return $1. If $0 is a falsy value, evaluate and return $2. Values considered as falsy are: `:bool:false` and `:nil:nil`. Everything else is considered truey.
diff --git a/example/test.uwu b/example/test.uwu
index 375a03f..081eb69 100644
--- a/example/test.uwu
+++ b/example/test.uwu
@@ -3,5 +3,6 @@ hello_world "hello world
main :str:cat(
hello_world,
- fibo:print(10)
+ fibo:print(10),
+ :nil:nil
)
diff --git a/std/bool.c b/std/bool.c
index 80aade5..76772bf 100644
--- a/std/bool.c
+++ b/std/bool.c
@@ -9,7 +9,6 @@ static inline bool get_bool_arg(UwUVMArgs *args, size_t i)
return uwubool_get(uwuvm_get_arg(args, i));
}
-#include "../api/str.h"
UwUVMValue uwu_if(UwUVMArgs *args)
{
if (args->num != 3)
diff --git a/std/int.c b/std/int.c
index 48c808b..dfc436c 100644
--- a/std/int.c
+++ b/std/int.c
@@ -80,7 +80,7 @@ static int reduce(const char *fnname, UwUVMArgs *args, ReduceOP op, int result)
UwUVMValue uwu_add(UwUVMArgs *args)
{
- return uwuint_create(reduce(":int:mul", args, ROP_ADD, 0));
+ return uwuint_create(reduce(":int:add", args, ROP_ADD, 0));
}
UwUVMValue uwu_sub(UwUVMArgs *args)
diff --git a/std/nil.c b/std/nil.c
new file mode 100644
index 0000000..33230fb
--- /dev/null
+++ b/std/nil.c
@@ -0,0 +1,10 @@
+#include "../src/err.h"
+#include "../api/nil.h"
+
+UwUVMValue uwu_nil(UwUVMArgs *args)
+{
+ if (args->num != 0)
+ error(":nil:nil does not accept any arguments\n");
+
+ return uwunil_create();
+}