if (isa(t, emit->gwion->type[et_compound]) > 0) {
l->is_compound = true;
VMValue vmval = {
- .t = t, .local = l, .offset = l->offset, .start = emit_code_size(emit)};
+ .t = t, .offset = l->offset, .start = emit_code_size(emit)};
m_vector_add(&emit->code->live_values, &vmval);
++emit->code->frame->value_count;
}
Local *const l = frame_local(emit->gwion->mp, emit->code->frame, t);
l->is_compound = true;
VMValue vmval = {
- .t = t, .local = l, .offset = l->offset, .start = emit_code_size(emit)};
+ .t = t, .offset = l->offset, .start = emit_code_size(emit)};
m_vector_add(&emit->code->live_values, &vmval);
++emit->code->frame->value_count;
l->instr = emit_add_instr(emit, Reg2Mem);
}
ANN void unset_local(const Emitter emit, Local *const l) {
-puts("unset");
l->instr->opcode = eNoOp;
for(m_uint i = m_vector_size(&emit->code->live_values) + 1; --i;) {
VMValue vmval = *(VMValue*)(ARRAY_PTR((&emit->code->live_values)) + (i-1) * sizeof(VMValue));
-// if(vmval.offset != l->offset) continue;
- if(vmval.local != l) continue;
+ if(vmval.offset != l->offset) continue;
m_vector_rem(&emit->code->live_values, i-1);
- vector_rem2(&emit->code->frame->stack, (vtype)l);
-//vector_rem2(&emit->code->instr, l->instr);
-// free instr
+ vector_rem2(&emit->code->frame->stack, (m_uint)l);
+ vector_rem2(&emit->code->instr, (m_uint)l->instr);
+ free_instr(emit->gwion, l->instr);
+ emit->code->frame->curr_offset -= l->type->size;
--emit->code->frame->value_count;
break;
}
}
ANN static m_uint decl_non_static_offset(const Emitter emit, const Exp_Decl *decl, const Type t) {
-// if(!exp_self(decl)->data)
+ if(!exp_self(decl)->data)
return emit_local(emit, t);
-// Local *const l = exp_self(decl)->data;
-// return l->offset;
+ const Local *l = exp_self(decl)->data;
+ exp_self(decl)->data = (void*)-1;
+ return l->offset;
}
ANN static m_bool emit_exp_decl_non_static(const Emitter emit,
exp_setvar(bin->rhs, 1);
CHECK_BO(isa(bin->lhs->type, bin->rhs->type));
bin->lhs->ref = bin->rhs;
-// bin->lhs->acquire = true;
-// bin->rhs-> = bin->lhs;
return bin->rhs->type;
}
-/*
-static bool exp_func(const Exp exp) {
-// was is_new
- return exp->exp_type == ae_exp_call;
-//&&
-// exp->d.exp_call.func->exp_type == ae_exp_dot &&
-// !strcmp(s_name(exp->d.exp_call.func->type->info->func->def->base->xid), "new"):
-}
-*/
ANN void unset_local(const Emitter emit, void *const l);
static OP_EMIT(opem_object_at) {
if(!bin->rhs->data) {
const Instr addref = emit_add_instr(emit, RegAddRef);
addref->m_val = -SZ_INT * 2;
- } else unset_local(emit, bin->rhs->data);
+ } else if(bin->rhs->data != (void*)-1)
+ unset_local(emit, bin->rhs->data);
if (bin->rhs->exp_type != ae_exp_decl)
(void)emit_add_instr(emit, ObjectAssign);
else