const Type t = decl->type;
const bool emit_addr = exp_getvar(exp_self(decl));
if (decl->args) {
++//exp_setvar(decl->args, emit_addr);
const Instr instr = (Instr)vector_back(&emit->code->instr);
CHECK_BB(emit_exp(emit, decl->args));
if (emit_addr) {
emit_regmove(emit, -t->size);
-- vector_add(&emit->code->instr, (m_uint)instr);
++// emit_regmove(emit, SZ_INT -t->size);
++// const Instr instr = emit_add_instr(emit, Reg2RegAddr);
++ const Instr instr = emit_add_instr(emit, RegPushMem4);
++// emit_add_instr(emit, EOC);
++// instr->m_val = -SZ_INT;
++// vector_add(&emit->code->instr, (m_uint)instr);
}
return GW_OK;
}
ANN2(1) /*static */ m_bool emit_exp(const Emitter emit, /* const */ Exp e) {
Exp exp = e;
do {
++ e->start = emit_code_size(emit);
if (emit->info->debug && emit->status.line < e->pos.first.line) {
const Instr instr = emit_add_instr(emit, DebugLine);
instr->m_val = emit->status.line = e->pos.first.line;
static OP_EMIT(opem_struct_assign) {
const Exp_Binary *bin = data;
const Type t = bin->lhs->type;
++ const Exp e = exp_self(bin);
++ if(unlikely(exp_getvar(e))) {
++ for(m_int i = vector_size(&emit->code->instr); --i > e->start && i;) {
++ const Instr instr = (Instr)vector_at(&emit->code->instr, i-1);
++ free_instr(emit->gwion, instr);
++ }
++ VLEN(&emit->code->instr) = e->start;
++ exp_setvar(bin->lhs, true);
++ CHECK_BB(emit_exp(emit, bin->lhs));
++ CHECK_BB(emit_exp(emit, bin->rhs));
++ emit_add_instr(emit, Assign);
++ return GW_OK;
++ }
++// need to add ref counting (release former)
if(t->size == SZ_INT) emit_add_instr(emit, int_r_assign);
else if(t->size == SZ_FLOAT) emit_add_instr(emit, float_r_assign);
else {
-- const Instr instr = emit_add_instr(emit, Reg2RegOther);
++ const Instr instr = (Instr)emit_add_instr(emit, Reg2RegOther);
instr->m_val = -(t->size + SZ_INT);
instr->m_val2 = t->size;
emit_regmove(emit, -SZ_INT);
return GW_OK;
}
++ANN static OP_CHECK(opck_struct_assign) {
++ CHECK_NN(opck_rassign(env, data));
++ Exp_Binary *bin = data;
++ exp_setnomut(exp_self(bin), true);
++ return bin->lhs->type;
++}
++
ANN static void scan0_struct_assign(const Env env, const Type t) {
-- struct Op_Func opfunc = {.ck = opck_rassign, .em = opem_struct_assign };
++ struct Op_Func opfunc = {.ck = opck_struct_assign, .em = opem_struct_assign };
struct Op_Import opi = {
.op = insert_symbol(":=>"), .lhs = t, .rhs = t, .ret = t, .func = &opfunc};
add_op(env->gwion, &opi);