cleanup: macos compiler build errors
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 13 Dec 2023 03:38:19 +0000 (21:38 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 13 Dec 2023 03:38:19 +0000 (21:38 -0600)
16 files changed:
compiler/build.sh
compiler/src/astnodes.c
compiler/src/checker.c
compiler/src/clone.c
compiler/src/doc.c
compiler/src/onyx.c
compiler/src/parser.c
compiler/src/polymorph.h
compiler/src/symres.c
compiler/src/types.c
compiler/src/utils.c
compiler/src/wasm_emit.c
compiler/src/wasm_output.h
compiler/src/wasm_runtime.c
compiler/src/wasm_type_table.h
shared/include/bh.h

index e20154dd0d4c9ebe4652bbbcf755aa445e450c68..c8b657aa16dd663ef8b22ddd51c8360fff79ffd0 100755 (executable)
@@ -4,7 +4,7 @@ C_FILES="onyx astnodes builtins checker clone doc entities errors lex parser sym
 LIBS="-lpthread -ldl -lm"
 INCLUDES="-I./include -I../shared/include -I../shared/include/dyncall"
 
-WARNINGS='-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wmaybe-uninitialized -Wsign-compare -Wstrict-overflow -Wduplicated-branches -Wduplicated-cond -Wtrigraphs -Waddress -Wlogical-op'
+WARNINGS='-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wsign-compare -Wstrict-overflow -Wtrigraphs -Waddress'
 
 if [ "$1" = "debug" ]; then
     FLAGS="$WARNINGS -g3"
@@ -45,7 +45,7 @@ fi
 
 case "$ONYX_ARCH" in
     *darwin*)
-        LIBS="$LIBS -lffi -lSystem -framework CoreFoundation -framework SystemConfiguration"
+        LIBS="$LIBS -lffi -framework CoreFoundation -framework SystemConfiguration"
         ;;
 esac
 
index 3fcba62d98cdb3e5d6ad3a092d2d1a0a857da585..b7e17d9327fe51abdc268275354577ee70fe847d 100644 (file)
@@ -208,7 +208,7 @@ AstNumLit* ast_reduce_type_compare(bh_allocator a, AstBinaryOp* node) {
     switch (node->operation) {
         case Binary_Op_Equal:     res->value.l = left_type->id == right_type->id; break;
         case Binary_Op_Not_Equal: res->value.l = left_type->id != right_type->id; break;
-        default: assert(("Bad case in ast_reduce_type_compare", 0));
+        default: assert("Bad case in ast_reduce_type_compare" && 0);
     }
 
     return res;
@@ -530,7 +530,7 @@ b32 convert_numlit_to_type(AstNumLit* num, Type* to_type) {
                 return 1;
             }
             if (type->Basic.size == 8) {
-                if (bh_abs(num->value.l) >= (1ull << 52)) {
+                if (bh_abs(num->value.l) >= (1ll << 52)) {
                     onyx_report_error(num->token->pos, Error_Critical, "Integer '%l' does not fit in 64-bit float exactly.", num->value.l);
                     return 0;
                 }
@@ -826,6 +826,7 @@ TypeMatch unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) {
                 case TYPE_MATCH_SUCCESS: break;
                 case TYPE_MATCH_FAILED: return TYPE_MATCH_FAILED;
                 case TYPE_MATCH_YIELD: return TYPE_MATCH_YIELD;
+                default: break;
             }
         }
 
@@ -834,6 +835,7 @@ TypeMatch unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) {
                 case TYPE_MATCH_SUCCESS: break;
                 case TYPE_MATCH_FAILED: return TYPE_MATCH_FAILED;
                 case TYPE_MATCH_YIELD: return TYPE_MATCH_YIELD;
+                default: break;
             }
         }
 
