summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-05 00:49:40 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-05 00:49:40 +0000
commit9c373683e39dc58664b45955d4cc04a27ad13f63 (patch)
tree879f024827b30a2725feee9ca067bc03fdcc748b /compile.c
parent0f806b4942e199de325489e322cab23c96ff8e6b (diff)
compile.c: refactoring of defined? exception handler
This commit removes tmp_node trick to create a special exception handler for `defined?`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/compile.c b/compile.c
index b876d9ab98..6280eab17e 100644
--- a/compile.c
+++ b/compile.c
@@ -4239,6 +4239,14 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
return 0;
}
+static VALUE
+build_defined_rescue_iseq(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *unused)
+{
+ ADD_INSN(ret, 0, putnil);
+ iseq_set_exception_local_table(iseq);
+ return Qnil;
+}
+
static int
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *const node, LABEL **lfinish, VALUE needstr)
@@ -4250,13 +4258,10 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
LABEL *lstart = NEW_LABEL(line);
LABEL *lend = NEW_LABEL(line);
const rb_iseq_t *rescue;
- NODE tmp_node, *node = &tmp_node;
- rb_node_init(node, NODE_NIL, 0, 0, 0);
- rescue = NEW_CHILD_ISEQ(node,
- rb_str_concat(rb_str_new2
- ("defined guard in "),
- iseq->body->location.label),
- ISEQ_TYPE_DEFINED_GUARD, 0);
+ rescue = new_child_iseq_ifunc(iseq, IFUNC_NEW(build_defined_rescue_iseq, 0, 0),
+ rb_str_concat(rb_str_new2("defined guard in "),
+ iseq->body->location.label),
+ iseq, ISEQ_TYPE_RESCUE, 0);
lstart->rescued = LABEL_RESCUE_BEG;
lend->rescued = LABEL_RESCUE_END;
APPEND_LABEL(ret, lcur, lstart);