]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix static code emission
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 31 May 2020 18:59:50 +0000 (20:59 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 31 May 2020 18:59:50 +0000 (20:59 +0200)
src/emit/emit.c

index a08ce3cc167fba058831cad0a86c494a4047d9e2..0545d4b03bc1d262d05853b4c05021c5605a5efd 100644 (file)
@@ -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);