Commit 57e345c7 authored by Masaki Muranaka's avatar Masaki Muranaka

Use mrb_true_or_false_value() / in mrb_f_block_given_p_m().

parent 70baae25
......@@ -219,21 +219,28 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self)
{
mrb_callinfo *ci = mrb->ci;
mrb_value *bp;
mrb_bool given_p;
bp = mrb->stbase + ci->stackidx + 1;
ci--;
if (ci <= mrb->cibase) return mrb_false_value();
/* block_given? called within block; check upper scope */
if (ci->proc->env && ci->proc->env->stack) {
if (ci->proc->env->stack == mrb->stbase || mrb_nil_p(ci->proc->env->stack[1]))
return mrb_false_value();
return mrb_true_value();
if (ci <= mrb->cibase) {
given_p = 0;
}
if (ci->argc > 0) {
bp += ci->argc;
else {
/* block_given? called within block; check upper scope */
if (ci->proc->env && ci->proc->env->stack) {
given_p = !(ci->proc->env->stack == mrb->stbase ||
mrb_nil_p(ci->proc->env->stack[1]));
}
else {
if (ci->argc > 0) {
bp += ci->argc;
}
given_p = !mrb_nil_p(*bp);
}
}
if (mrb_nil_p(*bp)) return mrb_false_value();
return mrb_true_value();
return mrb_true_or_false_value(given_p);
}
/* 15.3.1.3.7 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment