From 0272455c8bb06d5c63220172b2888510aeb7f40b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 18 Jun 2023 00:09:38 +0100 Subject: Hack together working HelloWorld compilation --- runtime/src/shed.c | 8 +++++++- runtime/src/shed.h | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'runtime/src') diff --git a/runtime/src/shed.c b/runtime/src/shed.c index 60d66e64..d2e4a72f 100644 --- a/runtime/src/shed.c +++ b/runtime/src/shed.c @@ -1,11 +1,16 @@ #include +#include #include #include "./shed.h" ShedObject const shed_unit = 0; -ShedObject shed__builtins__print(ShedEnv env, ShedString value) { +void* shed__runtime__alloc(uint64_t size) { + return malloc(size); +} + +ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString value) { size_t total_bytes_written = 0; while (total_bytes_written < value->length) { ssize_t bytes_written = write(STDOUT_FILENO, &value->data[total_bytes_written], value->length - total_bytes_written); @@ -16,3 +21,4 @@ ShedObject shed__builtins__print(ShedEnv env, ShedString value) { } return shed_unit; } + diff --git a/runtime/src/shed.h b/runtime/src/shed.h index 0c503db8..1fd8f44d 100644 --- a/runtime/src/shed.h +++ b/runtime/src/shed.h @@ -14,6 +14,22 @@ struct ShedString { typedef struct ShedString* ShedString; +struct ShedClosure { + void* function; + ShedObject freeVariables[]; +}; + +typedef struct ShedClosure ShedClosureStruct; + +typedef struct ShedClosure* ShedClosurePointer; + typedef ShedObject* ShedEnv; +ShedObject shed__runtime__print(ShedClosurePointer closurePointer, ShedString value); + +ShedClosureStruct shed__runtime__print_closure = { + .function = shed__runtime__print, + .freeVariables = {}, +}; + #endif -- cgit v1.2.3