From 20a325fc606694376d7f0ebb375c49c6ea9c0e66 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 21 Apr 2023 20:04:49 -0500 Subject: [PATCH] bugfix: miscellaneous missing in refactor --- compiler/src/onyx.c | 2 ++ compiler/src/types.c | 4 ++-- compiler/src/wasm_emit.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index 2b1b9a5b..35961c69 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -964,6 +964,8 @@ int main(int argc, char *argv[]) { #ifdef ENABLE_RUN_WITH_WASMER case ONYX_COMPILE_ACTION_RUN_WASM: + global_heap_allocator = bh_heap_allocator(); + context_init(&compile_opts); compiler_progress = ONYX_COMPILER_PROGRESS_SUCCESS; if (!onyx_run_wasm_file(context.options->target_file)) { compiler_progress = ONYX_COMPILER_PROGRESS_ERROR; diff --git a/compiler/src/types.c b/compiler/src/types.c index 923ef8df..3887ff13 100644 --- a/compiler/src/types.c +++ b/compiler/src/types.c @@ -251,7 +251,7 @@ u32 type_size_of(Type* type) { case Type_Kind_Basic: return type->Basic.size; case Type_Kind_MultiPointer: case Type_Kind_Pointer: return POINTER_SIZE; - case Type_Kind_Function: return 4 + 4 + POINTER_SIZE; + case Type_Kind_Function: return 3 * POINTER_SIZE; case Type_Kind_Array: return type->Array.size; case Type_Kind_Struct: return type->Struct.size; case Type_Kind_Enum: return type_size_of(type->Enum.backing); @@ -1345,7 +1345,7 @@ b32 type_lookup_member_by_idx(Type* type, i32 idx, StructMember* smem) { } case Type_Kind_Function: { - if (idx > 3) return 0; + if (idx > 2) return 0; *smem = func_members[idx]; return 1; diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index af71ea5c..4a5273d9 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -4510,6 +4510,8 @@ static b32 emit_constexpr_(ConstExprContext *ctx, AstTyped *node, u32 offset) { case Ast_Kind_Function: { AstFunction* func = (AstFunction *) node; CE(u32, 0) = get_element_idx(ctx->module, func); + CE(u32, 4) = 0; + CE(u32, 8) = 0; break; } -- 2.25.1