the IR won't create globals of the same name - make names starting with # an exception

This commit is contained in:
Wolfgang Bumiller 2012-07-20 21:36:37 +02:00
parent 21a2679efb
commit 7756cb9205
2 changed files with 11 additions and 4 deletions

4
ast.c
View file

@ -510,8 +510,10 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir)
}
v = ir_builder_create_global(ir, self->name, self->expression.vtype);
if (!v)
if (!v) {
printf("ir_builder_create_global failed\n");
return false;
}
if (self->isconst) {
switch (self->expression.vtype)

11
ir.c
View file

@ -206,9 +206,14 @@ ir_value* ir_builder_get_global(ir_builder *self, const char *name)
ir_value* ir_builder_create_global(ir_builder *self, const char *name, int vtype)
{
ir_value *ve = ir_builder_get_global(self, name);
if (ve) {
return NULL;
ir_value *ve;
if (name && name[0] != '#')
{
ve = ir_builder_get_global(self, name);
if (ve) {
return NULL;
}
}
ve = ir_value_var(name, store_global, vtype);