*
* Breaking conventions is annoying...
*/
-static bool ir_builder_gen_global(ir_builder *self, ir_value *global);
+static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal);
static bool gen_global_field(ir_value *global)
{
local_var_end = fun.firstlocal;
for (i = 0; i < irfun->locals_count; ++i) {
- if (!ir_builder_gen_global(ir, irfun->locals[i])) {
+ if (!ir_builder_gen_global(ir, irfun->locals[i], true)) {
irerror(irfun->locals[i]->context, "Failed to generate local %s", irfun->locals[i]->name);
return false;
}
return true;
}
-static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
+static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal)
{
size_t i;
int32_t *iptr;
ir_value_code_setaddr(global, code_globals_add(*iptr));
} else {
ir_value_code_setaddr(global, code_globals_add(0));
- def.type |= DEF_SAVEGLOBAL;
+ if (!islocal)
+ def.type |= DEF_SAVEGLOBAL;
}
if (code_defs_add(def) < 0)
return false;
ir_value_code_setaddr(global, code_globals_add(code_cachedstring(global->constval.vstring)));
else {
ir_value_code_setaddr(global, code_globals_add(0));
- def.type |= DEF_SAVEGLOBAL;
+ if (!islocal)
+ def.type |= DEF_SAVEGLOBAL;
}
if (code_defs_add(def) < 0)
return false;
if (code_globals_add(0) < 0)
return false;
}
- def.type |= DEF_SAVEGLOBAL;
+ if (!islocal)
+ def.type |= DEF_SAVEGLOBAL;
}
if (code_defs_add(def) < 0)
code_globals_add(code_functions_elements);
if (!gen_global_function(self, global))
return false;
- def.type |= DEF_SAVEGLOBAL;
+ if (!islocal)
+ def.type |= DEF_SAVEGLOBAL;
}
if (code_defs_add(def) < 0)
return false;
for (i = 0; i < self->globals_count; ++i)
{
- if (!ir_builder_gen_global(self, self->globals[i])) {
+ if (!ir_builder_gen_global(self, self->globals[i], false)) {
return false;
}
}