From e7f7e8fab727d2e1dc28a6606fd00e736beda803 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 7 Sep 2021 01:55:15 +0200 Subject: [PATCH] :art: small fixes --- src/emit/emit.c | 8 ++++---- src/lib/array.c | 16 ++++++---------- src/parse/check.c | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 18d55e6b..5d41d5c1 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1560,10 +1560,10 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f, instr->m_val = (m_uint)f; } else { const Instr back = (Instr)vector_back(&emit->code->instr); - if(back->execute != SetFunc) { - const Instr instr = emit_add_instr(emit, SetFunc); - instr->m_val = (m_uint)f; - } + if(back->execute != SetFunc) { + const Instr instr = emit_add_instr(emit, SetFunc); + instr->m_val = (m_uint)f; + } } } const m_uint offset = emit_code_offset(emit); diff --git a/src/lib/array.c b/src/lib/array.c index 954a9db5..fa41f106 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -17,7 +17,6 @@ static DTOR(array_dtor) { if (*(void **)(o->data + SZ_INT)) xfree(*(void **)(o->data + SZ_INT)); struct M_Vector_ *a = ARRAY(o); -// free_m_vector(shred->info->mp, a); m_vector_release(a); } @@ -321,26 +320,23 @@ ANN static void array_loop(const Emitter emit, const m_uint depth) { access->m_val = depth * SZ_INT; } -ANN static void array_finish(const Emitter emit, const m_uint depth, - const Type t, const m_bool is_var) { +ANN static void array_finish(const Emitter emit, const Array_Sub array, const m_bool is_var) { const Instr get = emit_add_instr(emit, is_var ? ArrayAddr : ArrayGet); - if(!is_var && isa(t, emit->gwion->type[et_object]) > 0) { - const m_uint _depth = get_depth(t); - if(_depth < depth || isa(array_base(t), emit->gwion->type[et_object]) > 0) + const Type t = array->type; + if(!is_var) { + if(array->depth < get_depth(t) || isa(array_base(t), emit->gwion->type[et_object]) > 0) emit_add_instr(emit, GWOP_EXCEPT); } - get->m_val = depth * SZ_INT; - // emit_add_instr(emit, ArrayValid); + get->m_val = array->depth * SZ_INT; const Instr push = emit_add_instr(emit, RegMove); push->m_val = is_var ? SZ_INT : t->size; } ANN static inline m_bool array_do(const Emitter emit, const Array_Sub array, const m_bool is_var) { - // emit_gc(emit, -SZ_INT); CHECK_BB(emit_exp(emit, array->exp)); array_loop(emit, array->depth); - array_finish(emit, array->depth, array->type, is_var); + array_finish(emit, array, is_var); return GW_OK; } diff --git a/src/parse/check.c b/src/parse/check.c index 6a281cf6..51dbad9e 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1726,7 +1726,7 @@ ANN m_bool check_abstract(const Env env, const Class_Def cdef) { if (!cdef->base.type->nspc->vtable.ptr) return GW_OK; bool err = false; for (m_uint i = 0; i < vector_size(&cdef->base.type->nspc->vtable); ++i) { - Func f = (Func)vector_at(&cdef->base.type->nspc->vtable, i); + const Func f = (Func)vector_at(&cdef->base.type->nspc->vtable, i); if (f && GET_FLAG(f->def->base, abstract)) { if (!err) { err = true; -- 2.43.0