simplied idea of type_is_compound
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 12 Jan 2023 21:24:53 +0000 (15:24 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 12 Jan 2023 21:24:53 +0000 (15:24 -0600)
compiler/src/types.c
compiler/src/wasm_emit.c

index 3e96ff176c90c31e4de4876545f375c6e173871c..887c73ecfb41747ff36b4abb6ce155cdb32f5bbf 100644 (file)
@@ -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) {
index 6ffd642d4dab5a92df84785809d2bb10bd07d502..12f6235d7129cffb1333682d13fe7322ed9f9423 100644 (file)
@@ -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);
     }