From: Brendan Hansen Date: Sat, 18 Jul 2020 03:37:32 +0000 (-0500) Subject: Small bugfixes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=6faef25ba031c684605723453ad17d93a5fcbaf4;p=onyx.git Small bugfixes --- diff --git a/include/onyxastnodes.h b/include/onyxastnodes.h index ceacab39..3333e0a9 100644 --- a/include/onyxastnodes.h +++ b/include/onyxastnodes.h @@ -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 caa0034a..1aceef52 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index a61df5be..21f44b88 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -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); diff --git a/src/onyxparser.c b/src/onyxparser.c index 034a6840..2110bfed 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -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 == ')')