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; };
}
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;
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;
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);
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;
if (curr != NULL && curr->kind != Ast_Kind_Error) {
*prev = curr;
prev = (AstArgument **) &curr->next;
+
+ call_node->arg_count++;
}
if (parser->curr->type == ')')