aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-20 10:27:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-20 10:27:27 +0000
commitd75631e6369a9927d66b277a4c0f2f935f32a7cc (patch)
tree9052099bf0d320c315bd1201960091993bcd0886 /compile.c
parentce760e0a9c737166ee190cd2cf28b0b379033991 (diff)
downloadruby-d75631e6369a9927d66b277a4c0f2f935f32a7cc.tar.gz
compile.c: binary logop check
* compile.c (compile_branch_condition): turn recursion at binary logical operator into loop by goto, and check the result of RHS of NODE_OR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/compile.c b/compile.c
index 7d42cc603c..bfdcb959ed 100644
--- a/compile.c
+++ b/compile.c
@@ -2902,6 +2902,7 @@ static int
compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *cond,
LABEL *then_label, LABEL *else_label)
{
+ again:
switch (nd_type(cond)) {
case NODE_AND:
{
@@ -2909,9 +2910,8 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *cond,
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
else_label));
ADD_LABEL(ret, label);
- CHECK(compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
- else_label));
- break;
+ cond = cond->nd_2nd;
+ goto again;
}
case NODE_OR:
{
@@ -2919,9 +2919,8 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *cond,
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
label));
ADD_LABEL(ret, label);
- compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
- else_label);
- break;
+ cond = cond->nd_2nd;
+ goto again;
}
case NODE_LIT: /* NODE_LIT is always true */
case NODE_TRUE: