diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-05 00:49:40 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-05 00:49:40 +0000 |
commit | 9c373683e39dc58664b45955d4cc04a27ad13f63 (patch) | |
tree | 879f024827b30a2725feee9ca067bc03fdcc748b | |
parent | 0f806b4942e199de325489e322cab23c96ff8e6b (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
-rw-r--r-- | compile.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -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); |