From: Brendan Hansen Date: Mon, 8 Nov 2021 03:58:53 +0000 (-0600) Subject: bugfix with exporting polymorphic procedures X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ccd39026c37d541e6febddc28d579c9b6b2deb17;p=onyx.git bugfix with exporting polymorphic procedures --- 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; }