while((e = e->next));
const Type type = array->type;
const Type base = array_base(type);
+ const Instr push = emit_add_instr(emit, RegPushImm);
+ push->m_val = count;
const Instr instr = emit_add_instr(emit, ArrayInit);
- instr->m_val = count;
+ instr->m_val = (m_uint)type;
instr->m_val2 = base->size;
- *(Type*)instr->ptr = type;
return GW_OK;
}
}
INSTR(ArrayInit) { GWDEBUG_EXE // for litteral array
- const m_uint off = instr->m_val * instr->m_val2;
- const Type t = *(Type*)instr->ptr;
- POP_REG(shred, off - SZ_INT);
- const M_Object obj = new_array(t, instr->m_val);
- vector_add(&shred->gc, (vtype)obj);
+ const Type t = (Type)instr->m_val;
+ const m_uint sz = *(m_uint*)REG(-SZ_INT);
+ const m_uint off = instr->m_val2 * sz;
+ POP_REG(shred, off /*- SZ_INT*/);
+ const M_Object obj = new_array(t, sz);
memcpy(ARRAY(obj)->ptr + ARRAY_OFFSET, REG(-SZ_INT), off);
*(M_Object*)REG(-SZ_INT) = obj;
}