From 8e091546984f3b09f325695c368fa9ba47ad4f83 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 12 Jan 2023 15:24:53 -0600 Subject: [PATCH] simplied idea of type_is_compound --- compiler/src/types.c | 13 ++----------- compiler/src/wasm_emit.c | 3 +-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/compiler/src/types.c b/compiler/src/types.c index 3e96ff17..887c73ec 100644 --- a/compiler/src/types.c +++ b/compiler/src/types.c @@ -1232,10 +1232,10 @@ b32 type_lookup_member_by_idx(Type* type, i32 idx, StructMember* smem) { } i32 type_linear_member_count(Type* type) { + if (!type) return 0; switch (type->kind) { case Type_Kind_Slice: case Type_Kind_VarArgs: return 2; - case Type_Kind_DynArray: return 5; case Type_Kind_Compound: return bh_arr_length(type->Compound.linear_members); default: return 1; } @@ -1381,16 +1381,7 @@ b32 type_is_numeric(Type* type) { } b32 type_is_compound(Type* type) { - if (type == NULL) return 0; - - return type->kind != Type_Kind_Basic - && type->kind != Type_Kind_Pointer - && type->kind != Type_Kind_Enum - && type->kind != Type_Kind_Function - && type->kind != Type_Kind_Array - && type->kind != Type_Kind_Distinct - && type->kind != Type_Kind_Struct - && type->kind != Type_Kind_DynArray; + return type_linear_member_count(type) > 1; } b32 type_is_simd(Type* type) { diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 6ffd642d..12f6235d 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -3664,8 +3664,7 @@ EMIT_FUNC(expression, AstTyped* expr) { } if ((expr->flags & Ast_Flag_Expr_Ignored) != 0 && !type_results_in_void(expr->type)) { - i32 mem_count = 1; - if (type_is_compound(expr->type)) mem_count = type_linear_member_count(expr->type); + i32 mem_count = type_linear_member_count(expr->type); fori (i, 0, mem_count) WI(NULL, WI_DROP); } -- 2.25.1