From 9838e8723e11fd2aaf65affcb0adf44568dd0cd0 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Wed, 6 Dec 2023 13:30:36 -0600 Subject: [PATCH] started working on fixed bug from #63 --- compiler/src/wasm_emit.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 4f0e0d4d..1be60370 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -2961,8 +2961,10 @@ EMIT_FUNC(compound_store, Type* type, u64 offset, b32 location_first) { type_linear_member_lookup(type, i, &two); WasmType wt = onyx_type_to_wasm_type(two.type); - temp_locals[i] = local_raw_allocate(mod->local_alloc, wt); - WIL(NULL, WI_LOCAL_SET, temp_locals[i]); + if (wt != WASM_TYPE_VOID) { + temp_locals[i] = local_raw_allocate(mod->local_alloc, wt); + WIL(NULL, WI_LOCAL_SET, temp_locals[i]); + } } if (!location_first) WIL(NULL, WI_LOCAL_SET, loc_idx); @@ -2970,13 +2972,15 @@ EMIT_FUNC(compound_store, Type* type, u64 offset, b32 location_first) { fori (i, 0, elem_count) { type_linear_member_lookup(type, i, &two); - u64 tmp_idx = temp_locals[i]; - WIL(NULL, WI_LOCAL_GET, loc_idx); - WIL(NULL, WI_LOCAL_GET, tmp_idx); - emit_store_instruction(mod, &code, two.type, offset + two.offset); - WasmType wt = onyx_type_to_wasm_type(two.type); - local_raw_free(mod->local_alloc, wt); + if (wt != WASM_TYPE_VOID) { + u64 tmp_idx = temp_locals[i]; + WIL(NULL, WI_LOCAL_GET, loc_idx); + WIL(NULL, WI_LOCAL_GET, tmp_idx); + emit_store_instruction(mod, &code, two.type, offset + two.offset); + + local_raw_free(mod->local_alloc, wt); + } } local_raw_free(mod->local_alloc, WASM_TYPE_PTR); -- 2.25.1