diff --git a/ast.c b/ast.c index ef24336..ebded6a 100644 --- a/ast.c +++ b/ast.c @@ -1582,6 +1582,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir) if (self->varargs) { if (!ast_local_codegen(self->varargs, self->ir_func, true)) return false; + irf->max_varargs = self->varargs->expression.count; } if (self->builtin) { diff --git a/ir.c b/ir.c index f743d33..bd8f12f 100644 --- a/ir.c +++ b/ir.c @@ -485,6 +485,8 @@ ir_function* ir_function_new(ir_builder* owner, int outtype) self->values = NULL; self->locals = NULL; + self->max_varargs = NULL; + self->code_function_def = -1; self->allocated_locals = 0; self->globaltemps = 0; diff --git a/ir.h b/ir.h index b1b0ea7..c2c94a1 100644 --- a/ir.h +++ b/ir.h @@ -273,6 +273,9 @@ typedef struct ir_function_s size_t run_id; struct ir_builder_s *owner; + + /* vararg support: */ + size_t max_varargs; } ir_function; #define IR_FLAG_HAS_ARRAYS (1<<1) #define IR_FLAG_HAS_UNINITIALIZED (1<<2)