]> Nishi Git Mirror - gwion.git/commitdiff
:art: push switch map on the stack
authorfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 15 Feb 2019 16:44:34 +0000 (17:44 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 15 Feb 2019 16:44:34 +0000 (17:44 +0100)
src/emit/emit.c
src/lib/instr.c

index e0abb3893adc34d73bf2bed3a8d3756bbbfecd1a..5607d957a885d08a62b8e0ebd32cd209c7b65792 100644 (file)
@@ -1168,6 +1168,9 @@ ANN static m_bool emit_switch_instr(const Emitter emit, Instr *instr) {
       CHECK_BB(emit_exp(emit, e, 0))
     *instr = emit_add_instr(emit, SwitchIni);
     (*instr)->m_val = (m_uint)switch_vec(emit->env);
+  } else {
+    const Instr instr = emit_add_instr(emit, RegPushImm);
+    instr->m_val = (m_uint)switch_map(emit->env);
   }
   return GW_OK;
 }
index 4ee856b7c7630cd61a9ad2bd37cacdb888187e50..3702658b8714a316ae4d7d05ce1b9f748230e79e 100644 (file)
@@ -43,10 +43,9 @@ INSTR(SwitchIni) {
 }
 
 INSTR(BranchSwitch) { GWDEBUG_EXE
-  const m_uint offset = *(m_uint*)instr->ptr;
-  POP_REG(shred, SZ_INT + offset);
-  const Map map = !offset ?(Map)instr->m_val2 : *(Map*)REG(0);
-  shred->pc = map_get(map, *(m_uint*)REG(offset));
+  POP_REG(shred, SZ_INT*2);
+  const Map map = *(Map*)REG(0);
+  shred->pc = map_get(map, *(m_uint*)REG(SZ_INT));
   if(!shred->pc)
     shred->pc = instr->m_val;
 }