ANN static void emit_pre_ctor(const Emitter emit, const Type type) {
if(type->info->parent)
emit_pre_ctor(emit, type->info->parent);
- maybe_ctor(emit, type);
if(tflag(type, tflag_typedef) && type->info->parent->array_depth)
- emit_array_extend(emit, type->info->parent, type->info->cdef->base.ext->array->exp);
+ emit_array_extend(emit, type, type->info->cdef->base.ext->array->exp);
+ maybe_ctor(emit, type);
}
ANN static void struct_expand(const Emitter emit, const Type t) {
for(m_uint i = 1; i < t->array_depth; ++i)
vector_add(&info->type, (vtype)array_type(emit->env, base, i));
vector_add(&info->type, (vtype)t);
- info->depth = (m_int)t->array_depth;
+ info->depth = !tflag(t, tflag_typedef) ? t->array_depth : t->info->parent->array_depth;
info->base = base;
return info;
}
ANN m_bool emit_array_extend(const Emitter emit, const Type t, const Exp e) {
CHECK_OB(emit_array_extend_inner(emit, t, e, 0))
- emit_add_instr(emit, PopArrayClass);
+ regpop(emit, SZ_INT);
+ const Instr instr = emit_add_instr(emit, Reg2Reg);
+ instr->m_val = -SZ_INT;
emit_add_instr(emit, RegAddRef);
return GW_OK;
}
ANN M_Object new_array(MemPool p, const Type t, const m_uint length) {
const M_Object a = new_object(p, NULL, t);
- const m_uint depth = t->array_depth;
+ const m_uint depth = !tflag(t, tflag_typedef) ? t->array_depth : t->info->parent->array_depth;
const m_uint size = depth > 1 ? SZ_INT : array_base(t)->size;
ARRAY(a) = new_m_vector(p, size,length);
return a;
vm_shred_exit(shred);
}
-INSTR(PopArrayClass) {
- POP_REG(shred, SZ_INT);
- const M_Object obj = *(M_Object*)REG(-SZ_INT);
- const M_Object tmp = *(M_Object*)REG(0);
- ARRAY(obj) = ARRAY(tmp);
- free_object(shred->info->mp, tmp);
-}
-
ANN static Func_Def from_base(const Env env, struct dottmpl_ *const dt, const Nspc nspc) {
const Func_Def fdef = dt->def ?: dt->base;
const Symbol sym = func_symbol(env, nspc->name, s_name(fdef->base->xid),