summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index d03f031b9e..f099654d1c 100644
--- a/eval.c
+++ b/eval.c
@@ -2862,6 +2862,7 @@ class_prefix(self, cpath)
NORETURN(static void return_jump _((VALUE)));
NORETURN(static void break_jump _((VALUE)));
+NORETURN(static void next_jump _((VALUE)));
NORETURN(static void unknown_node _((NODE * volatile)));
static void
@@ -3200,8 +3201,7 @@ rb_eval(self, n)
case NODE_NEXT:
CHECK_INTS;
- return_value(rb_eval(self, node->nd_stts));
- JUMP_TAG(TAG_NEXT);
+ next_jump(rb_eval(self, node->nd_stts));
break;
case NODE_REDO:
@@ -3283,7 +3283,6 @@ rb_eval(self, n)
POP_TAG();
if (state != TAG_RAISE) ruby_errinfo = e_info;
if (state) {
- if (state == TAG_NEXT) prot_tag->retval = result;
JUMP_TAG(state);
}
/* no exception raised */
@@ -4816,6 +4815,32 @@ break_jump(retval)
localjump_error("unexpected break", retval, TAG_BREAK);
}
+static void
+next_jump(retval)
+ VALUE retval;
+{
+ struct tag *tt = prot_tag;
+
+ if (retval == Qundef) retval = Qnil;
+ while (tt) {
+ switch (tt->tag) {
+ case PROT_THREAD:
+ case PROT_YIELD:
+ case PROT_LOOP:
+ case PROT_LAMBDA:
+ case PROT_FUNC:
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_NEXT);
+ break;
+ default:
+ break;
+ }
+ tt = tt->prev;
+ }
+ localjump_error("unexpected next", retval, TAG_NEXT);
+}
+
void
rb_need_block()
{