]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix repeat loop with idx
authorJérémie Astor <fennecdjay@gmail.com>
Tue, 1 Jun 2021 21:38:29 +0000 (23:38 +0200)
committerJérémie Astor <fennecdjay@gmail.com>
Tue, 1 Jun 2021 21:38:29 +0000 (23:38 +0200)
src/emit/emit.c
src/vm/vm.c

index d836595ab1f48f73d85b28348c4c4798fcee0e91..8199a6e63b8e3bc1ab36b546129230e7176a8775 100644 (file)
@@ -2004,6 +2004,9 @@ ANN static m_bool _emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt,
     const Instr instr = emit_add_instr(emit, MemSetImm);
     instr->m_val = emit_local(emit, emit->gwion->type[et_int]);
     stmt->idx->v->from->offset = offset;
+    const Instr idx = emit_add_instr(emit, MemSetImm);
+    idx->m_val = offset;
+    idx->m_val2 = -1;
   }
   CHECK_BB(emit_exp_pop_next(emit, stmt->cond));
   regpop(emit, SZ_INT);
index fe2c110de02c0515ca90d28afdb12d56c08ace03..ba830d1fe6fa2e88a85b29527ecb072218004c66 100644 (file)
@@ -534,7 +534,7 @@ memaddimm:
 //  (*(m_int*)(mem+VAL))--;
   DISPATCH();
 repeatidx:
-  BRANCH_DISPATCH(*(m_int*)(mem+VAL2+SZ_INT) == (*(m_int*)(mem+VAL2))++);
+  BRANCH_DISPATCH(*(m_int*)(mem+VAL2+SZ_INT) == ++(*(m_int*)(mem+VAL2)));
 repeat:
   BRANCH_DISPATCH(!(*(m_uint*)(mem+VAL2))--);
 regpushme: