From a77bf308c7512570a88182f74c4927aaf3d118a5 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 2 Jan 2024 18:19:48 -0600 Subject: [PATCH] fixed: distinct string types not storing correctly --- compiler/src/wasm_emit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 58fce47f..bac95f33 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -999,6 +999,8 @@ EMIT_FUNC(compound_assignment, AstBinaryOp* assign) { EMIT_FUNC(store_instruction, Type* type, u32 offset) { bh_arr(WasmInstruction) code = *pcode; + while (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type; + if (onyx_type_is_stored_in_memory(type)) { emit_struct_store(mod, pcode, type, offset); return; @@ -1018,8 +1020,6 @@ EMIT_FUNC(store_instruction, Type* type, u32 offset) { if (type->kind == Type_Kind_Struct) type = type_struct_is_just_one_basic_value(type); if (type->kind == Type_Kind_Enum) type = type->Enum.backing; - while (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type; - assert(type); u32 alignment = type_get_alignment_log2(type); @@ -1117,6 +1117,8 @@ EMIT_FUNC(load_with_ignored_instruction, Type* type, u32 offset, i32 ignored_val EMIT_FUNC(load_instruction, Type* type, u32 offset) { bh_arr(WasmInstruction) code = *pcode; + while (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type; + if (type->kind == Type_Kind_Array || onyx_type_is_stored_in_memory(type)) { if (offset != 0) { WID(NULL, WI_PTR_CONST, offset); @@ -1136,8 +1138,6 @@ EMIT_FUNC(load_instruction, Type* type, u32 offset) { if (type->kind == Type_Kind_Enum) type = type->Enum.backing; if (type->kind == Type_Kind_Function) assert(1234 && 0); - while (type->kind == Type_Kind_Distinct) type = type->Distinct.base_type; - assert(type); i32 load_size = type_size_of(type); -- 2.25.1