Initially was working on vargs but we need a new algorithm to match lambda call arguments

This commit is contained in:
Krzosa Karol
2022-06-20 16:23:35 +02:00
parent 9700742515
commit 9f7d51ff02
3 changed files with 11 additions and 3 deletions

View File

@@ -347,6 +347,7 @@ ast_expr_binary(Ast_Expr *left, Ast_Expr *right, Token *op){
function Ast_Call *
ast_call(Token *pos, Ast_Expr *name, Array<Ast_Call_Item *> exprs){
// name here specifies also typespec for compound expressions !
AST_NEW(Call, CALL, pos, AST_EXPR);
result->name = name;
result->exprs = exprs.tight_copy(pctx->perm);

View File

@@ -462,6 +462,8 @@ gen_ast(Ast *ast){
CASE(IF, If){
For(node->ifs){
gen_line(node);
genln("");
if(it->init) {
gen_expr(it->init);
gen(";");
@@ -629,7 +631,9 @@ gen_ast(Ast *ast){
For(node->cases){
For_Named(it->labels, label){
genln("case ");
gen_line(it);
genln("");
gen("case ");
gen_expr(label);
gen(":");
}

View File

@@ -614,7 +614,7 @@ resolve_stmt(Ast *ast, Ast_Type *ret){
}
For_Named(it->scope->stmts, stmt) resolve_stmt(stmt, ret);
}
For_Named(node->default_scope->stmts, stmt) resolve_stmt(stmt, ret);
if(node->default_scope) For_Named(node->default_scope->stmts, stmt) resolve_stmt(stmt, ret);
BREAK();
}
@@ -1187,11 +1187,14 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
// @note: check if all arguments are included and cleanup
For(node->exprs){
if(!is_flag_set(it->call_flags, CALL_INCLUDED))
compiler_error(it->pos, "Invalid argument to function call");
compiler_error(it->pos, "Unknown argument to a function call, couldn't match it with any of the declared arguments");
else unset_flag(it->call_flags, CALL_INCLUDED);
}
return operand_rvalue(name.type->func.ret);
//
// CALL End
//
BREAK();
}