From: Jérémie Astor Date: Sun, 31 May 2020 18:59:50 +0000 (+0200) Subject: :bug: Fix static code emission X-Git-Tag: nightly~1497 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=76473afdc3a0ea4cae6c8096a21e9e1c99b82506;p=gwion.git :bug: Fix static code emission --- diff --git a/src/emit/emit.c b/src/emit/emit.c index a08ce3cc..0545d4b0 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1070,7 +1070,8 @@ ANN Instr emit_exp_call1(const Emitter emit, const Func f) { instr->m_val2 = val2; } else if(f->value_ref->from->owner_class && f != emit->env->func && !f->code&& ! is_fptr(emit->gwion, f->value_ref->type)){ /* not yet emitted static func */ - const Instr instr = (Instr)vector_back(&emit->code->instr); + const Instr instr = vector_size(&emit->code->instr) ? + (Instr)vector_back(&emit->code->instr) : emit_add_instr(emit, PushStaticCode); assert(instr->opcode == ePushStaticCode); instr->opcode = eRegPushImm; const Instr pushcode = emit_add_instr(emit, PushStaticCode);