- /* 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
+ m_nil->setCodeAddress(m_code->globals.size());
+ m_code->globals.push_back(0);
+ m_code->globals.push_back(0);
+ m_code->globals.push_back(0);
+
+ // generate virtual-instruction temps
+ for (size_t i = 0; i < IR_MAX_VINSTR_TEMPS; ++i) {
+ m_vinstr_temp[i]->setCodeAddress(m_code->globals.size());
+ m_code->globals.push_back(0);
+ m_code->globals.push_back(0);
+ m_code->globals.push_back(0);
+ }
+
+ // generate global temps
+ m_first_common_globaltemp = m_code->globals.size();
+ m_code->globals.insert(m_code->globals.end(), m_max_globaltemps, 0);
+ // FIXME:DELME:
+ //for (size_t i = 0; i < m_max_globaltemps; ++i) {
+ // m_code->globals.push_back(0);
+ //}
+ // generate common locals
+ m_first_common_local = m_code->globals.size();
+ m_code->globals.insert(m_code->globals.end(), m_max_locals, 0);
+ // FIXME:DELME:
+ //for (i = 0; i < m_max_locals; ++i) {
+ // m_code->globals.push_back(0);
+ //}
+
+ // generate function code
+
+ for (auto& gp : m_globals) {
+ ir_value *global = gp.get();
+ if (global->m_vtype == TYPE_FUNCTION) {
+ if (!this->generateGlobalFunctionCode(global))