minor changes to parameter logic
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 11 Jan 2021 18:32:04 +0000 (12:32 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 11 Jan 2021 18:32:04 +0000 (12:32 -0600)
bin/onyx
core/string.onyx
onyx.exe
src/onyxchecker.c
src/onyxparser.c
src/onyxtypes.c
src/onyxwasm.c

index ebbda14d9289f47517d5a44649c4b1d8718913e5..738c0715811fbc631ce44b0777664f69ef1f916a 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 8bc25835cb85b554c3c97c83f65cb4e69b58e7c0..9f70b6fb41212af127346e51e4a524c7a7e98e73 100644 (file)
@@ -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;
index b6c2e962cef39d3e1e9b1ad30fb5d226b1b584c4..e585b16a24cb9f830e4d12094744a27d37fea8b6 100644 (file)
Binary files a/onyx.exe and b/onyx.exe differ
index 4d261ddc83591c4995165fee08cd918333fe01a3..49d1ab0f18cd7c429a64e342f129b9232efb4f84 100644 (file)
@@ -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;
index 022e4a446479fe1729a3cb56f2a53e334b9350ba..48ea0bf9cb3e0e3752cc969fe8edcd7b546f07ec 100644 (file)
@@ -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;
index c0403b7215882bc2441417d118d2e1bc5400617e..6da02121a3ffa8b0b4fd13582289de982fb8ecf7 100644 (file)
@@ -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);
 
index 57bf4e87fe5d8b8e25ca30b7882a8b6df1105d56..5b3deb6ba62e60a708726a536d83011a5df33283 100644 (file)
@@ -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);