summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-15 00:45:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-15 00:45:14 +0000
commitbc33c5ce0ae4a6146d58a5b037d3ba4bc66ed01a (patch)
tree2ee03f13e1b2cf37a1cc8d47ac56c7b916aa9162
parentb0e2c2476e75c710866dacc03b672b3314f50c6e (diff)
compile.c: compile_retry
* compile.c (compile_retry): extract from iseq_compile_each. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/compile.c b/compile.c
index b04d0dcba8..4ce73d0f75 100644
--- a/compile.c
+++ b/compile.c
@@ -4578,6 +4578,26 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped)
return COMPILE_OK;
}
+static int
+compile_retry(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped)
+{
+ const int line = nd_line(node);
+
+ if (iseq->body->type == ISEQ_TYPE_RESCUE) {
+ ADD_INSN(ret, line, putnil);
+ ADD_INSN1(ret, line, throw, INT2FIX(TAG_RETRY));
+
+ if (popped) {
+ ADD_INSN(ret, line, pop);
+ }
+ }
+ else {
+ COMPILE_ERROR(ERROR_ARGS "Invalid retry");
+ return COMPILE_NG;
+ }
+ return COMPILE_OK;
+}
+
static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped);
/**
compile each node
@@ -4752,21 +4772,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp
case NODE_REDO:
CHECK(compile_redo(iseq, ret, node, popped));
break;
- case NODE_RETRY:{
- if (iseq->body->type == ISEQ_TYPE_RESCUE) {
- ADD_INSN(ret, line, putnil);
- ADD_INSN1(ret, line, throw, INT2FIX(TAG_RETRY));
-
- if (popped) {
- ADD_INSN(ret, line, pop);
- }
- }
- else {
- COMPILE_ERROR(ERROR_ARGS "Invalid retry");
- goto ng;
- }
+ case NODE_RETRY:
+ CHECK(compile_retry(iseq, ret, node, popped));
break;
- }
case NODE_BEGIN:{
CHECK(COMPILE_(ret, "NODE_BEGIN", node->nd_body, popped));
break;