]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ast_function_label now takes a labelname to prefix the id with
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 3 May 2012 10:40:49 +0000 (12:40 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 3 May 2012 10:40:49 +0000 (12:40 +0200)
ast.c
ast.h

diff --git a/ast.c b/ast.c
index a909e735864f0090fb1935d31df85027e447562d..baad8210e1410eeda63b02113af6b7e75889dba3 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -368,10 +368,10 @@ void ast_function_delete(ast_function *self)
     mem_d(self);
 }
 
-const char* ast_function_label(ast_function *self)
+const char* ast_function_label(ast_function *self, const char *prefix)
 {
     size_t id = (self->labelcount++);
-    sprintf(self->labelbuf, "label%8u", (unsigned int)id);
+    sprintf(self->labelbuf, "%16s%8u", prefix, (unsigned int)id);
     return self->labelbuf;
 }
 
@@ -613,7 +613,7 @@ bool ast_binary_codegen(ast_binary *self, ast_function *func, bool lvalue, ir_va
     if (!(*cgen)((ast_expression*)(self->right), func, false, &right))
         return false;
 
-    *out = ir_block_create_binop(func->curblock, ast_function_label(func),
+    *out = ir_block_create_binop(func->curblock, ast_function_label(func, "bin"),
                                  self->op, left, right);
     if (!*out)
         return false;
@@ -641,10 +641,10 @@ bool ast_entfield_codegen(ast_entfield *self, ast_function *func, bool lvalue, i
 
     if (lvalue) {
         /* address! */
-        *out = ir_block_create_fieldaddress(func->curblock, ast_function_label(func),
+        *out = ir_block_create_fieldaddress(func->curblock, ast_function_label(func, "efa"),
                                             ent, field);
     } else {
-        *out = ir_block_create_load_from_ent(func->curblock, ast_function_label(func),
+        *out = ir_block_create_load_from_ent(func->curblock, ast_function_label(func, "efv"),
                                              ent, field, self->expression.vtype);
     }
     if (!*out)
@@ -674,7 +674,7 @@ bool ast_ifthen_codegen(ast_ifthen *self, ast_function *func, bool lvalue, ir_va
 
     if (self->on_true) {
         /* create on-true block */
-        ontrue = ir_function_create_block(func->ir_func, ast_function_label(func));
+        ontrue = ir_function_create_block(func->ir_func, ast_function_label(func, "ontrue"));
         if (!ontrue)
             return false;
     } else
@@ -682,13 +682,13 @@ bool ast_ifthen_codegen(ast_ifthen *self, ast_function *func, bool lvalue, ir_va
     
     if (self->on_false) {
         /* create on-false block */
-        onfalse = ir_function_create_block(func->ir_func, ast_function_label(func));
+        onfalse = ir_function_create_block(func->ir_func, ast_function_label(func, "onfalse"));
         if (!onfalse)
             return false;
     } else
         onfalse = NULL;
 
-    merge = ir_function_create_block(func->ir_func, ast_function_label(func));
+    merge = ir_function_create_block(func->ir_func, ast_function_label(func, "endif"));
     if (!merge)
         return NULL;
 
diff --git a/ast.h b/ast.h
index 2112ae42be2f1c9374a5812466831f835f62c630..13d351a60bfe12f3c1ae761a7233b7d7b03a927c 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -297,7 +297,7 @@ void ast_function_delete(ast_function*);
  * For "optimized" builds this can just keep returning "foo"...
  * or whatever...
  */
-const char* ast_function_label(ast_function*);
+const char* ast_function_label(ast_function*, const char *prefix);
 
 MEM_VECTOR_PROTO(ast_function, ast_block*, blocks);