summaryrefslogtreecommitdiff
path: root/vm_args.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-03 04:43:07 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-03 04:43:07 (GMT)
commitef25be739196ce019f1918736151e0daa0e93f19 (patch)
tree7240be35b2b2e0a699fe10e81989776f0e8cb5b9 /vm_args.c
parent888e16c51ec6dd4b6aeb94cb44ee70e8f2d102b4 (diff)
* vm_core.h: change semantics of opt_num and opt_table.
`opt_num' was the number of optional parameters + 1. `opt_table' has "opt_num" entries. Change them to: `opt_num' is the number of optional parameters. `opt_talbe' has "opt_num + 1" entries. This change simplify parameter fitting logics. * compile.c: catch up this change. * iseq.c: ditto. * proc.c: ditto. * vm_args.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_args.c')
-rw-r--r--vm_args.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/vm_args.c b/vm_args.c
index 989fc10..e4d7fed 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -523,7 +523,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq, r
VALUE * const locals, const enum arg_setup_type arg_setup_type)
{
const int min_argc = iseq->param.lead_num + iseq->param.post_num;
- const int max_argc = (iseq->param.flags.has_rest == FALSE) ? min_argc + (iseq->param.opt_num - (iseq->param.flags.has_opt == TRUE)) : UNLIMITED_ARGUMENTS;
+ const int max_argc = (iseq->param.flags.has_rest == FALSE) ? min_argc + iseq->param.opt_num : UNLIMITED_ARGUMENTS;
int opt_pc = 0;
int given_argc;
struct args_info args_body, *args;
@@ -570,8 +570,8 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq, r
break; /* do nothing special */
case arg_setup_block:
if (given_argc == 1 &&
- (min_argc > 0 ||
- iseq->param.opt_num > 2 || iseq->param.flags.has_kw || iseq->param.flags.has_kwrest) && /* TODO: can be shrink with flags */
+ (min_argc > 0 || iseq->param.opt_num > 1 ||
+ iseq->param.flags.has_kw || iseq->param.flags.has_kwrest) &&
!iseq->param.flags.ambiguous_param0 &&
args_check_block_arg0(args, th, msl)) {
given_argc = RARRAY_LENINT(args->rest);
@@ -632,7 +632,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq, r
}
if (iseq->param.flags.has_opt) {
- int opt = args_setup_opt_parameters(args, iseq->param.opt_num - 1, locals + iseq->param.lead_num);
+ int opt = args_setup_opt_parameters(args, iseq->param.opt_num, locals + iseq->param.lead_num);
opt_pc = (int)iseq->param.opt_table[opt];
}