Bug fixes; preparing to start WASM code gen
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 2 Jun 2020 21:03:42 +0000 (16:03 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 2 Jun 2020 21:03:42 +0000 (16:03 -0500)
.gitignore
.vimspector.json
include/bh.h
include/onyxparser.h
include/onyxwasm.h [new file with mode: 0644]
onyx
progs/minimal.onyx
src/onyx.c

index 97c16aa3312f47e23cac4574bd6b409bb3b282a7..cd21766181996945bcff1cdf069bdf84ea330014 100644 (file)
@@ -1,2 +1,3 @@
 **/*.o
 *.o
+tags
index 72e3a7abfa4568b526c68362688bf3ea7ac3706a..a52e2a695eaad6c9a1d7d36373098d819829dc86 100644 (file)
@@ -6,7 +6,7 @@
                 "type": "cppdbg",
                 "request": "launch",
                 "program": "${workspaceFolder}/onyx",
-                "args": ["progs/mvp.onyx"],
+                "args": ["progs/minimal.onyx"],
                 "stopAtEntry": true,
                 "cwd": "${workspaceFolder}",
                 "environment": [],
index 95772a75b7f303fcc9acb3a098f590acd7a1302d..d669d5548a3bbae283b4c2b37944578bfbe66e26 100644 (file)
@@ -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;
index b2496f6974f18d244beb43eaba8f7b464937f628..d61f5b19c466555ceb0863bc2e9e22389c945c97 100644 (file)
@@ -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 (file)
index 0000000..2fb91f0
--- /dev/null
@@ -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 a16d7ae6f49c8a3d2cccc93c21a93ef230808e5d..00d2cd3c93fcdf532de7d98d1471af68940c5e44 100755 (executable)
Binary files a/onyx and b/onyx differ
index 23ea5bbe98e71c2b81d8429e4b2d8e9e04c87998..433a220ad5c5184993f9db041b0e415f36df0c0c 100644 (file)
@@ -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;
 }
index ceb097038cb90b4578ab0ad9fb986c3889557977..20edcb87081f6826a9654bbea722cc8fecd2d110 100644 (file)
@@ -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;
 }