diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-02 23:14:21 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-02 23:14:21 +0000 |
commit | 831e33c7809a92da6d14f0e518f960034c5dabd0 (patch) | |
tree | a0308f28d043d963e8e2b21d68f0633655105693 /proc.c | |
parent | 5d1f152fa342f6bb5fa9b546e3971843ee81c6b1 (diff) | |
download | ruby-831e33c7809a92da6d14f0e518f960034c5dabd0.tar.gz |
* vm_core.h: change iseq parameter data structure.
https://bugs.ruby-lang.org/issues/10440#change-49694
* change terminology `arg' to `param'.
* move rb_iseq_t::arg_* to rb_iseq_t::param.
* move rb_iseq_t::arg_size to rb_iseq_t::param::size.
* move rb_iseq_t::argc to rb_iseq_t::param::lead_num.
* move rb_iseq_t::arg_opts to rb_iseq_t::param::opt_num.
* move rb_iseq_t::arg_rest to rb_iseq_t::param::rest_start.
* move rb_iseq_t::arg_post_num to rb_iseq_t::param::post_num.
* move rb_iseq_t::arg_post_start to rb_iseq_t::param::post_start.
* move rb_iseq_t::arg_block to rb_iseq_t::param::block_start.
* move rb_iseq_t::arg_keyword* to rb_iseq_t::param::keyword.
rb_iseq_t::param::keyword is allocated only when keyword
parameters are available.
* introduce rb_iseq_t::param::flags to represent parameter
availability. For example, rb_iseq_t::param::flags::has_kw
represents that this iseq has keyword parameters and
rb_iseq_t::param::keyword is allocated.
We don't need to compare with -1 to check availability.
* remove rb_iseq_t::arg_simple.
* compile.c: catch up this change.
* iseq.c: ditto.
* proc.c: ditto.
* vm.c, vm_args.c, vm_dump.c, vm_insnhelper.c: ditto.
* iseq.c (iseq_data_to_ary): support keyword argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -735,7 +735,7 @@ proc_call(int argc, VALUE *argv, VALUE procval) GetProcPtr(procval, proc); iseq = proc->block.iseq; - if (BUILTIN_TYPE(iseq) == T_NODE || iseq->arg_block != -1) { + if (BUILTIN_TYPE(iseq) == T_NODE || iseq->param.flags.has_block) { if (rb_block_given_p()) { rb_proc_t *passed_proc; RB_GC_GUARD(passed_procval) = rb_block_proc(); @@ -847,11 +847,13 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = iseq->arg_rest == -1 ? - iseq->argc + iseq->arg_post_num + iseq->arg_opts - - (iseq->arg_opts > 0) + (iseq->arg_keyword_num > 0) + (iseq->arg_keyword_rest >= 0) + *max = iseq->param.flags.has_rest == FALSE ? + iseq->param.lead_num + iseq->param.post_num + + iseq->param.opt_num - (iseq->param.flags.has_opt == TRUE) + + (iseq->param.flags.has_kw == TRUE) + + (iseq->param.flags.has_kwrest == TRUE) : UNLIMITED_ARGUMENTS; - return iseq->argc + iseq->arg_post_num + (iseq->arg_keyword_required > 0); + return iseq->param.lead_num + iseq->param.post_num + (iseq->param.flags.has_kw && iseq->param.keyword->required_num > 0); } static int |