From 5cd633526411268457c8b056d3e6b3aedd4a1664 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 14 Dec 2022 13:37:19 +0100 Subject: [PATCH] :art: use emit_jump --- src/emit/emit.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index c7d0df0f..ceba3b50 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2039,28 +2039,25 @@ ANN static inline m_bool emit_jump_index(const Emitter emit, const Vector v, return GW_ERROR; } -ANN static inline m_bool emit_stmt_continue(const Emitter emit, - const Stmt_Index stmt) { +ANN static inline m_bool emit_jump(const Emitter emit, const Stmt_Index stmt, + const Vector v) { CHECK_BB(emit_defers2(emit)); if (stmt->idx == -1 || stmt->idx == 1) - vector_add(&emit->code->stack_cont, (vtype)emit_add_instr(emit, Goto)); + vector_add(v, (vtype)emit_add_instr(emit, Goto)); else if (stmt->idx) { - if (emit_jump_index(emit, &emit->code->stack_cont, stmt->idx) < 0) + if (emit_jump_index(emit, v, stmt->idx) < 0) ERR_B(stmt_self(stmt)->pos, _("too many jumps required.")) } return GW_OK; } +ANN static inline m_bool emit_stmt_continue(const Emitter emit, + const Stmt_Index stmt) { + return emit_jump(emit, stmt, &emit->code->stack_cont); +} ANN static inline m_bool emit_stmt_break(const Emitter emit, const Stmt_Index stmt NUSED) { - CHECK_BB(emit_defers2(emit)); - if (stmt->idx == -1 || stmt->idx == 1) - vector_add(&emit->code->stack_break, (vtype)emit_add_instr(emit, Goto)); - else if (stmt->idx) { - if (emit_jump_index(emit, &emit->code->stack_break, stmt->idx) < 0) - ERR_B(stmt_self(stmt)->pos, _("too many jumps required.")) - } - return GW_OK; + return emit_jump(emit, stmt, &emit->code->stack_break); } ANN static inline void emit_push_stack(const Emitter emit) { -- 2.43.0