From: Brendan Hansen Date: Tue, 2 Jun 2020 21:03:42 +0000 (-0500) Subject: Bug fixes; preparing to start WASM code gen X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=c5b8646d47effe57e455ead5e3af2aeae8afbcb3;p=onyx.git Bug fixes; preparing to start WASM code gen --- diff --git a/.gitignore b/.gitignore index 97c16aa3..cd217661 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ **/*.o *.o +tags diff --git a/.vimspector.json b/.vimspector.json index 72e3a7ab..a52e2a69 100644 --- a/.vimspector.json +++ b/.vimspector.json @@ -6,7 +6,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/onyx", - "args": ["progs/mvp.onyx"], + "args": ["progs/minimal.onyx"], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], diff --git a/include/bh.h b/include/bh.h index 95772a75..d669d554 100644 --- a/include/bh.h +++ b/include/bh.h @@ -315,7 +315,7 @@ i64 bh_file_size(bh_file* file); bh_file_contents bh_file_read_contents_bh_file(bh_allocator alloc, bh_file* file); bh_file_contents bh_file_read_contents_direct(bh_allocator alloc, const char* filename); -i32 bh_file_contents_delete(bh_file_contents* contents); +i32 bh_file_contents_free(bh_file_contents* contents); #endif @@ -1197,7 +1197,7 @@ bh_file_contents bh_file_read_contents_direct(bh_allocator alloc, const char* fi return fc; } -b32 bh_file_contents_delete(bh_file_contents* contents) { +b32 bh_file_contents_free(bh_file_contents* contents) { bh_free(contents->allocator, contents->data); contents->length = 0; return 1; diff --git a/include/onyxparser.h b/include/onyxparser.h index b2496f69..d61f5b19 100644 --- a/include/onyxparser.h +++ b/include/onyxparser.h @@ -77,13 +77,9 @@ typedef enum OnyxTypeInfoKind { ONYX_TYPE_INFO_KIND_VOID, ONYX_TYPE_INFO_KIND_BOOL, - ONYX_TYPE_INFO_KIND_UINT8, - ONYX_TYPE_INFO_KIND_UINT16, ONYX_TYPE_INFO_KIND_UINT32, ONYX_TYPE_INFO_KIND_UINT64, - ONYX_TYPE_INFO_KIND_INT8, - ONYX_TYPE_INFO_KIND_INT16, ONYX_TYPE_INFO_KIND_INT32, ONYX_TYPE_INFO_KIND_INT64, diff --git a/include/onyxwasm.h b/include/onyxwasm.h new file mode 100644 index 00000000..2fb91f01 --- /dev/null +++ b/include/onyxwasm.h @@ -0,0 +1,22 @@ +#ifndef ONYXWASM_H +#define ONYXWASM_H + +#define BH_NO_STRING +#include "bh.h" + +#include "onyxparser.h" + +enum WasmType { + WASM_TYPE_INT32 = 0x7F, + WASM_TYPE_INT64 = 0x7E, + WASM_TYPE_FLOAT32 = 0x7D, + WASM_TYPE_FLOAT64 = 0x7C +}; + +typedef struct OnyxWasmModule { + +} OnyxWasmModule; + +OnyxWasmModule onyx_wasm_generate_module(bh_allocator alloc, OnyxAstNode* program); + +#endif diff --git a/onyx b/onyx index a16d7ae6..00d2cd3c 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/minimal.onyx b/progs/minimal.onyx index 23ea5bbe..433a220a 100644 --- a/progs/minimal.onyx +++ b/progs/minimal.onyx @@ -12,5 +12,7 @@ export mul :: proc (a i32, b i32) -> i64 { /* a and b are both i32, so i32 + i32 is i32 so d is i32 */ d: const = a + b; + e: i32 = 10 as i32; + return ((c as i32) * d) as i64; } diff --git a/src/onyx.c b/src/onyx.c index ceb09703..20edcb87 100644 --- a/src/onyx.c +++ b/src/onyx.c @@ -65,7 +65,7 @@ main_exit: // NOTE: Cleanup, since C doesn't have defer bh_arena_free(&ast_arena); onyx_parser_free(&parser); onyx_tokenizer_free(&tokenizer); - bh_file_contents_delete(&fc); + bh_file_contents_free(&fc); return 0; }