b32 type_is_compound(Type* type) {
if (type == NULL) return 0;
+
+ if (type->kind == Type_Kind_Struct) {
+ //
+ // This is for the kind of common case where a structure simply wraps a
+ // single non-compound value; in this situation, the structure can be
+ // "dissolved" at compile-time and turn into the underlying type.
+ //
+
+ if (bh_arr_length(type->Struct.linear_members) != 1) return 1;
+ return type_is_compound(type->Struct.linear_members[0].type);
+ }
+
return type->kind != Type_Kind_Basic
&& type->kind != Type_Kind_Pointer
&& type->kind != Type_Kind_Enum
return;
}
+ if (type->kind == Type_Kind_Struct) {
+ assert(bh_arr_length(type->Struct.linear_members) == 1);
+ type = type->Struct.linear_members[0].type;
+ }
+
if (type->kind == Type_Kind_Array) {
emit_array_store(mod, pcode, type, offset);
return;
return;
}
+ if (type->kind == Type_Kind_Struct) {
+ assert(bh_arr_length(type->Struct.linear_members) == 1);
+ type = type->Struct.linear_members[0].type;
+ }
+
if (type->kind == Type_Kind_Array) {
if (offset != 0) {
WID(WI_PTR_CONST, offset);
// HACK: Slightly: the wasm type for structs has to be 0x00
WasmType return_type = onyx_type_to_wasm_type(ft->Function.return_type);
+ if (ft->Function.return_type->kind == Type_Kind_Struct && !type_is_compound(ft->Function.return_type)) {
+ return_type = onyx_type_to_wasm_type(ft->Function.return_type->Struct.linear_members[0].type);
+ }
+
*(t++) = (char) return_type;
*t = '\0';