From: Jérémie Astor Date: Sun, 7 Nov 2021 15:09:32 +0000 (+0100) Subject: :art: cleans X-Git-Tag: nightly~413 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0211fff28bcc296f812ab8d7ee7ce5aca968fbdd;p=gwion.git :art: cleans --- diff --git a/include/emit.h b/include/emit.h index de188b50..4afb7e6d 100644 --- a/include/emit.h +++ b/include/emit.h @@ -11,10 +11,9 @@ typedef struct Frame_ { } Frame; typedef struct VMValue_ { - Type t; - void *local; /// :..... - uint16_t offset; - uint16_t start; + const Type t; + const uint16_t offset; + const uint16_t start; uint16_t end; } VMValue; diff --git a/include/object.h b/include/object.h index dae95eb4..872df60a 100644 --- a/include/object.h +++ b/include/object.h @@ -3,9 +3,7 @@ typedef struct M_Object_ *M_Object; struct M_Object_ { Type type_ref; -// struct Vector_ vtable; /*volatile */uint64_t ref; -// uint32_t offset; m_bit data[]; }; diff --git a/src/emit/emit.c b/src/emit/emit.c index 57224c1b..255caed3 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -293,7 +293,7 @@ ANN m_uint emit_local(const Emitter emit, const Type t) { 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; } @@ -304,7 +304,7 @@ ANN void* emit_localx(const Emitter emit, const Type t) { 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); @@ -961,26 +961,26 @@ ANN static Instr emit_struct_decl(const Emitter emit, const Value v, } 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, diff --git a/src/lib/object_op.c b/src/lib/object_op.c index 3765540d..d4c5d8d3 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -35,19 +35,8 @@ static OP_CHECK(opck_object_at) { 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) { @@ -55,7 +44,8 @@ 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