bugfix with exporting polymorphic procedures
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 8 Nov 2021 03:58:53 +0000 (21:58 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 8 Nov 2021 03:58:53 +0000 (21:58 -0600)
src/symres.c
src/wasm_emit.c

index df3b8711e126a86b99c6b958fa7ccfc9c1f521fd..0b2d427aa4df43628d26f610e0e4ddbc42dd1aad 100644 (file)
@@ -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;
                     }
                 }
index 68a1c8940ea3862b856523a5b4722f6fe3ea30db..659dca3ecc94a1bfefe0c1891b31f328a62592f5 100644 (file)
@@ -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;
 }