Small bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Jul 2020 03:37:32 +0000 (22:37 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Jul 2020 03:37:32 +0000 (22:37 -0500)
include/onyxastnodes.h
onyx
src/onyxchecker.c
src/onyxparser.c

index ceacab399a9f1c56d08646c578d0f9a3dc6e8e34..3333e0a91f34d82f8854e72916d746267714eb67 100644 (file)
@@ -186,8 +186,8 @@ struct AstBinOp         { AstTyped_base; BinaryOp operation; AstTyped *left, *ri
 struct AstUnaryOp       { AstTyped_base; UnaryOp operation; AstTyped *expr; };
 struct AstNumLit        { AstTyped_base; union { i32 i; i64 l; f32 f; f64 d; } value; };
 struct AstLocal         { AstTyped_base; AstLocal *prev_local; };
-struct AstCall          { AstTyped_base; AstArgument *arguments; AstNode *callee; };
-struct AstIntrinsicCall { AstTyped_base; AstArgument *arguments; OnyxIntrinsic intrinsic; };
+struct AstCall          { AstTyped_base; AstArgument *arguments; u64 arg_count; AstNode *callee; };
+struct AstIntrinsicCall { AstTyped_base; AstArgument *arguments; u64 arg_count; OnyxIntrinsic intrinsic; };
 struct AstArgument      { AstTyped_base; AstTyped *value; };
 struct AstArrayAccess   { AstTyped_base; AstTyped *addr; AstTyped *expr; u64 elem_size; };
 
diff --git a/onyx b/onyx
index caa0034a88fcd8f9b213b21ddecf780df073bcd2..1aceef52da59ee69696deda612c369b9df42f195 100755 (executable)
Binary files a/onyx and b/onyx differ
index a61df5befb681642af9551c496e58ff4abd071e9..21f44b88bdeaac3af252b6233898f593634bab35 100644 (file)
@@ -78,11 +78,6 @@ static b32 check_while(SemState* state, AstWhile* whilenode) {
 }
 
 static AstTyped* match_overloaded_function(SemState* state, AstCall* call, AstOverloadedFunction* ofunc) {
-    u64 param_count = 0;
-    for (AstArgument* arg = call->arguments;
-            arg != NULL;
-            arg = (AstArgument *) arg->next) param_count++;
-
     bh_arr_each(AstTyped *, node, ofunc->overloads) {
         AstFunction* overload = (AstFunction *) *node;
 
@@ -90,7 +85,7 @@ static AstTyped* match_overloaded_function(SemState* state, AstCall* call, AstOv
 
         TypeFunction* ol_type = &overload->type->Function;
 
-        if (ol_type->param_count != param_count) continue;
+        if (ol_type->param_count != call->arg_count) continue;
 
         AstArgument* arg = call->arguments;
         Type** param_type = ol_type->params;
@@ -491,6 +486,9 @@ static b32 check_statement(SemState* state, AstNode* stmt) {
         case Ast_Kind_Call:       return check_call(state, (AstCall *) stmt);
         case Ast_Kind_Block:      return check_block(state, (AstBlock *) stmt);
 
+        case Ast_Kind_Break:      return 0;
+        case Ast_Kind_Continue:   return 0;
+
         default:
             stmt->flags |= Ast_Flag_Expr_Ignored;
             return check_expression(state, (AstTyped *) stmt);
index 034a6840a58010e49b85c7d002506e0721ea3b6c..2110bfedc63f8d4111dc580bd2ddb16a09bc2cc7 100644 (file)
@@ -191,6 +191,7 @@ static AstTyped* parse_factor(OnyxParser* parser) {
                 AstCall* call_node = make_node(AstCall, Ast_Kind_Call);
                 call_node->token = expect_token(parser, '(');
                 call_node->callee = (AstNode *) sym_node;
+                call_node->arg_count = 0;
 
                 AstArgument** prev = &call_node->arguments;
                 AstArgument* curr = NULL;
@@ -202,6 +203,8 @@ static AstTyped* parse_factor(OnyxParser* parser) {
                     if (curr != NULL && curr->kind != Ast_Kind_Error) {
                         *prev = curr;
                         prev = (AstArgument **) &curr->next;
+
+                        call_node->arg_count++;
                     }
 
                     if (parser->curr->type == ')')