]> Nishi Git Mirror - gwion.git/commitdiff
:art: use emit_jump
authorfennecdjay <fennecdjay@gmail.com>
Wed, 14 Dec 2022 12:37:19 +0000 (13:37 +0100)
committerfennecdjay <fennecdjay@gmail.com>
Wed, 14 Dec 2022 12:37:19 +0000 (13:37 +0100)
src/emit/emit.c

index c7d0df0fce53cf9a4bacd4cc6c07477d8daae9a8..ceba3b50c11bad0caf3705413bf693a1f34f2e32 100644 (file)
@@ -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) {