From: Wolfgang (Blub) Bumiller Date: Thu, 3 May 2012 10:40:49 +0000 (+0200) Subject: ast_function_label now takes a labelname to prefix the id with X-Git-Tag: 0.1-rc1~507 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=91bf040f0acee5539816b499e605612cbf336dd0;p=xonotic%2Fgmqcc.git ast_function_label now takes a labelname to prefix the id with --- diff --git a/ast.c b/ast.c index a909e73..baad821 100644 --- 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 2112ae4..13d351a 100644 --- 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);