- /* generate nil */
- ir_value_code_setaddr(self->nil, vec_size(self->code->globals));
- vec_push(self->code->globals, 0);
- vec_push(self->code->globals, 0);
- vec_push(self->code->globals, 0);
-
- /* generate virtual-instruction temps */
- for (i = 0; i < IR_MAX_VINSTR_TEMPS; ++i) {
- ir_value_code_setaddr(self->vinstr_temp[i], vec_size(self->code->globals));
- vec_push(self->code->globals, 0);
- vec_push(self->code->globals, 0);
- vec_push(self->code->globals, 0);
- }
-
- /* generate global temps */
- self->first_common_globaltemp = vec_size(self->code->globals);
- for (i = 0; i < self->max_globaltemps; ++i) {
- vec_push(self->code->globals, 0);
- }
- /* generate common locals */
- self->first_common_local = vec_size(self->code->globals);
- for (i = 0; i < self->max_locals; ++i) {
- vec_push(self->code->globals, 0);
- }
-
- /* generate function code */
- for (i = 0; i < vec_size(self->globals); ++i)
- {
- if (self->globals[i]->vtype == TYPE_FUNCTION) {
- if (!gen_global_function_code(self, self->globals[i])) {
+ // generate nil
+ ir_value_code_setaddr(self->m_nil, self->m_code->globals.size());
+ self->m_code->globals.push_back(0);
+ self->m_code->globals.push_back(0);
+ self->m_code->globals.push_back(0);
+
+ // generate virtual-instruction temps
+ for (size_t i = 0; i < IR_MAX_VINSTR_TEMPS; ++i) {
+ ir_value_code_setaddr(self->m_vinstr_temp[i], self->m_code->globals.size());
+ self->m_code->globals.push_back(0);
+ self->m_code->globals.push_back(0);
+ self->m_code->globals.push_back(0);
+ }
+
+ // generate global temps
+ self->m_first_common_globaltemp = self->m_code->globals.size();
+ self->m_code->globals.insert(self->m_code->globals.end(), self->m_max_globaltemps, 0);
+ // FIXME:DELME:
+ //for (size_t i = 0; i < self->m_max_globaltemps; ++i) {
+ // self->m_code->globals.push_back(0);
+ //}
+ // generate common locals
+ self->m_first_common_local = self->m_code->globals.size();
+ self->m_code->globals.insert(self->m_code->globals.end(), self->m_max_locals, 0);
+ // FIXME:DELME:
+ //for (i = 0; i < self->m_max_locals; ++i) {
+ // self->m_code->globals.push_back(0);
+ //}
+
+ // generate function code
+
+ for (auto& gp : self->m_globals) {
+ ir_value *global = gp.get();
+ if (global->m_vtype == TYPE_FUNCTION) {
+ if (!gen_global_function_code(self, global)) {