Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
vm_args.c
Go to the documentation of this file.
1/**********************************************************************
2
3 vm_args.c - process method call arguments.
4
5 $Author$
6
7 Copyright (C) 2014- Yukihiro Matsumoto
8
9**********************************************************************/
10
11NORETURN(static void raise_argument_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const VALUE exc));
12NORETURN(static void argument_arity_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc));
13NORETURN(static void argument_kw_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const char *error, const VALUE keys));
14VALUE rb_keyword_error_new(const char *error, VALUE keys); /* class.c */
15static VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv,
16 enum method_missing_reason call_status, int kw_splat);
17#if !defined(_MSC_VER) || !defined(MJIT_HEADER)
19#endif
21
22struct args_info {
23 /* basic args info */
24 VALUE *argv;
25 int argc;
26
27 /* additional args info */
28 int rest_index;
29 int rest_dupped;
30 const struct rb_call_info_kw_arg *kw_arg;
32 VALUE rest;
33};
34
38};
39
40static inline void
41arg_rest_dup(struct args_info *args)
42{
43 if (!args->rest_dupped) {
44 args->rest = rb_ary_dup(args->rest);
45 args->rest_dupped = TRUE;
46 }
47}
48
49static inline int
50args_argc(struct args_info *args)
51{
52 if (args->rest == Qfalse) {
53 return args->argc;
54 }
55 else {
56 return args->argc + RARRAY_LENINT(args->rest) - args->rest_index;
57 }
58}
59
60static inline void
61args_extend(struct args_info *args, const int min_argc)
62{
63 int i;
64
65 if (args->rest) {
66 arg_rest_dup(args);
67 VM_ASSERT(args->rest_index == 0);
68 for (i=args->argc + RARRAY_LENINT(args->rest); i<min_argc; i++) {
69 rb_ary_push(args->rest, Qnil);
70 }
71 }
72 else {
73 for (i=args->argc; i<min_argc; i++) {
74 args->argv[args->argc++] = Qnil;
75 }
76 }
77}
78
79static inline void
80args_reduce(struct args_info *args, int over_argc)
81{
82 if (args->rest) {
83 const long len = RARRAY_LEN(args->rest);
84
85 if (len > over_argc) {
86 arg_rest_dup(args);
87 rb_ary_resize(args->rest, len - over_argc);
88 return;
89 }
90 else {
91 args->rest = Qfalse;
92 over_argc -= len;
93 }
94 }
95
96 VM_ASSERT(args->argc >= over_argc);
97 args->argc -= over_argc;
98}
99
100static inline int
101args_check_block_arg0(struct args_info *args)
102{
103 VALUE ary = Qnil;
104
105 if (args->rest && RARRAY_LEN(args->rest) == 1) {
106 VALUE arg0 = RARRAY_AREF(args->rest, 0);
107 ary = rb_check_array_type(arg0);
108 }
109 else if (args->argc == 1) {
110 VALUE arg0 = args->argv[0];
111 ary = rb_check_array_type(arg0);
112 args->argv[0] = arg0; /* see: https://bugs.ruby-lang.org/issues/8484 */
113 }
114
115 if (!NIL_P(ary)) {
116 args->rest = ary;
117 args->rest_index = 0;
118 args->argc = 0;
119 return TRUE;
120 }
121
122 return FALSE;
123}
124
125static inline void
126args_copy(struct args_info *args)
127{
128 if (args->rest != Qfalse) {
129 int argc = args->argc;
130 args->argc = 0;
131 arg_rest_dup(args);
132
133 /*
134 * argv: [m0, m1, m2, m3]
135 * rest: [a0, a1, a2, a3, a4, a5]
136 * ^
137 * rest_index
138 *
139 * #=> first loop
140 *
141 * argv: [m0, m1]
142 * rest: [m2, m3, a2, a3, a4, a5]
143 * ^
144 * rest_index
145 *
146 * #=> 2nd loop
147 *
148 * argv: [] (argc == 0)
149 * rest: [m0, m1, m2, m3, a2, a3, a4, a5]
150 * ^
151 * rest_index
152 */
153 while (args->rest_index > 0 && argc > 0) {
154 RARRAY_ASET(args->rest, --args->rest_index, args->argv[--argc]);
155 }
156 while (argc > 0) {
157 rb_ary_unshift(args->rest, args->argv[--argc]);
158 }
159 }
160 else if (args->argc > 0) {
161 args->rest = rb_ary_new_from_values(args->argc, args->argv);
162 args->rest_index = 0;
163 args->rest_dupped = TRUE;
164 args->argc = 0;
165 }
166}
167
168static inline const VALUE *
169args_rest_argv(struct args_info *args)
170{
171 return RARRAY_CONST_PTR_TRANSIENT(args->rest) + args->rest_index;
172}
173
174static inline VALUE
175args_rest_array(struct args_info *args)
176{
177 VALUE ary;
178
179 if (args->rest) {
180 ary = rb_ary_behead(args->rest, args->rest_index);
181 args->rest_index = 0;
182 args->rest = 0;
183 }
184 else {
185 ary = rb_ary_new();
186 }
187 return ary;
188}
189
190#define KW_HASH_HAS_NO_KEYS 0
191#define KW_HASH_HAS_SYMBOL_KEY 1
192#define KW_HASH_HAS_OTHER_KEY 2
193#define KW_HASH_HAS_BOTH_KEYS 3
194
195static int
196keyword_hash_symbol_other_iter(st_data_t key, st_data_t val, st_data_t arg)
197{
199
201 return ST_STOP;
202 }
203
204 return ST_CONTINUE;
205}
206
207static int
208keyword_hash_symbol_other(VALUE hash)
209{
210 int symbol_other = KW_HASH_HAS_NO_KEYS;
211 rb_hash_stlike_foreach(hash, keyword_hash_symbol_other_iter, (st_data_t)(&symbol_other));
212 return symbol_other;
213}
214
215static int
216keyword_hash_split_iter(st_data_t key, st_data_t val, st_data_t arg)
217{
218 if (SYMBOL_P((VALUE)key)) {
220 return ST_DELETE;
221 }
222
223 return ST_CONTINUE;
224}
225
226static void
227keyword_hash_split(VALUE *kw_hash_ptr, VALUE *rest_hash_ptr)
228{
229 *kw_hash_ptr = rb_hash_new();
230 rb_hash_stlike_foreach(*rest_hash_ptr, keyword_hash_split_iter, (st_data_t)(*kw_hash_ptr));
231}
232
233static int
234keyword_hash_p(VALUE *kw_hash_ptr, VALUE *rest_hash_ptr, int check_only_symbol)
235{
236 *rest_hash_ptr = rb_check_hash_type(*kw_hash_ptr);
237
238 if (!NIL_P(*rest_hash_ptr)) {
239 if (check_only_symbol) {
240 switch (keyword_hash_symbol_other(*rest_hash_ptr)) {
243 break;
245 *kw_hash_ptr = Qnil;
246 return FALSE;
248 *rest_hash_ptr = rb_hash_dup(*rest_hash_ptr);
249 keyword_hash_split(kw_hash_ptr, rest_hash_ptr);
250 return TRUE;
251 }
252 }
253 *kw_hash_ptr = *rest_hash_ptr;
254 *rest_hash_ptr = Qfalse;
255 return TRUE;
256 }
257 else {
258 *kw_hash_ptr = Qnil;
259 return FALSE;
260 }
261}
262
263static VALUE
264args_pop_keyword_hash(struct args_info *args, VALUE *kw_hash_ptr, int check_only_symbol)
265{
266 VALUE rest_hash;
267
268 if (args->rest == Qfalse) {
269 from_argv:
270 VM_ASSERT(args->argc > 0);
271 *kw_hash_ptr = args->argv[args->argc-1];
272
273 if (keyword_hash_p(kw_hash_ptr, &rest_hash, check_only_symbol)) {
274 if (rest_hash) {
275 args->argv[args->argc-1] = rest_hash;
276 }
277 else {
278 args->argc--;
279 return TRUE;
280 }
281 }
282 }
283 else {
284 long len = RARRAY_LEN(args->rest);
285
286 if (len > 0) {
287 *kw_hash_ptr = RARRAY_AREF(args->rest, len - 1);
288
289 if (keyword_hash_p(kw_hash_ptr, &rest_hash, check_only_symbol)) {
290 if (rest_hash) {
291 RARRAY_ASET(args->rest, len - 1, rest_hash);
292 }
293 else {
294 arg_rest_dup(args);
295 rb_ary_pop(args->rest);
296 return TRUE;
297 }
298 }
299 }
300 else {
301 goto from_argv;
302 }
303 }
304
305 return FALSE;
306}
307
308static int
309args_kw_argv_to_hash(struct args_info *args)
310{
311 const struct rb_call_info_kw_arg *kw_arg = args->kw_arg;
312 const VALUE *const passed_keywords = kw_arg->keywords;
313 const int kw_len = kw_arg->keyword_len;
314 VALUE h = rb_hash_new_with_size(kw_len);
315 const int kw_start = args->argc - kw_len;
316 const VALUE * const kw_argv = args->argv + kw_start;
317 int i;
318
319 args->argc = kw_start + 1;
320 for (i=0; i<kw_len; i++) {
321 rb_hash_aset(h, passed_keywords[i], kw_argv[i]);
322 }
323
324 args->argv[args->argc - 1] = h;
325
326 return args->argc;
327}
328
329static void
330args_stored_kw_argv_to_hash(struct args_info *args)
331{
332 int i;
333 const struct rb_call_info_kw_arg *kw_arg = args->kw_arg;
334 const VALUE *const passed_keywords = kw_arg->keywords;
335 const int passed_keyword_len = kw_arg->keyword_len;
336 VALUE h = rb_hash_new_with_size(passed_keyword_len);
337
338 for (i=0; i<passed_keyword_len; i++) {
339 rb_hash_aset(h, passed_keywords[i], args->kw_argv[i]);
340 }
341 args->kw_argv = NULL;
342
343 if (args->rest) {
344 arg_rest_dup(args);
345 rb_ary_push(args->rest, h);
346 }
347 else {
348 args->argv[args->argc++] = h;
349 }
350}
351
352static inline void
353args_setup_lead_parameters(struct args_info *args, int argc, VALUE *locals)
354{
355 if (args->argc >= argc) {
356 /* do noting */
357 args->argc -= argc;
358 args->argv += argc;
359 }
360 else {
361 int i, j;
362 const VALUE *argv = args_rest_argv(args);
363
364 for (i=args->argc, j=0; i<argc; i++, j++) {
365 locals[i] = argv[j];
366 }
367 args->rest_index += argc - args->argc;
368 args->argc = 0;
369 }
370}
371
372static inline void
373args_setup_post_parameters(struct args_info *args, int argc, VALUE *locals)
374{
375 long len;
376 len = RARRAY_LEN(args->rest);
378 rb_ary_resize(args->rest, len - argc);
379}
380
381static inline int
382args_setup_opt_parameters(struct args_info *args, int opt_max, VALUE *locals)
383{
384 int i;
385
386 if (args->argc >= opt_max) {
387 args->argc -= opt_max;
388 args->argv += opt_max;
389 i = opt_max;
390 }
391 else {
392 int j;
393 i = args->argc;
394 args->argc = 0;
395
396 if (args->rest) {
397 int len = RARRAY_LENINT(args->rest);
399
400 for (; i<opt_max && args->rest_index < len; i++, args->rest_index++) {
401 locals[i] = argv[args->rest_index];
402 }
403 }
404
405 /* initialize by nil */
406 for (j=i; j<opt_max; j++) {
407 locals[j] = Qnil;
408 }
409 }
410
411 return i;
412}
413
414static inline void
415args_setup_rest_parameter(struct args_info *args, VALUE *locals)
416{
417 *locals = args_rest_array(args);
418}
419
420static VALUE
421make_unknown_kw_hash(const VALUE *passed_keywords, int passed_keyword_len, const VALUE *kw_argv)
422{
423 int i;
425
426 for (i=0; i<passed_keyword_len; i++) {
427 if (kw_argv[i] != Qundef) {
428 rb_ary_push(obj, passed_keywords[i]);
429 }
430 }
431 return obj;
432}
433
434static VALUE
435make_rest_kw_hash(const VALUE *passed_keywords, int passed_keyword_len, const VALUE *kw_argv)
436{
437 int i;
438 VALUE obj = rb_hash_new_with_size(passed_keyword_len);
439
440 for (i=0; i<passed_keyword_len; i++) {
441 if (kw_argv[i] != Qundef) {
442 rb_hash_aset(obj, passed_keywords[i], kw_argv[i]);
443 }
444 }
445 return obj;
446}
447
448static inline int
449args_setup_kw_parameters_lookup(const ID key, VALUE *ptr, const VALUE *const passed_keywords, VALUE *passed_values, const int passed_keyword_len)
450{
451 int i;
452 const VALUE keyname = ID2SYM(key);
453
454 for (i=0; i<passed_keyword_len; i++) {
455 if (keyname == passed_keywords[i]) {
456 *ptr = passed_values[i];
457 passed_values[i] = Qundef;
458 return TRUE;
459 }
460 }
461
462 return FALSE;
463}
464
465#define KW_SPECIFIED_BITS_MAX (32-1) /* TODO: 32 -> Fixnum's max bits */
466
467static void
468args_setup_kw_parameters(rb_execution_context_t *const ec, const rb_iseq_t *const iseq,
469 VALUE *const passed_values, const int passed_keyword_len, const VALUE *const passed_keywords,
470 VALUE *const locals)
471{
472 const ID *acceptable_keywords = iseq->body->param.keyword->table;
473 const int req_key_num = iseq->body->param.keyword->required_num;
474 const int key_num = iseq->body->param.keyword->num;
475 const VALUE * const default_values = iseq->body->param.keyword->default_values;
476 VALUE missing = 0;
477 int i, di, found = 0;
478 int unspecified_bits = 0;
479 VALUE unspecified_bits_value = Qnil;
480
481 for (i=0; i<req_key_num; i++) {
482 ID key = acceptable_keywords[i];
483 if (args_setup_kw_parameters_lookup(key, &locals[i], passed_keywords, passed_values, passed_keyword_len)) {
484 found++;
485 }
486 else {
487 if (!missing) missing = rb_ary_tmp_new(1);
488 rb_ary_push(missing, ID2SYM(key));
489 }
490 }
491
492 if (missing) argument_kw_error(ec, iseq, "missing", missing);
493
494 for (di=0; i<key_num; i++, di++) {
495 if (args_setup_kw_parameters_lookup(acceptable_keywords[i], &locals[i], passed_keywords, passed_values, passed_keyword_len)) {
496 found++;
497 }
498 else {
499 if (default_values[di] == Qundef) {
500 locals[i] = Qnil;
501
503 unspecified_bits |= 0x01 << di;
504 }
505 else {
506 if (NIL_P(unspecified_bits_value)) {
507 /* fixnum -> hash */
508 int j;
509 unspecified_bits_value = rb_hash_new();
510
511 for (j=0; j<KW_SPECIFIED_BITS_MAX; j++) {
512 if (unspecified_bits & (0x01 << j)) {
513 rb_hash_aset(unspecified_bits_value, INT2FIX(j), Qtrue);
514 }
515 }
516 }
517 rb_hash_aset(unspecified_bits_value, INT2FIX(di), Qtrue);
518 }
519 }
520 else {
521 locals[i] = default_values[di];
522 }
523 }
524 }
525
527 const int rest_hash_index = key_num + 1;
528 locals[rest_hash_index] = make_rest_kw_hash(passed_keywords, passed_keyword_len, passed_values);
529 }
530 else {
531 if (found != passed_keyword_len) {
532 VALUE keys = make_unknown_kw_hash(passed_keywords, passed_keyword_len, passed_values);
533 argument_kw_error(ec, iseq, "unknown", keys);
534 }
535 }
536
537 if (NIL_P(unspecified_bits_value)) {
538 unspecified_bits_value = INT2FIX(unspecified_bits);
539 }
540 locals[key_num] = unspecified_bits_value;
541}
542
543static inline void
544args_setup_kw_rest_parameter(VALUE keyword_hash, VALUE *locals)
545{
546 locals[0] = NIL_P(keyword_hash) ? rb_hash_new() : rb_hash_dup(keyword_hash);
547}
548
549static inline void
550args_setup_block_parameter(const rb_execution_context_t *ec, struct rb_calling_info *calling, VALUE *locals)
551{
552 VALUE block_handler = calling->block_handler;
553 *locals = rb_vm_bh_to_procval(ec, block_handler);
554}
555
556struct fill_values_arg {
557 VALUE *keys;
558 VALUE *vals;
559 int argc;
560};
561
562static int
563fill_keys_values(st_data_t key, st_data_t val, st_data_t ptr)
564{
565 struct fill_values_arg *arg = (struct fill_values_arg *)ptr;
566 int i = arg->argc++;
567 arg->keys[i] = (VALUE)key;
568 arg->vals[i] = (VALUE)val;
569 return ST_CONTINUE;
570}
571
572static inline int
573ignore_keyword_hash_p(VALUE keyword_hash, const rb_iseq_t * const iseq)
574{
575 if (!(iseq->body->param.flags.has_kw) &&
577 keyword_hash = rb_check_hash_type(keyword_hash);
578
579 if (!NIL_P(keyword_hash) && RHASH_EMPTY_P(keyword_hash)) {
580 return 1;
581 }
582 }
583
584 return 0;
585}
586
588
589/* -- Remove In 3.0 -- */
590
591/* This is a map from caller PC to a set of callee methods.
592 * When a warning about keyword argument change is printed,
593 * it keeps the pair of callee and caller.
594 */
595static st_table *caller_to_callees = 0;
596
597static VALUE
598rb_warn_check(const rb_execution_context_t * const ec, const rb_iseq_t *const iseq)
599{
601
602 if (!iseq) return 0;
603
605
607
608 if (!cfp) return 0;
609
610 const st_data_t caller = (st_data_t)cfp->pc;
611
612 if (!caller_to_callees) {
613 caller_to_callees = st_init_numtable();
614 }
615
616 st_data_t val;
617 if (st_lookup(caller_to_callees, caller, &val)) {
618 st_table *callees;
619
620 if (val & 1) {
621 val &= ~(st_data_t)1;
622 if (val == callee) return 1; /* already warned */
623
624 callees = st_init_numtable();
625 st_insert(callees, val, 1);
626 }
627 else {
628 callees = (st_table *) val;
629 if (st_is_member(callees, callee)) return 1; /* already warned */
630 }
631 st_insert(callees, callee, 1);
632 st_insert(caller_to_callees, caller, (st_data_t) callees);
633 }
634 else {
635 st_insert(caller_to_callees, caller, callee | 1);
636 }
637
638 return 0; /* not warned yet for the pair of caller and callee */
639}
640
641static inline void
642rb_warn_keyword_to_last_hash(rb_execution_context_t * const ec, struct rb_calling_info *calling, const struct rb_call_info *ci, const rb_iseq_t * const iseq)
643{
644 if (rb_warn_check(ec, iseq)) return;
645
646 VALUE name, loc;
647 if (calling->recv == Qundef) {
648 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
649 return;
650 }
651 name = rb_id2str(ci->mid);
652 loc = rb_iseq_location(iseq);
653 if (NIL_P(loc)) {
654 rb_warn("Passing the keyword argument for `%"PRIsVALUE"' as the last hash parameter is deprecated",
655 name);
656 }
657 else {
658 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
659 if (name) {
661 "The called method `%"PRIsVALUE"' is defined here", name);
662 }
663 else {
665 "The called method is defined here");
666 }
667 }
668}
669
670static inline void
671rb_warn_split_last_hash_to_keyword(rb_execution_context_t * const ec, struct rb_calling_info *calling, const struct rb_call_info *ci, const rb_iseq_t * const iseq)
672{
673 if (rb_warn_check(ec, iseq)) return;
674
675 VALUE name, loc;
676 name = rb_id2str(ci->mid);
677 loc = rb_iseq_location(iseq);
678 if (NIL_P(loc)) {
679 rb_warn("Splitting the last argument for `%"PRIsVALUE"' into positional and keyword parameters is deprecated",
680 name);
681 }
682 else {
683 rb_warn("Splitting the last argument into positional and keyword parameters is deprecated");
684 if (calling->recv != Qundef) {
686 "The called method `%"PRIsVALUE"' is defined here", name);
687 }
688 else {
690 "The called method is defined here");
691 }
692 }
693}
694
695static inline void
696rb_warn_last_hash_to_keyword(rb_execution_context_t * const ec, struct rb_calling_info *calling, const struct rb_call_info *ci, const rb_iseq_t * const iseq)
697{
698 if (rb_warn_check(ec, iseq)) return;
699
700 VALUE name, loc;
701 name = rb_id2str(ci->mid);
702 loc = rb_iseq_location(iseq);
703 if (NIL_P(loc)) {
704 rb_warn("Using the last argument for `%"PRIsVALUE"' as keyword parameters is deprecated; maybe ** should be added to the call",
705 name);
706 }
707 else {
708 rb_warn("Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call");
709 if (calling->recv != Qundef) {
711 "The called method `%"PRIsVALUE"' is defined here", name);
712 }
713 else {
715 "The called method is defined here");
716 }
717 }
718}
719
720static int
721setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * const iseq,
722 struct rb_calling_info *const calling,
723 const struct rb_call_info *ci,
724 VALUE * const locals, const enum arg_setup_type arg_setup_type)
725{
728 int given_argc;
729 int kw_splat = FALSE;
730 unsigned int kw_flag = ci->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT);
731 int opt_pc = 0, allow_autosplat = !kw_flag;
732 struct args_info args_body, *args;
733 VALUE keyword_hash = Qnil;
734 VALUE * const orig_sp = ec->cfp->sp;
735 unsigned int i;
736 int remove_empty_keyword_hash = 1;
737 VALUE flag_keyword_hash = 0;
738
739 vm_check_canary(ec, orig_sp);
740 /*
741 * Extend SP for GC.
742 *
743 * [pushed values] [uninitialized values]
744 * <- ci->argc -->
745 * <- iseq->body->param.size------------>
746 * ^ locals ^ sp
747 *
748 * =>
749 * [pushed values] [initialized values ]
750 * <- ci->argc -->
751 * <- iseq->body->param.size------------>
752 * ^ locals ^ sp
753 */
754 for (i=calling->argc; i<iseq->body->param.size; i++) {
755 locals[i] = Qnil;
756 }
757 ec->cfp->sp = &locals[i];
758
759 /* setup args */
760 args = &args_body;
761 given_argc = args->argc = calling->argc;
762 args->argv = locals;
763 args->rest_dupped = FALSE;
764
765 if (kw_flag & VM_CALL_KWARG) {
766 args->kw_arg = ((struct rb_call_info_with_kwarg *)ci)->kw_arg;
767
768 if (iseq->body->param.flags.has_kw) {
769 int kw_len = args->kw_arg->keyword_len;
770 /* copy kw_argv */
771 args->kw_argv = ALLOCA_N(VALUE, kw_len);
772 args->argc -= kw_len;
773 given_argc -= kw_len;
774 MEMCPY(args->kw_argv, locals + args->argc, VALUE, kw_len);
775 }
776 else {
777 args->kw_argv = NULL;
778 given_argc = args_kw_argv_to_hash(args);
779 kw_flag |= VM_CALL_KW_SPLAT;
780 }
781 }
782 else {
783 args->kw_arg = NULL;
784 args->kw_argv = NULL;
785 }
786
787 if (kw_flag && iseq->body->param.flags.ruby2_keywords) {
788 remove_empty_keyword_hash = 0;
789 }
790
791 if (ci->flag & VM_CALL_ARGS_SPLAT) {
792 VALUE rest_last = 0;
793 int len;
794 args->rest = locals[--args->argc];
795 args->rest_index = 0;
796 len = RARRAY_LENINT(args->rest);
797 given_argc += len - 1;
798 rest_last = RARRAY_AREF(args->rest, len - 1);
799
800 if (!kw_flag && len > 0) {
801 if (RB_TYPE_P(rest_last, T_HASH) &&
802 (((struct RHash *)rest_last)->basic.flags & RHASH_PASS_AS_KEYWORDS)) {
803 rest_last = rb_hash_dup(rest_last);
804 kw_flag |= VM_CALL_KW_SPLAT;
806 remove_empty_keyword_hash = 0;
807 }
808 }
809 else {
810 rest_last = 0;
811 }
812 }
813
814 if (kw_flag & VM_CALL_KW_SPLAT) {
815 if (len > 0 && ignore_keyword_hash_p(rest_last, iseq)) {
816 if (given_argc != min_argc) {
817 if (remove_empty_keyword_hash) {
818 arg_rest_dup(args);
819 rb_ary_pop(args->rest);
820 given_argc--;
821 kw_flag &= ~VM_CALL_KW_SPLAT;
822 }
823 else {
824 if (RB_TYPE_P(rest_last, T_HASH) && rb_obj_frozen_p(rest_last)) {
825 rest_last = rb_hash_new();
826 RARRAY_ASET(args->rest, len - 1, rest_last);
827 }
828 flag_keyword_hash = rest_last;
829 }
830 }
831 else {
832 rb_warn_keyword_to_last_hash(ec, calling, ci, iseq);
833 }
834 }
835 else if (!remove_empty_keyword_hash && rest_last) {
836 flag_keyword_hash = rest_last;
837 }
838 }
839 }
840 else {
841 if (kw_flag & VM_CALL_KW_SPLAT) {
842 VALUE last_arg = args->argv[args->argc-1];
843 if (ignore_keyword_hash_p(last_arg, iseq)) {
844 if (given_argc != min_argc) {
845 if (remove_empty_keyword_hash) {
846 args->argc--;
847 given_argc--;
848 kw_flag &= ~VM_CALL_KW_SPLAT;
849 }
850 else {
851 if (RB_TYPE_P(last_arg, T_HASH) && rb_obj_frozen_p(last_arg)) {
852 last_arg = rb_hash_new();
853 args->argv[args->argc-1] = last_arg;
854 }
855 flag_keyword_hash = last_arg;
856 }
857 }
858 else {
859 rb_warn_keyword_to_last_hash(ec, calling, ci, iseq);
860 }
861 }
862 else if (!remove_empty_keyword_hash) {
863 flag_keyword_hash = args->argv[args->argc-1];
864 }
865 }
866 args->rest = Qfalse;
867 }
868
869 if (flag_keyword_hash && RB_TYPE_P(flag_keyword_hash, T_HASH)) {
870 ((struct RHash *)flag_keyword_hash)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
871 }
872
873 if (kw_flag && iseq->body->param.flags.accepts_no_kwarg) {
874 rb_raise(rb_eArgError, "no keywords accepted");
875 }
876
877 switch (arg_setup_type) {
878 case arg_setup_method:
879 break; /* do nothing special */
880 case arg_setup_block:
881 if (given_argc == 1 &&
882 allow_autosplat &&
883 (min_argc > 0 || iseq->body->param.opt_num > 1 ||
886 args_check_block_arg0(args)) {
887 given_argc = RARRAY_LENINT(args->rest);
888 }
889 break;
890 }
891
892 /* argc check */
893 if (given_argc < min_argc) {
894 if (given_argc == min_argc - 1 && args->kw_argv) {
895 args_stored_kw_argv_to_hash(args);
896 given_argc = args_argc(args);
897 }
898 else {
901 given_argc = min_argc;
902 args_extend(args, min_argc);
903 }
904 else {
905 argument_arity_error(ec, iseq, given_argc, min_argc, max_argc);
906 }
907 }
908 }
909
910 if (kw_flag & VM_CALL_KW_SPLAT) {
911 kw_splat = !iseq->body->param.flags.has_rest;
912 }
914 (kw_splat && given_argc > max_argc)) &&
915 args->kw_argv == NULL) {
916 if (given_argc > min_argc) {
917 if (kw_flag) {
918 int check_only_symbol = (kw_flag & VM_CALL_KW_SPLAT) &&
921
922 if (args_pop_keyword_hash(args, &keyword_hash, check_only_symbol)) {
923 given_argc--;
924 }
925 else if (check_only_symbol) {
926 if (keyword_hash != Qnil) {
927 rb_warn_split_last_hash_to_keyword(ec, calling, ci, iseq);
928 }
929 else {
930 rb_warn_keyword_to_last_hash(ec, calling, ci, iseq);
931 }
932 }
933 }
934 else if (args_pop_keyword_hash(args, &keyword_hash, 1)) {
935 /* Warn the following:
936 * def foo(k:1) p [k]; end
937 * foo({k:42}) #=> 42
938 */
939 rb_warn_last_hash_to_keyword(ec, calling, ci, iseq);
940 given_argc--;
941 }
942 else if (keyword_hash != Qnil) {
943 rb_warn_split_last_hash_to_keyword(ec, calling, ci, iseq);
944 }
945 }
946 else if (given_argc == min_argc && kw_flag) {
947 rb_warn_keyword_to_last_hash(ec, calling, ci, iseq);
948 }
949 }
950
951 if (given_argc > max_argc && max_argc != UNLIMITED_ARGUMENTS) {
953 /* truncate */
954 args_reduce(args, given_argc - max_argc);
955 given_argc = max_argc;
956 }
957 else {
958 argument_arity_error(ec, iseq, given_argc, min_argc, max_argc);
959 }
960 }
961
962 if (iseq->body->param.flags.has_lead) {
963 args_setup_lead_parameters(args, iseq->body->param.lead_num, locals + 0);
964 }
965
967 args_copy(args);
968 }
969
970 if (iseq->body->param.flags.has_post) {
971 args_setup_post_parameters(args, iseq->body->param.post_num, locals + iseq->body->param.post_start);
972 }
973
974 if (iseq->body->param.flags.has_opt) {
975 int opt = args_setup_opt_parameters(args, iseq->body->param.opt_num, locals + iseq->body->param.lead_num);
976 opt_pc = (int)iseq->body->param.opt_table[opt];
977 }
978
979 if (iseq->body->param.flags.has_rest) {
980 args_setup_rest_parameter(args, locals + iseq->body->param.rest_start);
981 }
982
983 if (iseq->body->param.flags.has_kw) {
984 VALUE * const klocals = locals + iseq->body->param.keyword->bits_start - iseq->body->param.keyword->num;
985
986 if (args->kw_argv != NULL) {
987 const struct rb_call_info_kw_arg *kw_arg = args->kw_arg;
988 args_setup_kw_parameters(ec, iseq, args->kw_argv, kw_arg->keyword_len, kw_arg->keywords, klocals);
989 }
990 else if (!NIL_P(keyword_hash)) {
991 int kw_len = rb_long2int(RHASH_SIZE(keyword_hash));
992 struct fill_values_arg arg;
993 /* copy kw_argv */
994 arg.keys = args->kw_argv = ALLOCA_N(VALUE, kw_len * 2);
995 arg.vals = arg.keys + kw_len;
996 arg.argc = 0;
997 rb_hash_foreach(keyword_hash, fill_keys_values, (VALUE)&arg);
998 VM_ASSERT(arg.argc == kw_len);
999 args_setup_kw_parameters(ec, iseq, arg.vals, kw_len, arg.keys, klocals);
1000 }
1001 else {
1002 VM_ASSERT(args_argc(args) == 0);
1003 args_setup_kw_parameters(ec, iseq, NULL, 0, NULL, klocals);
1004 }
1005 }
1006 else if (iseq->body->param.flags.has_kwrest) {
1007 args_setup_kw_rest_parameter(keyword_hash, locals + iseq->body->param.keyword->rest_start);
1008 }
1009 else if (!NIL_P(keyword_hash) && RHASH_SIZE(keyword_hash) > 0 && arg_setup_type == arg_setup_method) {
1010 argument_kw_error(ec, iseq, "unknown", rb_hash_keys(keyword_hash));
1011 }
1012
1013 if (iseq->body->param.flags.has_block) {
1014 if (iseq->body->local_iseq == iseq) {
1015 /* Do nothing */
1016 }
1017 else {
1018 args_setup_block_parameter(ec, calling, locals + iseq->body->param.block_start);
1019 }
1020 }
1021
1022#if 0
1023 {
1024 int i;
1025 for (i=0; i<iseq->body->param.size; i++) {
1026 fprintf(stderr, "local[%d] = %p\n", i, (void *)locals[i]);
1027 }
1028 }
1029#endif
1030
1031 ec->cfp->sp = orig_sp;
1032 return opt_pc;
1033}
1034
1035void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self); /* vm_backtrace.c */
1036
1037static void
1038raise_argument_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const VALUE exc)
1039{
1040 VALUE at;
1041
1042 if (iseq) {
1043 vm_push_frame(ec, iseq, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL, Qnil /* self */,
1044 VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */,
1046 ec->cfp->sp, 0, 0 /* stack_max */);
1047 at = rb_ec_backtrace_object(ec);
1049 rb_vm_pop_frame(ec);
1050 }
1051 else {
1052 at = rb_ec_backtrace_object(ec);
1053 }
1054
1058}
1059
1060static void
1061argument_arity_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc)
1062{
1063 VALUE exc = rb_arity_error_new(miss_argc, min_argc, max_argc);
1064 if (iseq->body->param.flags.has_kw) {
1065 const struct rb_iseq_param_keyword *const kw = iseq->body->param.keyword;
1066 const ID *keywords = kw->table;
1067 int req_key_num = kw->required_num;
1068 if (req_key_num > 0) {
1069 static const char required[] = "; required keywords";
1070 VALUE mesg = rb_attr_get(exc, idMesg);
1071 rb_str_resize(mesg, RSTRING_LEN(mesg)-1);
1072 rb_str_cat(mesg, required, sizeof(required) - 1 - (req_key_num == 1));
1073 rb_str_cat_cstr(mesg, ":");
1074 do {
1075 rb_str_cat_cstr(mesg, " ");
1076 rb_str_append(mesg, rb_id2str(*keywords++));
1077 rb_str_cat_cstr(mesg, ",");
1078 } while (--req_key_num);
1079 RSTRING_PTR(mesg)[RSTRING_LEN(mesg)-1] = ')';
1080 }
1081 }
1082 raise_argument_error(ec, iseq, exc);
1083}
1084
1085static void
1086argument_kw_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const char *error, const VALUE keys)
1087{
1088 raise_argument_error(ec, iseq, rb_keyword_error_new(error, keys));
1089}
1090
1091static inline void
1092vm_caller_setup_arg_splat(rb_control_frame_t *cfp, struct rb_calling_info *calling)
1093{
1094 int argc = calling->argc;
1095 VALUE *argv = cfp->sp - argc;
1096 VALUE ary = argv[argc-1];
1097
1099 cfp->sp--;
1100
1101 if (!NIL_P(ary)) {
1102 const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
1103 long len = RARRAY_LEN(ary), i;
1104
1106
1107 for (i = 0; i < len; i++) {
1108 *cfp->sp++ = ptr[i];
1109 }
1110 calling->argc += i - 1;
1111 }
1112}
1113
1114static inline void
1115vm_caller_setup_arg_kw(rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci)
1116{
1117 struct rb_call_info_with_kwarg *ci_kw = (struct rb_call_info_with_kwarg *)ci;
1118 const VALUE *const passed_keywords = ci_kw->kw_arg->keywords;
1119 const int kw_len = ci_kw->kw_arg->keyword_len;
1120 const VALUE h = rb_hash_new_with_size(kw_len);
1121 VALUE *sp = cfp->sp;
1122 int i;
1123
1124 for (i=0; i<kw_len; i++) {
1125 rb_hash_aset(h, passed_keywords[i], (sp - kw_len)[i]);
1126 }
1127 (sp-kw_len)[0] = h;
1128
1129 cfp->sp -= kw_len - 1;
1130 calling->argc -= kw_len - 1;
1131 calling->kw_splat = 1;
1132}
1133
1134static VALUE
1135vm_to_proc(VALUE proc)
1136{
1137 if (UNLIKELY(!rb_obj_is_proc(proc))) {
1138 VALUE b;
1141
1142 if (me) {
1143 b = rb_vm_call0(GET_EC(), proc, idTo_proc, 0, NULL, me, RB_NO_KEYWORDS);
1144 }
1145 else {
1146 /* NOTE: calling method_missing */
1148 }
1149
1150 if (NIL_P(b) || !rb_obj_is_proc(b)) {
1152 "wrong argument type %s (expected Proc)",
1153 rb_obj_classname(proc));
1154 }
1155 return b;
1156 }
1157 else {
1158 return proc;
1159 }
1160}
1161
1162static VALUE
1163refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
1164{
1165 VALUE obj;
1166 ID mid;
1169 const VALUE symbol = RARRAY_AREF(callback_arg, 0);
1170 const VALUE refinements = RARRAY_AREF(callback_arg, 1);
1171 int kw_splat = RB_PASS_CALLED_KEYWORDS;
1172 VALUE v;
1173 VALUE ret;
1174 VALUE klass;
1175
1176 if (argc-- < 1) {
1177 rb_raise(rb_eArgError, "no receiver given");
1178 }
1179 obj = *argv++;
1180
1181 mid = SYM2ID(symbol);
1184 if (me) {
1186 if (me) break;
1187 }
1188 }
1189
1190 ec = GET_EC();
1191 if (!NIL_P(blockarg)) {
1192 vm_passed_block_handler_set(ec, blockarg);
1193 }
1194 v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1195 if (!me) {
1196 ret = method_missing(obj, mid, argc, argv, MISSING_NOENTRY, kw_splat);
1197 }
1198 else {
1199 ret = rb_vm_call0(ec, obj, mid, argc, argv, me, kw_splat);
1200 }
1202 return ret;
1203}
1204
1205static VALUE
1206vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
1207 const struct rb_call_info *ci, const rb_iseq_t *blockiseq, const int is_super)
1208{
1209 if (ci->flag & VM_CALL_ARGS_BLOCKARG) {
1210 VALUE block_code = *(--reg_cfp->sp);
1211
1212 if (NIL_P(block_code)) {
1213 return VM_BLOCK_HANDLER_NONE;
1214 }
1215 else if (block_code == rb_block_param_proxy) {
1216 VM_ASSERT(!VM_CFP_IN_HEAP_P(GET_EC(), reg_cfp));
1217 VALUE handler = VM_CF_BLOCK_HANDLER(reg_cfp);
1218 reg_cfp->block_code = (const void *) handler;
1219 return handler;
1220 }
1221 else if (SYMBOL_P(block_code) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
1222 const rb_cref_t *cref = vm_env_cref(reg_cfp->ep);
1223 if (cref && !NIL_P(cref->refinements)) {
1224 VALUE ref = cref->refinements;
1225 VALUE func = rb_hash_lookup(ref, block_code);
1226 if (NIL_P(func)) {
1227 /* TODO: limit cached funcs */
1228 VALUE callback_arg = rb_ary_tmp_new(2);
1229 rb_ary_push(callback_arg, block_code);
1230 rb_ary_push(callback_arg, ref);
1231 OBJ_FREEZE_RAW(callback_arg);
1232 func = rb_func_proc_new(refine_sym_proc_call, callback_arg);
1233 rb_hash_aset(ref, block_code, func);
1234 }
1235 block_code = func;
1236 }
1237 return block_code;
1238 }
1239 else {
1240 return vm_to_proc(block_code);
1241 }
1242 }
1243 else if (blockiseq != NULL) { /* likely */
1244 struct rb_captured_block *captured = VM_CFP_TO_CAPTURED_BLOCK(reg_cfp);
1245 captured->code.iseq = blockiseq;
1246 return VM_BH_FROM_ISEQ_BLOCK(captured);
1247 }
1248 else {
1249 if (is_super) {
1250 return GET_BLOCK_HANDLER();
1251 }
1252 else {
1253 return VM_BLOCK_HANDLER_NONE;
1254 }
1255 }
1256}
struct RIMemo * ptr
Definition: debug.c:65
VALUE rb_keyword_error_new(const char *error, VALUE keys)
Definition: class.c:1837
VALUE rb_cSymbol
Definition: ruby.h:2048
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2671
_Bool rb_warning_category_enabled_p(rb_warning_category_t category)
Definition: error.c:166
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
Definition: eval.c:668
VALUE rb_eTypeError
Definition: error.c:924
void rb_warn(const char *fmt,...)
Definition: error.c:315
VALUE rb_eArgError
Definition: error.c:925
VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt)
Definition: error.c:1312
VALUE rb_obj_frozen_p(VALUE obj)
Determines if the object is frozen.
Definition: object.c:1099
VALUE rb_check_convert_type_with_id(VALUE, int, const char *, ID)
Definition: object.c:2957
const char * name
Definition: nkf.c:208
my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2)
Definition: problem1.c:16
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
#define RARRAY_LEN(a)
VALUE rb_ary_new_from_values(long n, const VALUE *elts)
Definition: array.c:762
VALUE rb_hash_lookup(VALUE, VALUE)
Definition: hash.c:2063
#define MEMCPY(p1, p2, type, n)
void rb_hash_foreach(VALUE, int(*)(VALUE, VALUE, VALUE), VALUE)
#define NULL
VALUE rb_adjust_argv_kw_splat(int *, const VALUE **, int *)
Definition: vm_eval.c:237
VALUE rb_str_resize(VALUE, long)
Definition: string.c:2709
@ RB_WARN_CATEGORY_DEPRECATED
#define UNLIMITED_ARGUMENTS
#define RSTRING_LEN(str)
#define ALLOCA_N(type, n)
rb_control_frame_t struct rb_calling_info const struct rb_call_info VALUE block_handler
#define RCLASS_SUPER(c)
unsigned long st_data_t
void rb_compile_warn(const char *, int, const char *,...) __attribute__((format(printf
const rb_callable_method_entry_t * rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class)
Definition: vm_method.c:934
const rb_iseq_t const int const int min_argc
#define RARRAY_LENINT(ary)
#define VM_CALL_ARGS_BLOCKARG
rb_control_frame_t * cfp
#define Qundef
const VALUE VALUE obj
VALUE rb_ary_pop(VALUE)
Definition: array.c:1241
#define st_is_member(table, key)
#define RSTRING_PTR(str)
const rb_iseq_t const char * error
VALUE rb_ec_backtrace_object(const rb_execution_context_t *ec)
Definition: vm_backtrace.c:557
#define GET_EC()
VALUE rb_obj_is_proc(VALUE)
Definition: proc.c:152
#define NIL_P(v)
const rb_iseq_t const int miss_argc
const rb_callable_method_entry_t * me
#define VM_ASSERT(expr)
VALUE rb_str_cat(VALUE, const char *, long)
Definition: string.c:2812
#define ID2SYM(x)
int const VALUE VALUE int call_status
int fprintf(FILE *__restrict__, const char *__restrict__,...) __attribute__((__format__(__printf__
#define T_DATA
VALUE rb_vm_call0(rb_execution_context_t *ec, VALUE, ID, int, const VALUE *, const rb_callable_method_entry_t *, int kw_splat)
Definition: vm_eval.c:46
#define SYM2ID(x)
const char const char *typedef unsigned long VALUE
VALUE rb_ary_push(VALUE, VALUE)
Definition: array.c:1195
#define stderr
rb_control_frame_t struct rb_calling_info const struct rb_call_info * ci
rb_control_frame_t * reg_cfp
const rb_iseq_t const char const VALUE keys
#define RARRAY_ASET(a, i, v)
VALUE rb_hash_dup(VALUE)
Definition: hash.c:1564
uint32_t i
const rb_callable_method_entry_t * rb_callable_method_entry(VALUE klass, ID id)
Definition: vm_method.c:895
__inline__ const void *__restrict__ size_t len
const char * rb_obj_classname(VALUE)
Definition: variable.c:289
#define VM_CALL_ARGS_SPLAT
VALUE rb_hash_new_with_size(st_index_t size)
Definition: hash.c:1529
#define T_HASH
#define rb_long2int(n)
#define PRIsVALUE
VALUE rb_ary_tmp_new(long)
Definition: array.c:768
#define FIX2INT(x)
int VALUE v
#define rb_method_basic_definition_p(klass, mid)
VALUE rb_ary_new(void)
Definition: array.c:723
rb_control_frame_t * rb_vm_get_ruby_level_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
Definition: vm.c:553
#define RB_PASS_CALLED_KEYWORDS
#define rb_str_cat_cstr(str, ptr)
rb_control_frame_t struct rb_calling_info * calling
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val)
Definition: proc.c:728
#define GET_BLOCK_HANDLER()
#define CHECK_VM_STACK_OVERFLOW(cfp, margin)
const rb_iseq_t * iseq
#define RARRAY_CONST_PTR_TRANSIENT(a)
#define TRUE
#define FALSE
#define RHASH_SIZE(h)
VALUE rb_ary_resize(VALUE ary, long len)
expands or shrinks ary to len elements.
Definition: array.c:1955
VALUE rb_hash_keys(VALUE hash)
Definition: hash.c:3409
void void rb_free_tmp_buffer(volatile VALUE *store)
Definition: gc.c:10290
#define Qtrue
const rb_iseq_t const int const int const int max_argc
int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg)
Definition: hash.c:1442
#define UNLIKELY(x)
#define RB_NO_KEYWORDS
VALUE rb_block_param_proxy
Definition: vm.c:368
VALUE rb_str_append(VALUE, VALUE)
Definition: string.c:2965
VALUE rb_ary_dup(VALUE)
Definition: array.c:2238
#define vm_check_canary(ec, sp)
VALUE rb_attr_get(VALUE, ID)
Definition: variable.c:1084
#define Qnil
rb_control_frame_t struct rb_calling_info const rb_callable_method_entry_t int opt_pc
#define Qfalse
#define OBJ_FREEZE_RAW(x)
VALUE rb_check_hash_type(VALUE)
Definition: hash.c:1852
#define RB_TYPE_P(obj, type)
@ RHASH_PASS_AS_KEYWORDS
#define INT2FIX(i)
VALUE rb_check_array_type(VALUE)
Definition: array.c:909
VALUE rb_ary_unshift(VALUE, VALUE)
Definition: array.c:1494
#define MJIT_FUNC_EXPORTED
const VALUE * argv
#define VM_BLOCK_HANDLER_NONE
#define SYMBOL_P(x)
__inline__ int
VALUE rb_ivar_set(VALUE, ID, VALUE)
Definition: variable.c:1300
#define CLASS_OF(v)
#define VM_CALL_KWARG
if((__builtin_expect(!!(!me), 0)))
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
Definition: hash.c:2852
@ VM_FRAME_MAGIC_DUMMY
#define VM_CALL_KW_SPLAT
VALUE rb_ary_behead(VALUE, long)
Definition: array.c:1369
unsigned long ID
#define RHASH_EMPTY_P(h)
size_t st_index_t h
const rb_iseq_t const VALUE exc
#define RARRAY_AREF(a, i)
VALUE rb_hash_new(void)
Definition: hash.c:1523
#define LIKELY(x)
unsigned long VALUE
Definition: ruby.h:102
st_table * st_init_numtable(void)
Definition: st.c:653
int st_insert(st_table *tab, st_data_t key, st_data_t value)
Definition: st.c:1171
int st_lookup(st_table *tab, st_data_t key, st_data_t *value)
Definition: st.c:1101
const struct rb_call_info_kw_arg * kw_arg
struct rb_call_info_kw_arg * kw_arg
union rb_captured_block::@53 code
CREF (Class REFerence)
struct rb_iseq_constant_body::@45 param
const struct rb_iseq_constant_body::@45::rb_iseq_param_keyword * keyword
struct rb_iseq_constant_body::@45::@47 flags
struct rb_iseq_struct * local_iseq
struct rb_iseq_constant_body * body
#define KW_HASH_HAS_SYMBOL_KEY
Definition: vm_args.c:191
#define KW_HASH_HAS_OTHER_KEY
Definition: vm_args.c:192
VALUE rb_iseq_location(const rb_iseq_t *iseq)
Definition: proc.c:1242
#define KW_SPECIFIED_BITS_MAX
Definition: vm_args.c:465
@ arg_setup_block
Definition: vm_args.c:37
@ arg_setup_method
Definition: vm_args.c:36
#define KW_HASH_HAS_NO_KEYS
Definition: vm_args.c:190
#define KW_HASH_HAS_BOTH_KEYS
Definition: vm_args.c:193
void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self)
Definition: vm_backtrace.c:632
NORETURN(static void raise_argument_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const VALUE exc))
MJIT_FUNC_EXPORTED const rb_callable_method_entry_t * rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me)
Definition: vm_method.c:996
#define rb_id2str(id)
Definition: vm_backtrace.c:30
MJIT_STATIC void rb_vm_pop_frame(rb_execution_context_t *ec)
MJIT_STATIC VALUE rb_vm_bh_to_procval(const rb_execution_context_t *ec, VALUE block_handler)