From f2cf7e1c025c98d9526fe95da0945eb105345d3d Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 12 Dec 2023 21:38:19 -0600 Subject: [PATCH] cleanup: macos compiler build errors --- compiler/build.sh | 4 ++-- compiler/src/astnodes.c | 14 ++++++++------ compiler/src/checker.c | 9 +++++++++ compiler/src/clone.c | 3 ++- compiler/src/doc.c | 21 ++++++++++++--------- compiler/src/onyx.c | 16 ++++++++-------- compiler/src/parser.c | 2 +- compiler/src/polymorph.h | 2 ++ compiler/src/symres.c | 10 ++++++++-- compiler/src/types.c | 4 +++- compiler/src/utils.c | 9 ++++++++- compiler/src/wasm_emit.c | 24 ++++++++++++++++++------ compiler/src/wasm_output.h | 5 +++-- compiler/src/wasm_runtime.c | 12 ++++++------ compiler/src/wasm_type_table.h | 4 ++++ shared/include/bh.h | 8 ++++---- 16 files changed, 98 insertions(+), 49 deletions(-) diff --git a/compiler/build.sh b/compiler/build.sh index e20154dd..c8b657aa 100755 --- a/compiler/build.sh +++ b/compiler/build.sh @@ -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 diff --git a/compiler/src/astnodes.c b/compiler/src/astnodes.c index 3fcba62d..b7e17d93 100644 --- a/compiler/src/astnodes.c +++ b/compiler/src/astnodes.c @@ -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; diff --git a/compiler/src/checker.c b/compiler/src/checker.c index 363edabd..860ae511 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -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; } } diff --git a/compiler/src/clone.c b/compiler/src/clone.c index 449899b0..d9639938 100644 --- a/compiler/src/clone.c +++ b/compiler/src/clone.c @@ -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; diff --git a/compiler/src/doc.c b/compiler/src/doc.c index 01814026..003e91c4 100644 --- a/compiler/src/doc.c +++ b/compiler/src/doc.c @@ -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(¶m_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(¶m_type_buf); write_type_node(¶m_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(¶m_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); diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index 4c9308c5..c87f9874 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -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(); diff --git a/compiler/src/parser.c b/compiler/src/parser.c index b89077a6..13d4e1f4 100644 --- a/compiler/src/parser.c +++ b/compiler/src/parser.c @@ -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], diff --git a/compiler/src/polymorph.h b/compiler/src/polymorph.h index bd97a95d..ecc1ae6c 100644 --- a/compiler/src/polymorph.h +++ b/compiler/src/polymorph.h @@ -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); diff --git a/compiler/src/symres.c b/compiler/src/symres.c index ff929261..0a9947fc 100644 --- a/compiler/src/symres.c +++ b/compiler/src/symres.c @@ -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; diff --git a/compiler/src/types.c b/compiler/src/types.c index 805f7102..9f0d41e1 100644 --- a/compiler/src/types.c +++ b/compiler/src/types.c @@ -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; diff --git a/compiler/src/utils.c b/compiler/src/utils.c index dab01847..4995c521 100644 --- a/compiler/src/utils.c +++ b/compiler/src/utils.c @@ -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; diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index d47696c8..e092579c 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -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); } } diff --git a/compiler/src/wasm_output.h b/compiler/src/wasm_output.h index ee5273ae..c44ffe09 100644 --- a/compiler/src/wasm_output.h +++ b/compiler/src/wasm_output.h @@ -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); diff --git a/compiler/src/wasm_runtime.c b/compiler/src/wasm_runtime.c index a5038330..e232d8b9 100644 --- a/compiler/src/wasm_runtime.c +++ b/compiler/src/wasm_runtime.c @@ -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) { diff --git a/compiler/src/wasm_type_table.h b/compiler/src/wasm_type_table.h index 9e2b46c5..630c6132 100644 --- a/compiler/src/wasm_type_table.h +++ b/compiler/src/wasm_type_table.h @@ -773,6 +773,10 @@ static u64 build_type_table(OnyxWasmModule* module) { break; } + + case Type_Kind_Invalid: + case Type_Kind_Count: + break; } } diff --git a/shared/include/bh.h b/shared/include/bh.h index 70e6bf08..5f55a52b 100644 --- a/shared/include/bh.h +++ b/shared/include/bh.h @@ -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); } -- 2.25.1