From 2deda85fee9b9f33454a6deb22cd7357aa196257 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 18 May 2021 21:41:51 +0200 Subject: [PATCH] Update --- scripts/nanorc.sh | 2 +- src/emit/emit.c | 7 +++---- src/vm/vm.c | 2 +- util | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/nanorc.sh b/scripts/nanorc.sh index 909cc3e9..4f8f0874 100644 --- a/scripts/nanorc.sh +++ b/scripts/nanorc.sh @@ -125,7 +125,7 @@ color italic,green "\<(protected|private)\>" color bold,green "\<(var|late|const)\>" color bold,italic,green "\<(const)\>" -color bold,yellow "\<(for|until|if|while|do|else|match|case|when|where|defer)\>" +color bold,yellow "\<(for|foreach|repeat|until|if|while|do|else|match|case|when|where|defer)\>" color magenta "\<(goto|continue|break|return)\>" ## Comment highlighting diff --git a/src/emit/emit.c b/src/emit/emit.c index 80f2dc7c..5e3ed476 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1789,18 +1789,18 @@ ANN static inline m_bool unroll_run(const Emitter emit, const struct Looper *loo } ANN static m_bool unroll(const Emitter emit, const struct Looper *loop) { + const Instr gc = scoped_ini(emit); const Instr unroll = emit_add_instr(emit, Unroll); unroll->m_val = loop->offset; const m_uint start = emit_code_size(emit); - const Instr gc = scoped_ini(emit); CHECK_BB(unroll_run(emit, loop)); const m_uint end = emit_code_size(emit); for(m_uint i = 1; i < loop->n; ++i) CHECK_BB(unroll_run(emit, loop)); unroll->m_val2 = end - start; - scoped_end(emit, gc); const Instr unroll2 = emit_add_instr(emit, Unroll2); unroll2->m_val = (m_uint)unroll; + scoped_end(emit, gc); return GW_OK; } @@ -1884,9 +1884,8 @@ ANN static m_bool _emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt, m_ui emit_local(emit, emit->gwion->type[et_int]); CHECK_BB(emit_exp_pop_next(emit, stmt->cond)); regpop(emit, SZ_INT); -// set mem const Instr tomem = emit_add_instr(emit, Reg2Mem); - tomem->m_val = offset + !stmt->idx ? 0 : SZ_INT; + tomem->m_val = offset + (!stmt->idx ? 0 : SZ_INT); *index = emit_code_size(emit); struct Looper loop = { .stmt=stmt->body, .offset=offset, .n=n, .roll= !stmt->idx ? stmt_loop_roll : stmt_loop_roll_idx}; diff --git a/src/vm/vm.c b/src/vm/vm.c index 06f4cd8b..902013ac 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -806,7 +806,7 @@ unroll: DISPATCH() } *(m_uint*)(mem + VAL) = 0; - PC_DISPATCH(PC + VAL2*(idx)); + PC_DISPATCH(PC + VAL2*(idx+1)); } PC_DISPATCH(PC + VAL2 *n + 1); } diff --git a/util b/util index c5170484..7f657c4d 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit c51704848c29ab1934021f94ee2ece981e6e8468 +Subproject commit 7f657c4d12c8a4362d26b1976ddca5de2324d60a -- 2.43.0