@@ -1061,7 +1063,7 @@ Type* query_expression_type(AstTyped *node) {
 
     if (node->kind == Ast_Kind_NumLit && node->type->kind == Type_Kind_Basic) {
         if (node->type->Basic.kind == Basic_Kind_Int_Unsized) {
-            b32 big    = bh_abs(((AstNumLit *) node)->value.l) >= (1ull << 32);
+            b32 big    = bh_abs(((AstNumLit *) node)->value.l) >= (1ll << 32);
             b32 unsign = ((AstNumLit *) node)->was_hex_literal;
 
             if (((AstNumLit *) node)->was_char_literal) return &basic_types[Basic_Kind_U8];
@@ -1171,7 +1173,7 @@ Type* resolve_expression_type(AstTyped* node) {
 
     if (node->kind == Ast_Kind_NumLit && node->type->kind == Type_Kind_Basic) {
         if (node->type->Basic.kind == Basic_Kind_Int_Unsized) {
-            b32 big    = bh_abs(((AstNumLit *) node)->value.l) >= (1ull << 32);
+            b32 big    = bh_abs(((AstNumLit *) node)->value.l) >= (1ll << 32);
             b32 unsign = ((AstNumLit *) node)->was_hex_literal;
 
             if (((AstNumLit *) node)->was_char_literal) convert_numlit_to_type((AstNumLit *) node, &basic_types[Basic_Kind_U8]);
@@ -1247,7 +1249,7 @@ char *get_expression_string_value(AstTyped* node, b32 *out_is_valid) {
         // CLEANUP: Maybe this should allocate on the heap?
         // I guess if in all cases the memory is allocated on the heap,
         // then the caller can free the memory.
-        i8* strdata = bh_alloc_array(global_heap_allocator, i8, str->token->length + 1);
+        char* strdata = bh_alloc_array(global_heap_allocator, char, str->token->length + 1);
         i32 length  = string_process_escape_seqs(strdata, str->token->text, str->token->length);
         strdata[length] = '\0';
 
@@ -1563,7 +1565,7 @@ AstNumLit* make_int_literal(bh_allocator a, i64 i) {
     AstNumLit* num = onyx_ast_node_new(a, sizeof(AstNumLit), Ast_Kind_NumLit);
     num->flags |= Ast_Flag_Comptime;
 
-    if (bh_abs(i) >= ((u64) 1 << 32))
+    if (bh_abs(i) >= (1ll << 32))
         num->type_node = (AstType *) &basic_type_i64;
     else
         num->type_node = (AstType *) &basic_type_i32;
index 363edabd0c28112cacaff6eba3eee5256314ae7a..860ae5113b21149fffd890c5343b3898e0a2b146 100644 (file)
@@ -1213,6 +1213,8 @@ static b32 binary_op_is_allowed(BinaryOp operation, Type* type) {
         case Type_Kind_MultiPointer: effective_flags = Basic_Flag_Multi_Pointer; break;
         case Type_Kind_Enum:         effective_flags = Basic_Flag_Integer; break;
         case Type_Kind_Function:     effective_flags = Basic_Flag_Equality; break;
+
+        default: break;
     }
 
     return (binop_allowed[operation] & effective_flags) != 0;
@@ -3464,6 +3466,8 @@ CheckStatus check_type(AstType** ptype) {
             }
             break;
         }
+
+        default: break;
     }
 
     type = original_type;
@@ -3819,6 +3823,8 @@ CheckStatus check_constraint(AstConstraint *constraint) {
             *constraint->report_status = Constraint_Check_Status_Success;
             return Check_Complete;
         }
+
+        default: break;
     }
 
     onyx_errors_enable();
@@ -3988,6 +3994,7 @@ CheckStatus check_arbitrary_job(EntityJobData *job) {
         case TYPE_MATCH_SUCCESS: return Check_Complete;
         case TYPE_MATCH_FAILED:  return Check_Error;
         case TYPE_MATCH_YIELD:   return Check_Yield_Macro;
+        case TYPE_MATCH_SPECIAL: return Check_Yield_Macro;
     }
 
     return Check_Error;
@@ -4051,5 +4058,7 @@ void check_entity(Entity* ent) {
     clear_attempts:
         ent->macro_attempts = 0;
         ent->micro_attempts = 0;
+
+        default: break;
     }
 }
index 449899b042a6cb23ad0a1498b5f177834cc921ac..d96399383e5ac249922cc4aa87690a2caa822b82 100644 (file)
@@ -122,7 +122,8 @@ static inline i32 ast_kind_to_size(AstNode* node) {
         case Ast_Kind_Capture_Local: return sizeof(AstCaptureLocal);
         case Ast_Kind_Union_Type: return sizeof(AstUnionType);
         case Ast_Kind_Union_Variant: return sizeof(AstUnionVariant);
-        case Ast_Kind_Count: return 0;
+
+        default: break;
     }
 
     return 0;
index 0181402693d848649658a3c4add07d11fac3225b..003e91c4e5d9616f76be3291fbb212b9a7fbff79 100644 (file)
@@ -411,6 +411,8 @@ static void write_type_node(bh_buffer *buffer, void *vnode) {
                 
             bh_buffer_append(buffer, node->token->text, node->token->length);
             return;
+
+        default: break;
     }
 
   unknown_case:
@@ -479,7 +481,7 @@ static void write_doc_constraints(bh_buffer *buffer, ConstraintContext *constrai
         }
 
         bh_buffer_write_string(&tmp_buffer, ")");
-        write_string(buffer, tmp_buffer.length, tmp_buffer.data);
+        write_string(buffer, tmp_buffer.length, (char *) tmp_buffer.data);
 
         constraint_count += 1;
     }
@@ -497,7 +499,7 @@ static void write_doc_constraints(bh_buffer *buffer, ConstraintContext *constrai
             poly_param->poly_sym->flags |= Ast_Flag_Symbol_Is_PolyVar;
 
             bh_buffer_write_string(&tmp_buffer, ")");
-            write_string(buffer, tmp_buffer.length, tmp_buffer.data);
+            write_string(buffer, tmp_buffer.length, (char *) tmp_buffer.data);
 
             constraint_count += 1;
         }
@@ -534,6 +536,7 @@ static void write_doc_methods(bh_buffer *buffer, Scope *method_scope) {
             case Ast_Kind_Function:            binding = node->original_binding_to_node; break;
             case Ast_Kind_Macro:               binding = ((AstMacro *) node)->original_binding_to_node; break;
             case Ast_Kind_Overloaded_Function: binding = ((AstOverloadedFunction *) node)->original_binding_to_node; break;
+            default: break;
         }
 
         OnyxToken tmp_name_token;
@@ -647,7 +650,7 @@ static b32 write_doc_polymorphic_proc(bh_buffer *buffer, AstBinding *binding, As
             write_string(buffer, param->local->token->length, param->local->token->text);
 
         write_type_node(&param_type_buf, param->local->type_node);
-        write_string(buffer, param_type_buf.length, param_type_buf.data);
+        write_string(buffer, param_type_buf.length, (char *) param_type_buf.data);
         write_cstring(buffer, "");
     }
 
@@ -655,7 +658,7 @@ static b32 write_doc_polymorphic_proc(bh_buffer *buffer, AstBinding *binding, As
     // Return type
     bh_buffer_clear(&param_type_buf);
     write_type_node(&param_type_buf, func->return_type);
-    write_string(buffer, param_type_buf.length, param_type_buf.data);
+    write_string(buffer, param_type_buf.length, (char *) param_type_buf.data);
     bh_buffer_free(&param_type_buf);
 
     // Overload procs
@@ -736,7 +739,7 @@ static b32 write_doc_structure(bh_buffer *buffer, AstBinding *binding, AstNode *
             write_type_node(&type_buf, smem->type_node);
 
             write_string(buffer, smem->token->length, smem->token->text);
-            write_string(buffer, type_buf.length, type_buf.data);
+            write_string(buffer, type_buf.length, (char *) type_buf.data);
             write_cstring(buffer, "");
 
             bh_buffer_write_u32(buffer, smem->is_used ? 1 : 0);
@@ -749,7 +752,7 @@ static b32 write_doc_structure(bh_buffer *buffer, AstBinding *binding, AstNode *
             write_type_node(&type_buf, param->type_node);
 
             write_string(buffer, param->token->length, param->token->text);
-            write_string(buffer, type_buf.length, type_buf.data);
+            write_string(buffer, type_buf.length, (char *) type_buf.data);
             write_cstring(buffer, "");
         }
 
@@ -809,7 +812,7 @@ static b32 write_doc_union_type(bh_buffer *buffer, AstBinding *binding, AstNode
             write_type_node(&type_buf, uv->type_node);
 
             write_string(buffer, uv->token->length, uv->token->text);
-            write_string(buffer, type_buf.length, type_buf.data);
+            write_string(buffer, type_buf.length, (char *) type_buf.data);
         }
 
         // Polymorph parameters
@@ -819,7 +822,7 @@ static b32 write_doc_union_type(bh_buffer *buffer, AstBinding *binding, AstNode
             write_type_node(&type_buf, param->type_node);
 
             write_string(buffer, param->token->length, param->token->text);
-            write_string(buffer, type_buf.length, type_buf.data);
+            write_string(buffer, type_buf.length, (char *) type_buf.data);
             write_cstring(buffer, "");
         }
 
@@ -863,7 +866,7 @@ static b32 write_doc_distinct_type(bh_buffer *buffer, AstBinding *binding, AstNo
     bh_buffer type_buf;
     bh_buffer_init(&type_buf, global_scratch_allocator, 256);
     write_type_node(&type_buf, distinct_node->base_type);
-    write_string(buffer, type_buf.length, type_buf.data);
+    write_string(buffer, type_buf.length, (char *) type_buf.data);
     bh_buffer_free(&type_buf);
 
     write_doc_methods(buffer, distinct_node->scope);
index 4c9308c5aec9df15aa8431ea2da47e92456b2a94..c87f987437a60b06eb6973c798e58cd37040587a 100644 (file)
@@ -679,7 +679,7 @@ static b32 process_load_entity(Entity* ent) {
                     bh_snprintf(fullpath, 511, "%s/%s", folder, entry.name);
                     bh_path_convert_separators(fullpath);
 
-                    u8* formatted_name = bh_path_get_full_name(fullpath, global_heap_allocator);
+                    char* formatted_name = bh_path_get_full_name(fullpath, global_heap_allocator);
 
                     AstInclude* new_include = onyx_ast_node_new(context.ast_alloc, sizeof(AstInclude), Ast_Kind_Load_File);
                     new_include->token = include->token;
@@ -691,7 +691,7 @@ static b32 process_load_entity(Entity* ent) {
                     if (!strcmp(entry.name, ".") || !strcmp(entry.name, "..")) continue;
 
                     bh_snprintf(fullpath, 511, "%s/%s", folder, entry.name);
-                    u8* formatted_name = bh_path_get_full_name(fullpath, global_scratch_allocator); // Could this overflow the scratch allocator?
+                    char* formatted_name = bh_path_get_full_name(fullpath, global_scratch_allocator); // Could this overflow the scratch allocator?
 
                     bh_arr_push(folders_to_process, formatted_name);
                 }
@@ -799,6 +799,8 @@ static b32 process_entity(Entity* ent) {
             emit_entity(ent);
             break;
         }
+
+        default: break;
     }
 
     b32 changed = ent->state != before_state;
@@ -971,8 +973,8 @@ static i32 onyx_compile() {
         // TODO: Replace these with bh_printf when padded formatting is added.
         printf("\nStatistics:\n");
         printf("    Time taken: %lf ms\n", (double) duration);
-        printf("    Processed %ld lines (%f lines/second).\n", context.lexer_lines_processed, ((f32) 1000 * context.lexer_lines_processed) / (duration));
-        printf("    Processed %ld tokens (%f tokens/second).\n", context.lexer_tokens_processed, ((f32) 1000 * context.lexer_tokens_processed) / (duration));
+        printf("    Processed %llu lines (%f lines/second).\n", context.lexer_lines_processed, ((f32) 1000 * context.lexer_lines_processed) / (duration));
+        printf("    Processed %llu tokens (%f tokens/second).\n", context.lexer_tokens_processed, ((f32) 1000 * context.lexer_tokens_processed) / (duration));
         printf("\n");
     }
 
@@ -1224,10 +1226,8 @@ int main(int argc, char *argv[]) {
         default: break;
     }
 
-    switch (compiler_progress) {
-        case ONYX_COMPILER_PROGRESS_FAILED_OUTPUT:
-            bh_printf_err("Failed to open file for writing: '%s'\n", compile_opts.target_file);
-            break;
+    if (compiler_progress == ONYX_COMPILER_PROGRESS_FAILED_OUTPUT) {
+        bh_printf_err("Failed to open file for writing: '%s'\n", compile_opts.target_file);
     }
 
     cleanup_compilation();
index b89077a6662651e162b0ed7b8312ee194c72c37e..13d4e1f46cebe4e9c171276b65233d6b54347ce5 100644 (file)
@@ -3151,7 +3151,7 @@ static b32 parse_possible_quick_function_definition(OnyxParser* parser, AstTyped
     bh_arr_new(global_heap_allocator, poly_proc->poly_params, bh_arr_length(params));
     fori (i, 0, bh_arr_length(params)) {
         bh_arr_push(poly_proc->poly_params, ((AstPolyParam) {
-            .kind = PSK_Type,
+            .kind = PPK_Poly_Type,
             .idx  = i,
             .poly_sym = poly_params[i],
             .type_expr = (AstType *) poly_params[i],
index bd97a95d3e296532e5da7d6a81c506f27643bf16..ecc1ae6c87dfc83118f8616746906eacd3c09d1f 100644 (file)
@@ -47,6 +47,8 @@ void insert_poly_sln_into_scope(Scope* scope, AstPolySolution *sln) {
 
             node = (AstNode *) sln->value;
             break;
+
+        case PSK_Undefined: assert("Unexpected PSK_Undefined" && 0); break;
     }
 
     symbol_introduce(scope, sln->poly_sym->token, node);
index ff92926168806d5bbe3f4a32e674cbb87e233dfa..0a9947fcf3ba078f6f99624c18d465a28344ce65 100644 (file)
@@ -308,6 +308,8 @@ static SymresStatus symres_type(AstType** type) {
             SYMRES(type, &distinct->base_type);
             break;
         }
+
+        default: break;
     }
 
     return Symres_Success;
@@ -1536,8 +1538,8 @@ static SymresStatus symres_process_directive(AstNode* directive) {
                 }
 
                 UnaryOp unop = Unary_Op_Count;
-                switch (operator->operator_token->type) {
-                    case '?': unop = Unary_Op_Try; break;
+                if (operator->operator_token->type == (TokenType) '?') {
+                    unop = Unary_Op_Try;
                 }
 
                 if (unop == Unary_Op_Count) {
@@ -1634,6 +1636,8 @@ static SymresStatus symres_process_directive(AstNode* directive) {
             package->package = current_entity->package;
             return Symres_Complete;
         }
+    
+        default: assert("Bad directive in symres_process_directive" && 0); break;
     }
 
     return Symres_Success;
@@ -1708,6 +1712,8 @@ static SymresStatus symres_constraint(AstConstraint* constraint) {
             onyx_errors_enable();
             return Symres_Success;
         }
+
+        default: break;
     }
 
     return Symres_Success;
index 805f7102405b254c06eb704a28cba8137e065bde..9f0d41e194ab6856881a95f37591b4cec4198028 100644 (file)
@@ -241,7 +241,7 @@ b32 types_are_compatible_(Type* t1, Type* t2, b32 recurse_pointers) {
             return 0;
 
         default:
-            assert(("Invalid type", 0));
+            assert("Invalid type" && 0);
             break;
     }
 
@@ -832,6 +832,8 @@ static Type* type_build_from_ast_inner(bh_allocator alloc, AstType* type_node, b
 
             return u_type;
         }
+
+        default: break;
     }
 
     return NULL;
index dab018477c6512572d76941be5a66afc993c45ef..4995c521eeb350cb69a5ac7322f8ac60eaa3e3a0 100644 (file)
@@ -388,6 +388,8 @@ all_types_peeled_off:
             AstInterface* inter = (AstInterface *) node;
             return symbol_raw_resolve(inter->scope, symbol);
         }
+
+        default: break;
     }
 
     return NULL;
@@ -543,6 +545,7 @@ AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads,
                 overload = (AstFunction *) node;
                 arguments_clear_baked_flags(&args);
                 break;
+            default: break;
         }
 
         // NOTE: Overload is not something that is known to be overloadable.
@@ -856,7 +859,7 @@ AstFunction* macro_resolve_header(AstMacro* macro, Arguments* args, OnyxToken* c
             return polymorphic_proc_build_only_header_with_slns(pp, slns, error_if_failed);
         }
 
-        default: assert(("Bad macro body type.", 0));
+        default: assert("Bad macro body type." && 0);
     }
 
     return NULL;
@@ -941,6 +944,8 @@ static i32 maximum_argument_count(AstNode* provider) {
 
             return type_structlike_mem_count(sl->type);
         }
+
+        default: break;
     }
 
     // NOTE: This returns int_max for anything other than struct literals because the
@@ -1436,6 +1441,8 @@ all_types_peeled_off:
             AstInterface* inter = (AstInterface *) node;
             return &inter->scope;
         }
+
+        default: break;
     }
 
     return NULL;
index d47696c80df0bf52ef0eebc1dc4d118a73f24516..e092579c4ad784049fec296427914990eedce975 100644 (file)
@@ -257,7 +257,7 @@ static u32 debug_introduce_symbol(OnyxWasmModule *mod, OnyxToken *token, DebugSy
     }
 
     bh_buffer_write_byte(&mod->debug_context->op_buffer, DOT_SYM);
-    u32 leb_len=0;
+    i32 leb_len=0;
     u8 *bytes = uint_to_uleb128(id, &leb_len);
     bh_buffer_append(&mod->debug_context->op_buffer, bytes, leb_len);
 
@@ -296,7 +296,7 @@ static void debug_set_position(OnyxWasmModule *mod, OnyxToken *token) {
     bh_buffer_write_byte(&mod->debug_context->op_buffer, DOT_SET);
     mod->debug_context->last_op_was_rep = 0;
 
-    u32 leb_len=0;
+    i32 leb_len=0;
     u8 *bytes = uint_to_uleb128(file_id, &leb_len);
     bh_buffer_append(&mod->debug_context->op_buffer, bytes, leb_len);
 
@@ -1953,6 +1953,7 @@ EMIT_FUNC(binop, AstBinaryOp* binop) {
         case Binary_Op_Less:    case Binary_Op_Less_Equal:
         case Binary_Op_Greater: case Binary_Op_Greater_Equal:
             is_sign_significant = 1;
+        default: break;
     }
 
     WasmType operator_type = onyx_type_to_wasm_type(binop->left->type);
@@ -2056,6 +2057,10 @@ EMIT_FUNC(unaryop, AstUnaryOp* unop) {
 
         case Unary_Op_Auto_Cast:
         case Unary_Op_Cast: emit_cast(mod, &code, unop); break;
+
+        case Unary_Op_Try: // Should be handled in operator overload
+        case Unary_Op_Count:
+            break;
     }
 
     *pcode = code;
@@ -2255,6 +2260,9 @@ EMIT_FUNC(call, AstCall* call) {
             reserve_size += 4 + POINTER_SIZE;
             break;
         }
+
+        case VA_Kind_Not_VA:
+            break;
     }
 
     CallingConvention cc = type_function_get_cc(call->callee->type);
@@ -2830,7 +2838,7 @@ EMIT_FUNC(intrinsic_call, AstCall* call) {
             break;
         }
 
-        default: assert(("Unsupported intrinsic", 0));
+        default: assert("Unsupported intrinsic" && 0);
     }
 
     *pcode = code;
@@ -4276,6 +4284,8 @@ static i32 generate_type_idx(OnyxWasmModule* mod, Type* ft) {
                 param_count += mem_count - 1;
                 break;
             }
+
+            case Param_Pass_Invalid: assert("Invalid parameter passing" && 0);
         }
 
         param_type++;
@@ -4615,6 +4625,8 @@ static void emit_export_directive(OnyxWasmModule* mod, AstDirectiveExport* expor
 
         case Ast_Kind_Global:   wasm_export.kind = WASM_FOREIGN_GLOBAL;
                                 break;
+
+        default: assert("Invalid export node" && 0);
     }
 
     shput(mod->exports, export->export_name->text, wasm_export);
@@ -4643,7 +4655,7 @@ static void emit_global(OnyxWasmModule* module, AstGlobal* global) {
         case WASM_TYPE_FLOAT32: bh_arr_push(glob.initial_value, ((WasmInstruction) { WI_F32_CONST, 0 })); break;
         case WASM_TYPE_FLOAT64: bh_arr_push(glob.initial_value, ((WasmInstruction) { WI_F64_CONST, 0 })); break;
 
-        default: assert(("Invalid global type", 0)); break;
+        default: assert("Invalid global type" && 0); break;
     }
 
     bh_arr_set_at(module->globals, global_idx, glob);
@@ -4662,7 +4674,7 @@ static void emit_raw_string(OnyxWasmModule* mod, char *data, i32 len, u64 *out_d
     // NOTE: Allocating more than necessary, but there are no cases
     // in a string literal that create more bytes than already
     // existed. You can create less however ('\n' => 0x0a).
-    i8* strdata = bh_alloc_array(global_heap_allocator, i8, len + 1);
+    char* strdata = bh_alloc_array(global_heap_allocator, char, len + 1);
     i32 length  = string_process_escape_seqs(strdata, data, len);
 
     i32 index = shgeti(mod->string_literals, (char *) strdata);
@@ -5312,7 +5324,7 @@ void onyx_wasm_module_link(OnyxWasmModule *module, OnyxWasmLinkOptions *options)
                 patch->data_id = ((AstMemRes *) patch->node_to_use_if_data_id_is_null)->data_id;
 
             } else {
-                assert(("Unexpected empty data_id in linking!", 0));
+                assert("Unexpected empty data_id in linking!" && 0);
             }
         }
 
