From: fennecdjay Date: Fri, 28 Oct 2022 03:32:51 +0000 (+0200) Subject: :art: clean emit_local X-Git-Tag: nightly~207^2~108 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e3b667058f855d1c9193d735afea528ffe9d33e0;p=gwion.git :art: clean emit_local --- diff --git a/src/emit/emit.c b/src/emit/emit.c index cd116501..348c3065 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -296,9 +296,9 @@ ANN m_uint emit_code_offset(const Emitter emit) { return emit->code->frame->curr_offset; } -ANN m_uint emit_local(const Emitter emit, const Type t) { +ANN static Local * add_local(const Emitter emit, const Type t, const bool is_compound) { Local *const l = frame_local(emit->gwion->mp, emit->code->frame, t); - if (isa(t, emit->gwion->type[et_compound]) > 0) { + if (is_compound) { l->is_compound = true; VMValue vmval = { .t = t, @@ -308,19 +308,17 @@ ANN m_uint emit_local(const Emitter emit, const Type t) { m_vector_add(&emit->code->live_values, &vmval); ++emit->code->frame->value_count; } + return l; +} + +ANN m_uint emit_local(const Emitter emit, const Type t) { + const bool is_compound = isa(t, emit->gwion->type[et_compound]) > 0; + Local *const l = add_local(emit, t, is_compound); return l->offset; } 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, - .offset = l->offset, - .start = emit_code_size(emit) - }; - m_vector_add(&emit->code->live_values, &vmval); - ++emit->code->frame->value_count; + Local *const l = add_local(emit, t, 1); l->instr = emit_regtomem(emit, l->offset, -SZ_INT); return l; }