From: Brendan Hansen Date: Mon, 11 Jan 2021 18:32:04 +0000 (-0600) Subject: minor changes to parameter logic X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=3e0a9d71f60a5a51ccbfac8f492cbe1a687d035a;p=onyx.git minor changes to parameter logic --- diff --git a/bin/onyx b/bin/onyx index ebbda14d..738c0715 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/core/string.onyx b/core/string.onyx index 8bc25835..9f70b6fb 100644 --- a/core/string.onyx +++ b/core/string.onyx @@ -103,7 +103,7 @@ compare :: proc (str1: str, str2: str) -> i32 { return ~~(str1[i] - str2[i]); } -equal :: proc (str1: str, str2: str) -> bool { +equal :: proc (str1: str, str2: str) -> bool #operator== { if str1.count != str2.count do return false; while i := 0; i < str1.count { if str1[i] != str2[i] do return false; diff --git a/onyx.exe b/onyx.exe index b6c2e962..e585b16a 100644 Binary files a/onyx.exe and b/onyx.exe differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index 4d261ddc..49d1ab0f 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -294,6 +294,7 @@ CheckStatus check_switch(AstSwitch* switchnode) { return 0; } + static AstTyped* match_overloaded_function(bh_arr(AstTyped *) arg_arr, bh_arr(AstTyped *) overloads) { bh_arr_each(AstTyped *, node, overloads) { AstFunction* overload = NULL; @@ -311,8 +312,12 @@ static AstTyped* match_overloaded_function(bh_arr(AstTyped *) arg_arr, bh_arr(As TypeFunction* ol_type = &overload->type->Function; if (bh_arr_length(arg_arr) < (i32) ol_type->needed_param_count) continue; + i32 param_left = ol_type->param_count; Type** param_type = ol_type->params; bh_arr_each(AstTyped*, arg, arg_arr) { + if (param_left == 0) goto no_match; + param_left--; + fill_in_type(*arg); Type* type_to_match = *param_type; diff --git a/src/onyxparser.c b/src/onyxparser.c index 022e4a44..48ea0bf9 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -1726,7 +1726,6 @@ static void parse_function_params(OnyxParser* parser, AstFunction* func) { curr_param.vararg_kind = VA_Kind_Not_VA; curr_param.local = make_node(AstLocal, Ast_Kind_Param); curr_param.local->token = symbol; - curr_param.local->flags |= Ast_Flag_Const; if (param_use) { curr_param.local->flags |= Ast_Flag_Param_Use; diff --git a/src/onyxtypes.c b/src/onyxtypes.c index c0403b72..6da02121 100644 --- a/src/onyxtypes.c +++ b/src/onyxtypes.c @@ -348,6 +348,8 @@ Type* type_build_from_ast(bh_allocator alloc, AstType* type_node) { s_type->Struct.name = s_node->name; s_type->Struct.mem_count = bh_arr_length(s_node->members); s_type->Struct.memarr = NULL; + s_type->Struct.poly_sln = NULL; + bh_table_init(global_heap_allocator, s_type->Struct.members, s_type->Struct.mem_count); bh_arr_new(global_heap_allocator, s_type->Struct.memarr, s_type->Struct.mem_count); diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 57bf4e87..5b3deb6b 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -331,7 +331,7 @@ EMIT_FUNC(assignment, AstBinaryOp* assign) { AstTyped* lval = assign->left; - if (lval->kind == Ast_Kind_Local) { + if (lval->kind == Ast_Kind_Local || lval->kind == Ast_Kind_Param) { if (bh_imap_get(&mod->local_map, (u64) lval) & LOCAL_IS_WASM) { u64 localidx = bh_imap_get(&mod->local_map, (u64) lval); emit_expression(mod, &code, assign->right);