60 for (i=args->
argc; i<min_argc; i++) {
72 if (len > over_argc) {
84 args->
argc -= over_argc;
96 else if (args->
argc == 1) {
147 else if (args->
argc > 0) {
154 static inline const VALUE *
180 if (!
NIL_P(*rest_hash_ptr)) {
182 if (!hash) hash =
Qnil;
200 *kw_hash_ptr = args->
argv[args->
argc-1];
204 args->
argv[args->
argc-1] = rest_hash;
244 const int kw_start = args->
argc - kw_len;
248 args->
argc = kw_start + 1;
249 for (i=0; i<kw_len; i++) {
265 const int passed_keyword_len = kw_arg->
keyword_len;
267 for (i=0; i<passed_keyword_len; i++) {
284 if (args->
argc >= argc) {
293 for (i=args->
argc, j=0; i<argc; i++, j++) {
316 if (args->
argc >= opt_max) {
317 args->
argc -= opt_max;
318 args->
argv += opt_max;
336 for (j=i; j<opt_max; j++) {
357 for (i=0; i<passed_keyword_len; i++) {
358 if (kw_argv[i] !=
Qundef) {
371 for (i=0; i<passed_keyword_len; i++) {
372 if (kw_argv[i] !=
Qundef) {
385 for (i=0; i<passed_keyword_len; i++) {
386 if (keyname == passed_keywords[i]) {
387 *ptr = passed_values[i];
388 passed_values[i] =
Qundef;
405 int i, di, found = 0;
406 int unspecified_bits = 0;
409 for (i=0; i<req_key_num; i++) {
410 ID key = acceptable_keywords[i];
422 for (di=0; i<key_num; i++, di++) {
427 if (default_values[di] ==
Qundef) {
431 unspecified_bits |= 0x01 << di;
434 if (
NIL_P(unspecified_bits_value)) {
439 for (j=0; j<32; j++) {
440 if (unspecified_bits & (0x01 << j)) {
449 locals[i] = default_values[di];
455 const int rest_hash_index = key_num + 1;
456 locals[rest_hash_index] =
make_rest_kw_hash(passed_keywords, passed_keyword_len, passed_values);
459 if (found != passed_keyword_len) {
465 if (
NIL_P(unspecified_bits_value)) {
466 unspecified_bits_value =
INT2FIX(unspecified_bits);
468 locals[key_num] = unspecified_bits_value;
546 for (i=calling->
argc; i<iseq->body->param.size; i++) {
549 th->
cfp->
sp = &locals[i];
553 given_argc = args->argc = calling->
argc;
560 int kw_len = args->kw_arg->keyword_len;
563 args->argc -= kw_len;
564 given_argc -= kw_len;
565 MEMCPY(args->kw_argv, locals + args->argc,
VALUE, kw_len);
568 args->kw_argv =
NULL;
574 args->kw_argv =
NULL;
578 args->rest = locals[--args->argc];
579 args->rest_index = 0;
586 switch (arg_setup_type) {
590 if (given_argc == 1 &&
603 if (given_argc < min_argc) {
604 if (given_argc == min_argc - 1 && args->kw_argv) {
611 given_argc = min_argc;
620 if (given_argc > min_argc &&
622 args->kw_argv ==
NULL) {
632 given_argc = max_argc;
659 if (args->kw_argv !=
NULL) {
663 else if (!
NIL_P(keyword_hash)) {
691 fprintf(stderr,
"local[%d] = %p\n", i, (
void *)locals[i]);
696 th->
cfp->
sp = orig_sp;
738 VALUE ary = argv[argc-1];
748 for (i = 0; i <
len; i++) {
751 calling->
argc += i - 1;
765 for (i=0; i<kw_len; i++) {
770 cfp->
sp -= kw_len - 1;
771 calling->
argc -= kw_len - 1;
783 "wrong argument type %s (expected Proc)",
805 mid =
SYM2ID(callback_arg);
808 if (!
NIL_P(blockarg)) {
822 VALUE block_code = *(--reg_cfp->
sp);
824 if (
NIL_P(block_code)) {
847 else if (blockiseq !=
NULL) {
862 #define IS_ARGS_SPLAT(ci) ((ci)->flag & VM_CALL_ARGS_SPLAT) 863 #define IS_ARGS_KEYWORD(ci) ((ci)->flag & VM_CALL_KWARG) 865 #define CALLER_SETUP_ARG(cfp, calling, ci) do { \ 866 if (UNLIKELY(IS_ARGS_SPLAT(ci))) vm_caller_setup_arg_splat((cfp), (calling)); \ 867 if (UNLIKELY(IS_ARGS_KEYWORD(ci))) vm_caller_setup_arg_kw((cfp), (calling), (ci)); \
#define VM_CALL_ARGS_BLOCKARG
VALUE rb_ary_unshift(VALUE ary, VALUE item)
static void raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc)
VALUE rb_ary_pop(VALUE ary)
static void vm_passed_block_handler_set(rb_thread_t *th, VALUE block_handler)
VALUE rb_vm_backtrace_object(void)
const rb_callable_method_entry_t * rb_callable_method_entry_with_refinements(VALUE klass, ID id)
static void vm_caller_setup_arg_splat(rb_control_frame_t *cfp, struct rb_calling_info *calling)
static void args_copy(struct args_info *args)
static int setup_parameters_complex(rb_thread_t *const th, const rb_iseq_t *const iseq, struct rb_calling_info *const calling, const struct rb_call_info *ci, VALUE *const locals, const enum arg_setup_type arg_setup_type)
static int keyword_hash_p(VALUE *kw_hash_ptr, VALUE *rest_hash_ptr, rb_thread_t *th)
VALUE rb_hash_dup(VALUE hash)
static unsigned int hash(str, len) register const char *str
VALUE rb_ary_subseq(VALUE ary, long beg, long len)
struct rb_iseq_constant_body::@196::@197 flags
VALUE rb_ary_push(VALUE ary, VALUE item)
#define VM_BLOCK_HANDLER_NONE
#define GET_BLOCK_HANDLER()
SSL_METHOD *(* func)(void)
static VALUE VM_BH_TO_SYMBOL(VALUE block_handler)
VALUE rb_ary_tmp_new(long capa)
struct rb_iseq_constant_body * body
static void argument_arity_error(rb_thread_t *th, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc)
static VALUE args_rest_array(struct args_info *args)
struct rb_call_info_kw_arg * kw_arg
void rb_raise(VALUE exc, const char *fmt,...)
struct rb_iseq_constant_body::@196 param
parameter information
#define VM_CALL_ARGS_SPLAT
VALUE rb_hash_lookup(VALUE hash, VALUE key)
RUBY_EXTERN VALUE rb_cProc
static void argument_kw_error(rb_thread_t *th, const rb_iseq_t *iseq, const char *error, const VALUE keys)
static void args_setup_lead_parameters(struct args_info *args, int argc, VALUE *locals)
const char * rb_obj_classname(VALUE)
static rb_control_frame_t * vm_push_frame(rb_thread_t *th, const rb_iseq_t *iseq, VALUE type, VALUE self, VALUE specval, VALUE cref_or_me, const VALUE *pc, VALUE *sp, int local_size, int stack_max)
static const VALUE * args_rest_argv(struct args_info *args)
static VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
VALUE rb_vm_make_proc(rb_thread_t *th, const struct rb_captured_block *captured, VALUE klass)
const VALUE * iseq_encoded
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
void rb_hash_foreach(VALUE hash, int(*func)(ANYARGS), VALUE farg)
void rb_exc_raise(VALUE mesg)
static const struct rb_captured_block * VM_BH_TO_CAPT_BLOCK(VALUE block_handler)
static void args_setup_post_parameters(struct args_info *args, int argc, VALUE *locals)
VALUE rb_extract_keywords(VALUE *orighash)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static int args_setup_kw_parameters_lookup(const ID key, VALUE *ptr, const VALUE *const passed_keywords, VALUE *passed_values, const int passed_keyword_len)
static int args_argc(struct args_info *args)
static VALUE vm_call0(rb_thread_t *th, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me)
static VALUE refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
#define ALLOCA_N(type, n)
#define MEMCPY(p1, p2, type, n)
VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt)
const struct rb_iseq_constant_body::@196::rb_iseq_param_keyword * keyword
static VALUE vm_to_proc(VALUE proc)
static rb_cref_t * vm_env_cref(const VALUE *ep)
void rb_vm_pop_frame(rb_thread_t *th)
#define RARRAY_CONST_PTR(a)
NORETURN(static void raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc))
VALUE rb_obj_is_proc(VALUE)
static void args_setup_kw_parameters(VALUE *const passed_values, const int passed_keyword_len, const VALUE *const passed_keywords, const rb_iseq_t *const iseq, VALUE *const locals)
static enum rb_block_handler_type vm_block_handler_type(VALUE block_handler)
static int fill_keys_values(st_data_t key, st_data_t val, st_data_t ptr)
VALUE rb_ivar_set(VALUE, ID, VALUE)
VALUE rb_check_hash_type(VALUE hash)
static void args_setup_block_parameter(rb_thread_t *th, struct rb_calling_info *calling, VALUE *locals)
static void vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, rb_iseq_t *blockiseq, const int is_super)
VALUE rb_sym_to_proc(VALUE sym)
static VALUE make_unknown_kw_hash(const VALUE *passed_keywords, int passed_keyword_len, const VALUE *kw_argv)
static void vm_caller_setup_arg_kw(rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci)
#define RARRAY_LENINT(ary)
register unsigned int len
VALUE rb_ary_new_from_values(long n, const VALUE *elts)
static VALUE VM_BH_TO_PROC(VALUE block_handler)
VALUE rb_ary_resize(VALUE ary, long len)
expands or shrinks ary to len elements.
#define RARRAY_ASET(a, i, v)
static void args_extend(struct args_info *args, const int min_argc)
static VALUE make_rest_kw_hash(const VALUE *passed_keywords, int passed_keyword_len, const VALUE *kw_argv)
#define UNLIMITED_ARGUMENTS
static int args_kw_argv_to_hash(struct args_info *args)
#define RARRAY_AREF(a, i)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
static void args_setup_rest_parameter(struct args_info *args, VALUE *locals)
VALUE rb_check_array_type(VALUE ary)
static VALUE rb_arity_error_new(int argc, int min, int max)
static int args_setup_opt_parameters(struct args_info *args, int opt_max, VALUE *locals)
int rb_method_basic_definition_p(VALUE, ID)
VALUE rb_ary_dup(VALUE ary)
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val)
static void args_stored_kw_argv_to_hash(struct args_info *args)
static VALUE VM_BH_FROM_ISEQ_BLOCK(const struct rb_captured_block *captured)
static VALUE args_pop_keyword_hash(struct args_info *args, VALUE *kw_hash_ptr, rb_thread_t *th)
static struct rb_captured_block * VM_CFP_TO_CAPTURED_BLOCK(const rb_control_frame_t *cfp)
#define CHECK_VM_STACK_OVERFLOW(cfp, margin)
RUBY_EXTERN VALUE rb_cSymbol
static int args_check_block_arg0(struct args_info *args, rb_thread_t *th)
static void args_setup_kw_rest_parameter(VALUE keyword_hash, VALUE *locals)
const struct rb_call_info_kw_arg * kw_arg
union rb_captured_block::@202 code
static void args_reduce(struct args_info *args, int over_argc)
VALUE rb_keyword_error_new(const char *error, VALUE keys)