Added MRB_API function to get block arguments info.

- ` mrb_block_given_p()` -- The name comes from CRuby's `rb_block_given_p ()`

At the same time, it applies to `f_instance_eval()` and `f_class_eval()` of `mruby-eval`.
This commit is contained in:
dearblue
2021-06-19 15:08:09 +09:00
committed by Yukihiro "Matz" Matsumoto
parent 43eddfd4d5
commit c40802865a
3 changed files with 20 additions and 14 deletions
+11
View File
@@ -859,6 +859,17 @@ mrb_get_arg1(mrb_state *mrb)
return array_argv[0];
}
MRB_API mrb_bool
mrb_block_given_p(mrb_state *mrb)
{
const mrb_callinfo *ci = mrb->c->ci;
int argc = ci->argc;
int idx = (argc < 0) ? 2 : argc + 1;
mrb_value b = ci->stack[idx];
return !mrb_nil_p(b);
}
void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
/*