aboutsummaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/shed/ints.h8
-rw-r--r--runtime/src/shed/namespaces/Shed/Builtins.c24
-rw-r--r--runtime/src/shed/shed.h1
3 files changed, 33 insertions, 0 deletions
diff --git a/runtime/src/shed/ints.h b/runtime/src/shed/ints.h
new file mode 100644
index 00000000..c99579d8
--- /dev/null
+++ b/runtime/src/shed/ints.h
@@ -0,0 +1,8 @@
+#ifndef SHED_INTS_H
+#define SHED_INTS_H
+
+#include "./primitives.h"
+
+PatioInt shed__runtime__int_value(ShedObject object);
+
+#endif
diff --git a/runtime/src/shed/namespaces/Shed/Builtins.c b/runtime/src/shed/namespaces/Shed/Builtins.c
index 142a1317..9efb4c62 100644
--- a/runtime/src/shed/namespaces/Shed/Builtins.c
+++ b/runtime/src/shed/namespaces/Shed/Builtins.c
@@ -24,8 +24,24 @@ ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString va
return shed_unit;
}
+void wasi_proc_exit(uint32_t exitcode)
+ __attribute__((
+ __import_module__("wasi_snapshot_preview1"),
+ __import_name__("proc_exit"),
+ ));
+
+ShedObject shed__runtime__namespace__Std__Process__exit(
+ ShedClosurePointer closurePointer,
+ ShedObject exitCode
+) {
+ wasi_proc_exit(shed__runtime__int_value(exitCode));
+ return shed_unit;
+}
+
#else
+#include <stdlib.h>
+
ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString value) {
size_t total_bytes_written = 0;
while (total_bytes_written < value->length) {
@@ -38,6 +54,14 @@ ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString va
return shed_unit;
}
+ShedObject shed__runtime__namespace__Std__Process__exit(
+ ShedClosurePointer closurePointer,
+ ShedObject exitCode
+) {
+ exit(shed__runtime__int_value(exitCode));
+ return shed_unit;
+}
+
#endif
ShedClosureStruct shed__runtime__print_closure = {
diff --git a/runtime/src/shed/shed.h b/runtime/src/shed/shed.h
index ff44cd9c..1730a79b 100644
--- a/runtime/src/shed/shed.h
+++ b/runtime/src/shed/shed.h
@@ -2,6 +2,7 @@
#define SHED_H
#include "./closures.h"
+#include "./ints.h"
#include "./primitives.h"
#include "./strings.h"