]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve static_code/ allow recursive spork 107/head
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 10 Mar 2019 11:36:05 +0000 (12:36 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 10 Mar 2019 11:37:20 +0000 (12:37 +0100)
src/emit/emit.c
src/vm/vm.c

index ddbc5dcd04a5c373930033f0154bebbd1546d113..56fe9dfeab61d6c3a54ad7c3837f43b8fa579b13 100644 (file)
@@ -846,8 +846,13 @@ ANN static m_bool spork_func(const Emitter emit, const Exp_Call* exp) { GWDEBUG_
   push_spork_code(emit, SPORK_FUNC_PREFIX, exp->self->pos);
   if(GET_FLAG(exp->m_func, member))
     SET_FLAG(emit->code, member);
-  const Instr p = emit_add_instr(emit, RegPushImm);
-  p->m_val = (m_uint)exp->m_func->code;
+  if(exp->m_func->code) {
+    const Instr p = emit_add_instr(emit, RegPushImm);
+    p->m_val = (m_uint)exp->m_func->code;
+  } else {
+    const Instr p = emit_add_instr(emit, PushStaticCode);
+    p->m_val = (m_uint)exp->m_func;
+  }
   CHECK_BB(emit_exp_call1(emit, exp->m_func))
   const VM_Code code = finalyze(emit);
   const m_uint size = exp->m_func->def->stack_depth - (GET_FLAG(exp->m_func,
index a0897ebef78ffc2f6f1cecf7e7cad1f63a24e061..6c4928feda6d3a12d2311e2f2cc64b1356717c2b 100644 (file)
@@ -766,7 +766,8 @@ dotstaticfunc:
   *(VM_Code*)(reg-SZ_INT) = ((Func)vector_at(a.obj->vtable, instr->m_val))->code;
   DISPATCH()
 staticcode:
-  (*(VM_Code*)reg = ((Func)instr->m_val)->code);
+  instr->m_val = (m_uint)((*(VM_Code*)reg = ((Func)instr->m_val)->code));
+  instr->opcode = (m_bit)(m_uint)RegPushImm;
   reg += SZ_INT;
   DISPATCH()
 pushstr: