From: Brendan Hansen Date: Mon, 20 Jul 2020 02:54:32 +0000 (-0500) Subject: small potential bugfix X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=49432ea5a9c7a7d6c0ccc25ce2661cf5fe57bdc9;p=onyx.git small potential bugfix --- diff --git a/onyx b/onyx index 69bdc1a0..c3e5c62f 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/arrays.onyx b/progs/arrays.onyx index 6c849775..d121c0f5 100644 --- a/progs/arrays.onyx +++ b/progs/arrays.onyx @@ -100,8 +100,6 @@ alloc_2darr :: proc (rows: u32, cols: u32) -> ^^i32 { return arr; } - - multi_arr_test :: proc #export "main" { arrs := alloc_2darr(10, 10); diff --git a/src/onyxwasm.c b/src/onyxwasm.c index cefd6e72..b5a361d2 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -890,7 +890,10 @@ COMPILE_FUNC(cast, AstUnaryOp* cast) { Type* to = cast->type; i32 fromidx = -1, toidx = -1; - if (from->Basic.flags & Basic_Flag_Integer) { + if (from->Basic.flags & Basic_Flag_Pointer) { + fromidx = 8; + } + else if (from->Basic.flags & Basic_Flag_Integer) { b32 unsign = (from->Basic.flags & Basic_Flag_Unsigned) != 0; if (from->Basic.size == 1 && !unsign) fromidx = 0; @@ -906,11 +909,11 @@ COMPILE_FUNC(cast, AstUnaryOp* cast) { if (from->Basic.size == 4) fromidx = 6; else if (from->Basic.size == 8) fromidx = 7; } - else if (from->Basic.flags & Basic_Flag_Pointer) { - fromidx = 8; - } - if (to->Basic.flags & Basic_Flag_Integer) { + if (to->Basic.flags & Basic_Flag_Pointer) { + toidx = 8; + } + else if (to->Basic.flags & Basic_Flag_Integer) { b32 unsign = (to->Basic.flags & Basic_Flag_Unsigned) != 0; if (to->Basic.size == 1 && !unsign) toidx = 0; @@ -926,9 +929,6 @@ COMPILE_FUNC(cast, AstUnaryOp* cast) { if (to->Basic.size == 4) toidx = 6; else if (to->Basic.size == 8) toidx = 7; } - else if (to->Basic.flags & Basic_Flag_Pointer) { - toidx = 8; - } if (fromidx != -1 && toidx != -1) { WasmInstructionType cast_op = cast_map[fromidx][toidx];