From: Brendan Hansen Date: Sat, 8 Aug 2020 03:38:51 +0000 (-0500) Subject: small bugfixes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=f2c184701409d38cbce0b21c4dc2875ce9655645;p=onyx.git small bugfixes --- diff --git a/onyx b/onyx index 22752e46..376fff4d 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/stack_based.onyx b/progs/stack_based.onyx index f2f4f4ad..e1b2b6ee 100644 --- a/progs/stack_based.onyx +++ b/progs/stack_based.onyx @@ -8,6 +8,8 @@ use package memory ret_val :: proc (x: i32, y: i32) -> i32 { big_arr : [128] i32; + big_arr[0] = 1234; + big_arr[1] = 1234; big_arr[127] = 1234; return big_arr[127] + x + y; } @@ -22,7 +24,10 @@ sumN :: proc (x: [N] i32) -> i32 { summing :: proc (x: ^i32) -> i32 { s := 0; - for i: 0, N do s += x[i]; + for i: 0, N { + tmp :: ^i; + s += x[i]; + } return s; } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 2d617a1a..177d1f9d 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -976,7 +976,7 @@ COMPILE_FUNC(expression, AstTyped* expr) { WI(WI_I32_ADD); } } - + break; } @@ -1034,8 +1034,10 @@ COMPILE_FUNC(expression, AstTyped* expr) { case Ast_Kind_Local: { u64 offset = 0; compile_local_location(mod, &code, (AstLocal *) aof->expr, &offset); - WID(WI_I32_CONST, offset); - WI(WI_I32_ADD); + if (offset != 0) { + WID(WI_I32_CONST, offset); + WI(WI_I32_ADD); + } break; } @@ -1423,7 +1425,7 @@ static inline b32 should_compile_function(AstFunction* fd) { } static b32 local_is_wasm_local(AstLocal* local) { - if (local->flags & Ast_Flag_Address_Taken) return 1; + if (local->flags & Ast_Flag_Address_Taken) return 0; if (local->type->kind == Type_Kind_Basic) return 1; if (local->type->kind == Type_Kind_Pointer) return 1; return 0;