small bugfix with struct typing
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 8 Aug 2020 16:17:32 +0000 (11:17 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 8 Aug 2020 16:17:32 +0000 (11:17 -0500)
src/onyxwasm.c

index 177d1f9d4f98a63c0b5ee98c7fe5085b7ba02cad..caff5d93d98d2f6c3897a2df2ec31410f28b15c5 100644 (file)
@@ -202,7 +202,7 @@ static const char* wi_string(WasmInstructionType wit) {
 
 static WasmType onyx_type_to_wasm_type(Type* type) {
     if (type->kind == Type_Kind_Struct) {
-        DEBUG_HERE;
+        return WASM_TYPE_VOID;
     }
 
     if (type->kind == Type_Kind_Enum) {
@@ -452,6 +452,15 @@ COMPILE_FUNC(store_instruction, Type* type, u32 alignment, u32 offset) {
 COMPILE_FUNC(load_instruction, Type* type, u32 offset) {
     bh_arr(WasmInstruction) code = *pcode;
 
+    if (type->kind == Type_Kind_Array) {
+        if (offset != 0) {
+            WID(WI_I32_CONST, offset);
+            WI(WI_I32_ADD);
+        }
+
+        return;
+    }
+
     if (type->kind == Type_Kind_Enum) {
         type = type->Enum.backing;
     }