From ccd39026c37d541e6febddc28d579c9b6b2deb17 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 7 Nov 2021 21:58:53 -0600 Subject: [PATCH] bugfix with exporting polymorphic procedures --- src/symres.c | 10 +++++++--- src/wasm_emit.c | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/symres.c b/src/symres.c index df3b8711..0b2d427a 100644 --- a/src/symres.c +++ b/src/symres.c @@ -1159,6 +1159,10 @@ static SymresStatus symres_process_directive(AstNode* directive) { AstDirectiveExport *export = (AstDirectiveExport *) directive; SYMRES(expression, &export->export); + if (export->export->kind == Ast_Kind_Polymorphic_Proc) { + onyx_report_error(export->token->pos, "Cannot export a polymorphic function."); + return Symres_Error; + } if (export->export->kind == Ast_Kind_Function) { AstFunction *func = (AstFunction *) export->export; @@ -1167,18 +1171,18 @@ static SymresStatus symres_process_directive(AstNode* directive) { if (func->is_exported) { if (func->is_foreign) { - onyx_report_error(export->token->pos, "exporting a foreign function"); + onyx_report_error(export->token->pos, "Cannot export a foreign function."); return Symres_Error; } if (func->is_intrinsic) { - onyx_report_error(export->token->pos, "exporting a intrinsic function"); + onyx_report_error(export->token->pos, "Cannot export an intrinsic function."); return Symres_Error; } // NOTE: This should never happen if (func->exported_name == NULL) { - onyx_report_error(export->token->pos, "exporting function without a name"); + onyx_report_error(export->token->pos, "Cannot export function without a name."); return Symres_Error; } } diff --git a/src/wasm_emit.c b/src/wasm_emit.c index 68a1c894..659dca3e 100644 --- a/src/wasm_emit.c +++ b/src/wasm_emit.c @@ -3714,6 +3714,13 @@ OnyxWasmModule onyx_wasm_module_create(bh_allocator alloc) { module.export_count++; } + WasmExport func_table_export = { + .kind = WASM_FOREIGN_TABLE, + .idx = 0, + }; + bh_table_put(WasmExport, module.exports, "func_table", func_table_export); + module.export_count++; + return module; } -- 2.25.1