From: Jérémie Astor Date: Tue, 1 Jun 2021 21:38:29 +0000 (+0200) Subject: :bug: Fix repeat loop with idx X-Git-Tag: nightly~613 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=96f2a16bead81cd565d987f23e3b2071fa10c245;p=gwion.git :bug: Fix repeat loop with idx --- diff --git a/src/emit/emit.c b/src/emit/emit.c index d836595a..8199a6e6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -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); diff --git a/src/vm/vm.c b/src/vm/vm.c index fe2c110d..ba830d1f 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -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: