From: Jérémie Astor Date: Mon, 6 Sep 2021 23:55:15 +0000 (+0200) Subject: :art: small fixes X-Git-Tag: nightly~464 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e7f7e8fab727d2e1dc28a6606fd00e736beda803;p=gwion.git :art: small fixes --- 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;