From 13437e49bc0e4f87296b9c3ac7010ef1bd7f7ef5 Mon Sep 17 00:00:00 2001 From: able Date: Thu, 7 Sep 2023 14:18:47 -0500 Subject: [PATCH] STDLib work --- assets/libraries/std/ecalls.rhea | 20 ++++++++++++++++++++ assets/libraries/std/std.rhea | 2 ++ assets/libraries/std/terminal.rhea | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 assets/libraries/std/ecalls.rhea create mode 100644 assets/libraries/std/terminal.rhea diff --git a/assets/libraries/std/ecalls.rhea b/assets/libraries/std/ecalls.rhea new file mode 100644 index 0000000..c884f9d --- /dev/null +++ b/assets/libraries/std/ecalls.rhea @@ -0,0 +1,20 @@ + +var (error,warn,info,debug,trace) = io.log.(error,warn,info,debug,trace); + + + +// TODO: define and add in IDL shenanigans for a proper IPC Protocol +func make_ipc_buffer(bounded: bool, length: u64) { + match bounded{ + true -> match length { + 0 -> error("Bound array has length of zero") + } + } + + asm { + li r254, bounded + li r253, length + } + // Return a pointer to a memory address with `length` + return (123, 456); +} \ No newline at end of file diff --git a/assets/libraries/std/std.rhea b/assets/libraries/std/std.rhea index 468fd3b..c38ee45 100644 --- a/assets/libraries/std/std.rhea +++ b/assets/libraries/std/std.rhea @@ -1,4 +1,6 @@ var io = include "io"; + var math = include "math"; +var ecalls = include "ecalls"; var print = io.print; \ No newline at end of file diff --git a/assets/libraries/std/terminal.rhea b/assets/libraries/std/terminal.rhea new file mode 100644 index 0000000..53c38d5 --- /dev/null +++ b/assets/libraries/std/terminal.rhea @@ -0,0 +1,20 @@ +var ecalls = include "ecalls"; +var make_ipc_buffer = ecalls.make_ipc_buffer; + +var terminal; +terminal.init = terminal_init; +terminal.write = terminal_write; + +func terminal_init(){ + // setup a buffer with the TextIO protocol + var buffer = make_ipc_buffer(false, 0); + terminal.buffer = buffer; +} + +func terminal_write(value: String){ + // TODO: write value into buffer according to TextIO protocol + + + +} +