index ee5273ae854743c2b87edd663eb925be1c45b023..c44ffe093c6b733ff7144594f81bee1b8bf610ad 100644 (file)
@@ -262,7 +262,8 @@ static i32 output_importsection(OnyxWasmModule* module, bh_buffer* buff) {
                 output_limits(import->min, import->max, import->shared, &vec_buff);
                 break;
 
-            case WASM_FOREIGN_TABLE: assert(0);
+            case WASM_FOREIGN_GLOBAL:
+            case WASM_FOREIGN_TABLE: assert("Bad foreign import kind" && 0);
         }
     }
 
@@ -1053,7 +1054,7 @@ static i32 output_ovm_debug_sections(OnyxWasmModule* module, bh_buffer* buff) {
                 continue;
             }
 
-            assert(("Unhandled type", 0));
+            assert("Unhandled type in debug info builder" && 0);
         }
 
         output_unsigned_integer(section_buff.length, buff);
index a50383307f1c3f3379ec04af175c1a430acb10dc..e232d8b9548e86820d52ba913fef94d7ba3358d7 100644 (file)
@@ -165,7 +165,7 @@ static void lookup_and_load_custom_libraries(LinkLibraryContext *ctx, bh_arr(Was
         i32 section_start = cursor;
         if (section_number == 0) {
             u64 name_len = uleb128_to_uint(wasm_bytes.data, &cursor);
-            if (!strncmp(wasm_bytes.data + cursor, "_onyx_libs", name_len)) {
+            if (!strncmp((const char *) wasm_bytes.data + cursor, "_onyx_libs", name_len)) {
                 cursor += name_len;
                 u64 lib_count = uleb128_to_uint(wasm_bytes.data, &cursor);
 
@@ -174,7 +174,7 @@ static void lookup_and_load_custom_libraries(LinkLibraryContext *ctx, bh_arr(Was
                     lib_path_length = bh_min(lib_path_length, 512);
 
                     char *lib_path = malloc(lib_path_length);
-                    strncpy(lib_path, wasm_bytes.data + cursor, lib_path_length);
+                    strncpy(lib_path, (const char *) wasm_bytes.data + cursor, lib_path_length);
                     lib_path[lib_path_length] = '\0';
                     bh_path_convert_separators(lib_path);
                     cursor += lib_path_length;
@@ -189,7 +189,7 @@ static void lookup_and_load_custom_libraries(LinkLibraryContext *ctx, bh_arr(Was
                     lib_name_length = bh_min(lib_name_length, 256);
 
                     char library_name[256];
-                    strncpy(library_name, wasm_bytes.data + cursor, lib_name_length);
+                    strncpy(library_name, (const char *) wasm_bytes.data + cursor, lib_name_length);
                     library_name[lib_name_length] = '\0';
                     cursor += lib_name_length;
 
@@ -399,7 +399,7 @@ static void onyx_print_trap(wasm_trap_t* trap) {
         i32 section_start = cursor;
         if (section_number == 0) {
             u64 name_len = uleb128_to_uint(wasm_raw_bytes.data, &cursor);
-            if (!strncmp(wasm_raw_bytes.data + cursor, "_onyx_func_offsets", name_len)) {
+            if (!strncmp((const char *) wasm_raw_bytes.data + cursor, "_onyx_func_offsets", name_len)) {
                 cursor += name_len;
                 func_name_section = cursor;
                 break;
@@ -419,7 +419,7 @@ static void onyx_print_trap(wasm_trap_t* trap) {
         if (func_name_section > 0) {
             i32 cursor = func_name_section + 4 * func_idx;
             i32 func_offset = *(i32 *) (wasm_raw_bytes.data + cursor);
-            char* func_name = wasm_raw_bytes.data + func_name_section + func_offset;
+            char* func_name = (char *) wasm_raw_bytes.data + func_name_section + func_offset;
 
             bh_printf("    func[%d]:%p at %s\n", func_idx, mod_offset, func_name);
         } else {
@@ -616,7 +616,7 @@ b32 onyx_run_wasm(bh_buffer wasm_bytes, int argc, char *argv[]) {
 
     wasm_byte_vec_t wasm_data;
     wasm_data.size = wasm_bytes.length;
-    wasm_data.data = wasm_bytes.data;
+    wasm_data.data = (wasm_byte_t *) wasm_bytes.data;
 
     wasm_module = wasm_module_new(wasm_store, &wasm_data);
     if (!wasm_module) {
index 9e2b46c51b896375c7bb1589df3d64d672e52d6c..630c61328cc48bcc41d8dd47afc5bfbb9160e524 100644 (file)
@@ -773,6 +773,10 @@ static u64 build_type_table(OnyxWasmModule* module) {
 
                 break;
             }
+        
+            case Type_Kind_Invalid:
+            case Type_Kind_Count:
+                break;
         }
     }
 
index 70e6bf08562be4a286f4fdd32c1092f7743315df..5f55a52bb8b3702362a6470a71d8c068f7f08f46 100644 (file)
@@ -78,7 +78,7 @@ typedef int16_t i16;
 typedef int32_t i32;
 typedef int64_t i64;
 typedef int64_t isize;
-typedef i32 b32;
+typedef u32 b32;
 typedef void* ptr;
 typedef float f32;
 typedef double f64;
@@ -466,7 +466,7 @@ char* bh_lookup_file(char* filename, char* relative_to, char *suffix, b32 add_su
 
 bh_file_contents bh_file_read_contents_bh_file(bh_allocator alloc, bh_file* file);
 bh_file_contents bh_file_read_contents_direct(bh_allocator alloc, const char* filename);
-i32 bh_file_contents_free(bh_file_contents* contents);
+b32 bh_file_contents_free(bh_file_contents* contents);
 
 
 #ifdef _BH_WINDOWS
@@ -1850,11 +1850,11 @@ bh_file_error bh_file_close(bh_file* file) {
 #endif
 }
 
-b32 bh_file_read(bh_file* file, void* buffer, isize buff_size) {
+i32 bh_file_read(bh_file* file, void* buffer, isize buff_size) {
     return bh_file_read_at(file, bh_file_tell(file), buffer, buff_size, NULL);
 }
 
-b32 bh_file_write(bh_file* file, void* buffer, isize buff_size) {
+i32 bh_file_write(bh_file* file, void* buffer, isize buff_size) {
     return bh_file_write_at(file, bh_file_tell(file), buffer, buff_size, NULL);
 }