From: Wolfgang (Blub) Bumiller Date: Wed, 2 May 2012 17:25:25 +0000 (+0200) Subject: create the ir_function in ast_function_codegen, keep the current ir_block stored... X-Git-Tag: 0.1-rc1~518 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=13082112b071c0e6c0a5f9bd408c2afa7613b75b;p=xonotic%2Fgmqcc.git create the ir_function in ast_function_codegen, keep the current ir_block stored in ast_function so inner codegens can use it --- diff --git a/ast.c b/ast.c index 5f8025c..7a2b7a5 100644 --- a/ast.c +++ b/ast.c @@ -267,6 +267,7 @@ ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype) MEM_VECTOR_INIT(self, blocks); self->ir_func = NULL; + self->curblock = NULL; vtype->isconst = true; vtype->constval.vfunc = self; @@ -421,13 +422,20 @@ error: /* clean up */ bool ast_function_codegen(ast_function *self, ir_builder *ir) { - ir_value *dummy; + ir_function *irf; + ir_value *dummy; size_t i; - if (!self->ir_func) { + + irf = self->ir_func; + if (!irf) { printf("ast_function's related ast_value was not generated yet\n"); return false; } + self->curblock = ir_function_create_block(irf, "entry"); + if (!self->curblock) + return false; + for (i = 0; i < self->blocks_count; ++i) { ast_expression_codegen *gen = self->blocks[i]->expression.codegen; if (!(*gen)((ast_expression*)self->blocks[i], self, false, &dummy)) diff --git a/ast.h b/ast.h index bea59d5..9609a08 100644 --- a/ast.h +++ b/ast.h @@ -274,6 +274,7 @@ struct ast_function_s const char *name; ir_function *ir_func; + ir_block *curblock; MEM_VECTOR_MAKE(ast_block*, blocks); };