X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ast.c;h=ef24336cc4fd684812a07d822b1bc074eb756d5b;hp=0f5b05ca4a98383e22e61f4989c451ce94e353e5;hb=973122ed9bc0679d4f9bb0fde90f90d57c17c3d7;hpb=6dfdf69a8e96ea2f5f5e6f89bbe8fd6262268846 diff --git a/ast.c b/ast.c index 0f5b05c..ef24336 100644 --- a/ast.c +++ b/ast.c @@ -894,8 +894,9 @@ ast_call* ast_call_new(lex_ctx ctx, ast_side_effects(self) = true; - self->params = NULL; - self->func = funcexpr; + self->params = NULL; + self->func = funcexpr; + self->va_count = NULL; ast_type_adopt(self, funcexpr->expression.next); @@ -912,6 +913,9 @@ void ast_call_delete(ast_call *self) if (self->func) ast_unref(self->func); + if (self->va_count) + ast_unref(self->va_count); + ast_expression_delete((ast_expression*)self); mem_d(self); } @@ -3030,6 +3034,20 @@ bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value vec_push(params, param); } + /* varargs counter */ + if (self->va_count) { + ir_value *va_count; + ir_builder *builder = func->curblock->owner->owner; + cgen = self->va_count->expression.codegen; + if (!(*cgen)((ast_expression*)(self->va_count), func, false, &va_count)) + return false; + if (!ir_block_create_store_op(func->curblock, ast_ctx(self), INSTR_STORE_F, + ir_builder_get_va_count(builder), va_count)) + { + return false; + } + } + callinstr = ir_block_create_call(func->curblock, ast_ctx(self), ast_function_label(func, "call"), funval, !!(self->func->expression.flags & AST_FLAG_NORETURN));