Give temporary variables unique names.

This commit is contained in:
Bill Currie 2011-02-09 10:04:55 +09:00
parent 681ded9375
commit 68cdc904f5
2 changed files with 7 additions and 2 deletions

View file

@ -56,6 +56,7 @@ typedef struct function_s {
int function_num;
string_t s_file; ///< source file with definition
string_t s_name;
int temp_num; ///< number for next temp var
struct def_s *def;
struct symbol_s *sym;
struct symtab_s *symtab;

View file

@ -108,9 +108,13 @@ get_operand_def (expr_t *expr, operand_t *op)
zero_def.type = &type_short;
return &zero_def; //FIXME
case op_temp:
if (!op->o.def)
op->o.def = new_def (".tmp", ev_types[op->type],
if (!op->o.def) {
const char *temp_name;
temp_name = va (".tmp%d", current_func->temp_num++);
op->o.def = new_def (temp_name, ev_types[op->type],
current_func->symtab->space, st_local);
}
return op->o.def;
case op_pointer:
def = op->o.pointer->def;