diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-11 22:44:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-11 22:44:26 +0000 |
commit | cd7b59e4f2b15f2a9353777dce8d577e17bc8276 (patch) | |
tree | 353858dee17cddc252a4ab910bc4a53a4bb29814 /compile.c | |
parent | f19b0418375af4b46443034fa6dfec636bcfaf63 (diff) | |
download | ruby-cd7b59e4f2b15f2a9353777dce8d577e17bc8276.tar.gz |
compile.c: iseq_compile_each0
* compile.c (iseq_compile_each0): split from null node case to
constify line and type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -4156,6 +4156,7 @@ compile_when(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped) return COMPILE_OK; } +static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped); /** compile each node @@ -4166,10 +4167,6 @@ compile_when(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped) static int iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped) { - enum node_type type; - LINK_ELEMENT *saved_last_element = 0; - int line; - if (node == 0) { if (!popped) { debugs("node: NODE_NIL(implicit)\n"); @@ -4177,8 +4174,16 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe } return COMPILE_OK; } + return iseq_compile_each0(iseq, ret, node, popped); +} + - line = (int)nd_line(node); +static int +iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped) +{ + LINK_ELEMENT *saved_last_element = 0; + const int line = (int)nd_line(node); + const enum node_type type = nd_type(node); if (ISEQ_COMPILE_DATA(iseq)->last_line == line) { /* ignore */ @@ -4195,8 +4200,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe #undef BEFORE_RETURN #define BEFORE_RETURN debug_node_end() - type = nd_type(node); - switch (type) { case NODE_BLOCK:{ while (node && nd_type(node) == NODE_BLOCK) { @@ -5332,7 +5335,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe } /* args */ - if (nd_type(node) != NODE_VCALL) { + if (type != NODE_VCALL) { argc = setup_args(iseq, args, node->nd_args, &flag, &keywords); } else { @@ -5345,7 +5348,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe debugp_param("call args argc", argc); debugp_param("call method", ID2SYM(mid)); - switch (nd_type(node)) { + switch ((int)type) { case NODE_VCALL: flag |= VM_CALL_VCALL; /* VCALL is funcall, so fall through */ @@ -5373,7 +5376,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe INIT_ANCHOR(args); ISEQ_COMPILE_DATA(iseq)->current_block = NULL; - if (nd_type(node) == NODE_SUPER) { + if (type == NODE_SUPER) { VALUE vargc = setup_args(iseq, args, node->nd_args, &flag, &keywords); argc = FIX2INT(vargc); } |