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
This commit is contained in:
parent
82092f4bb7
commit
4b39eaf4cc
11
compile.c
11
compile.c
@ -2902,6 +2902,7 @@ static int
|
|||||||
compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *cond,
|
compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *cond,
|
||||||
LABEL *then_label, LABEL *else_label)
|
LABEL *then_label, LABEL *else_label)
|
||||||
{
|
{
|
||||||
|
again:
|
||||||
switch (nd_type(cond)) {
|
switch (nd_type(cond)) {
|
||||||
case NODE_AND:
|
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,
|
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
|
||||||
else_label));
|
else_label));
|
||||||
ADD_LABEL(ret, label);
|
ADD_LABEL(ret, label);
|
||||||
CHECK(compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
|
cond = cond->nd_2nd;
|
||||||
else_label));
|
goto again;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case NODE_OR:
|
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,
|
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
|
||||||
label));
|
label));
|
||||||
ADD_LABEL(ret, label);
|
ADD_LABEL(ret, label);
|
||||||
compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
|
cond = cond->nd_2nd;
|
||||||
else_label);
|
goto again;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case NODE_LIT: /* NODE_LIT is always true */
|
case NODE_LIT: /* NODE_LIT is always true */
|
||||||
case NODE_TRUE:
|
case NODE_TRUE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user