]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
create the ir_function in ast_function_codegen, keep the current ir_block stored...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 2 May 2012 17:25:25 +0000 (19:25 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 2 May 2012 17:25:25 +0000 (19:25 +0200)
ast.c
ast.h

diff --git a/ast.c b/ast.c
index 5f8025cebeaba6d6211d2f7300b4165177310133..7a2b7a59f721a42bb52abefe906ae71519201d8c 100644 (file)
--- 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 bea59d57b25055e87ea0793e52ef94d2df6201ee..9609a08d678600d2a44fe4b741203c40e5da0b4f 100644 (file)
--- 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);
 };