Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
vm_eval.c
Go to the documentation of this file.
1/**********************************************************************
2
3 vm_eval.c -
4
5 $Author$
6 created at: Sat May 24 16:02:32 JST 2008
7
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
9 Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
10 Copyright (C) 2000 Information-technology Promotion Agency, Japan
11
12**********************************************************************/
13
14struct local_var_list {
15 VALUE tbl;
16};
17
18static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status, int kw_splat);
19static inline VALUE vm_yield_with_cref(rb_execution_context_t *ec, int argc, const VALUE *argv, int kw_splat, const rb_cref_t *cref, int is_lambda);
20static inline VALUE vm_yield(rb_execution_context_t *ec, int argc, const VALUE *argv, int kw_splat);
21static inline VALUE vm_yield_with_block(rb_execution_context_t *ec, int argc, const VALUE *argv, VALUE block_handler, int kw_splat);
22static inline VALUE vm_yield_force_blockarg(rb_execution_context_t *ec, VALUE args);
23VALUE vm_exec(rb_execution_context_t *ec, int mjit_enable_p);
24static void vm_set_eval_stack(rb_execution_context_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block);
25static int vm_collect_local_variables_in_heap(const VALUE *dfp, const struct local_var_list *vars);
26
27static VALUE rb_eUncaughtThrow;
28static ID id_result, id_tag, id_value;
29#define id_mesg idMesg
30
31typedef enum call_type {
39
40static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope);
41static VALUE vm_call0_body(rb_execution_context_t* ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv);
42
43#ifndef MJIT_HEADER
44
46rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat)
47{
49 struct rb_call_info ci = { id, (kw_splat ? VM_CALL_KW_SPLAT : 0), argc, };
50 struct rb_call_cache cc = { 0, { 0, }, me, me->def->method_serial, vm_call_general, { 0, }, };
51 struct rb_call_data cd = { cc, ci, };
52 return vm_call0_body(ec, &calling, &cd, argv);
53}
54
55static VALUE
56vm_call0_cfunc_with_frame(rb_execution_context_t* ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv)
57{
58 const struct rb_call_info *ci = &cd->ci;
59 const struct rb_call_cache *cc = &cd->cc;
60 VALUE val;
62 const rb_method_cfunc_t *cfunc = UNALIGNED_MEMBER_PTR(me->def, body.cfunc);
63 int len = cfunc->argc;
64 VALUE recv = calling->recv;
65 int argc = calling->argc;
66 ID mid = ci->mid;
67 VALUE block_handler = calling->block_handler;
69
70 if (calling->kw_splat) {
71 if (argc > 0 && RB_TYPE_P(argv[argc-1], T_HASH) && RHASH_EMPTY_P(argv[argc-1])) {
72 frame_flags |= VM_FRAME_FLAG_CFRAME_EMPTY_KW;
73 argc--;
74 }
75 else {
76 frame_flags |= VM_FRAME_FLAG_CFRAME_KW;
77 }
78 }
79
82 {
84
85 vm_push_frame(ec, 0, frame_flags, recv,
87 0, reg_cfp->sp, 0, 0);
88
89 if (len >= 0) rb_check_arity(argc, len, len);
90
91 val = (*cfunc->invoker)(recv, argc, argv, cfunc->func);
92
93 CHECK_CFP_CONSISTENCY("vm_call0_cfunc_with_frame");
95 }
98
99 return val;
100}
101
102static VALUE
103vm_call0_cfunc(rb_execution_context_t *ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv)
104{
105 return vm_call0_cfunc_with_frame(ec, calling, cd, argv);
106}
107
108/* `ci' should point temporal value (on stack value) */
109static VALUE
110vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, struct rb_call_data *cd, const VALUE *argv)
111{
112 const struct rb_call_info *ci = &cd->ci;
113 struct rb_call_cache *cc = &cd->cc;
114
115 VALUE ret;
116
117 calling->block_handler = vm_passed_block_handler(ec);
118
119 again:
120 switch (cc->me->def->type) {
122 {
124 int i;
125
128
129 *reg_cfp->sp++ = calling->recv;
130 for (i = 0; i < calling->argc; i++) {
131 *reg_cfp->sp++ = argv[i];
132 }
133
134 vm_call_iseq_setup(ec, reg_cfp, calling, cd);
135 VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH);
136 return vm_exec(ec, TRUE); /* CHECK_INTS in this function */
137 }
140 ret = vm_call0_cfunc(ec, calling, cd, argv);
141 goto success;
143 if (calling->kw_splat &&
144 calling->argc > 0 &&
145 RB_TYPE_P(argv[calling->argc-1], T_HASH) &&
146 RHASH_EMPTY_P(argv[calling->argc-1])) {
147 if (calling->argc == 1) {
148 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
149 }
150 else {
151 calling->argc--;
152 }
153 }
154
155 rb_check_arity(calling->argc, 1, 1);
156 ret = rb_ivar_set(calling->recv, cc->me->def->body.attr.id, argv[0]);
157 goto success;
159 if (calling->kw_splat &&
160 calling->argc > 0 &&
161 RB_TYPE_P(argv[calling->argc-1], T_HASH) &&
162 RHASH_EMPTY_P(argv[calling->argc-1])) {
163 calling->argc--;
164 }
165
166 rb_check_arity(calling->argc, 0, 0);
167 ret = rb_attr_get(calling->recv, cc->me->def->body.attr.id);
168 goto success;
170 ret = vm_call_bmethod_body(ec, calling, cd, argv);
171 goto success;
174 {
175 const rb_method_type_t type = cc->me->def->type;
176 VALUE super_class = cc->me->defined_class;
177
179 super_class = RCLASS_ORIGIN(super_class);
180 }
181 else if (cc->me->def->body.refined.orig_me) {
182 CC_SET_ME(cc, refined_method_callable_without_refinement(cc->me));
183 goto again;
184 }
185
186 super_class = RCLASS_SUPER(super_class);
187 if (super_class) {
188 CC_SET_ME(cc, rb_callable_method_entry(super_class, ci->mid));
189 if (cc->me) {
191 goto again;
192 }
193 }
194
196 ret = method_missing(calling->recv, ci->mid, calling->argc, argv, ex, calling->kw_splat);
197 goto success;
198 }
200 CC_SET_ME(cc, aliased_callable_method_entry(cc->me));
201 goto again;
203 {
204 vm_passed_block_handler_set(ec, calling->block_handler);
205 return method_missing(calling->recv, ci->mid, calling->argc,
206 argv, MISSING_NOENTRY, calling->kw_splat);
207 }
209 switch (cc->me->def->body.optimize_type) {
211 ret = send_internal(calling->argc, argv, calling->recv, calling->kw_splat ? CALL_FCALL_KW : CALL_FCALL);
212 goto success;
214 {
215 rb_proc_t *proc;
216 GetProcPtr(calling->recv, proc);
217 ret = rb_vm_invoke_proc(ec, proc, calling->argc, argv, calling->kw_splat, calling->block_handler);
218 goto success;
219 }
220 default:
221 rb_bug("vm_call0: unsupported optimized method type (%d)", cc->me->def->body.optimize_type);
222 }
223 break;
225 break;
226 }
227 rb_bug("vm_call0: unsupported method type (%d)", cc->me->def->type);
228 return Qundef;
229
230 success:
232 return ret;
233}
234
235/* Caller should keep the reference to the return value until argv becomes useless. */
237rb_adjust_argv_kw_splat(int *argc, const VALUE **argv, int *kw_splat)
238{
239 if (*kw_splat == RB_PASS_CALLED_KEYWORDS || *kw_splat == RB_PASS_EMPTY_KEYWORDS) {
240 if (*kw_splat == RB_PASS_EMPTY_KEYWORDS || rb_empty_keyword_given_p()) {
241 int n = *argc;
242 VALUE v;
243 VALUE *ptr = rb_alloc_tmp_buffer2(&v, n+1, sizeof(VALUE));
244 if (n) memcpy(ptr, *argv, sizeof(VALUE)*n);
245 ptr[n] = rb_hash_new();
246 *argc = ++n;
247 *argv = ptr;
248 *kw_splat = 1;
249 return v;
250 }
251 else {
252 *kw_splat = rb_keyword_given_p();
253 }
254 }
255
256 if (*kw_splat && (*argc == 0 || !RB_TYPE_P((*argv)[(*argc)-1], T_HASH))) {
257 rb_warn("Keyword flag passed calling internal method, but last entry is not a hash, unsetting keyword flag");
258 *kw_splat = 0;
259 }
260
261 return 0;
262}
263
266{
267 VALUE v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
268 VALUE ret = rb_vm_call0(ec, recv, id, argc, argv, me, kw_splat);
270 return ret;
271}
272
273static inline VALUE
274vm_call_super(rb_execution_context_t *ec, int argc, const VALUE *argv, int kw_splat)
275{
276 VALUE recv = ec->cfp->self;
277 VALUE klass;
278 ID id;
281
282 if (VM_FRAME_RUBYFRAME_P(cfp)) {
283 rb_bug("vm_call_super: should not be reached");
284 }
285
288 id = me->def->original_id;
290
291 if (!me) {
292 return method_missing(recv, id, argc, argv, MISSING_SUPER, kw_splat);
293 }
294 return rb_vm_call_kw(ec, recv, id, argc, argv, me, kw_splat);
295}
296
297VALUE
298rb_call_super_kw(int argc, const VALUE *argv, int kw_splat)
299{
302 return vm_call_super(ec, argc, argv, kw_splat);
303}
304
305VALUE
307{
310 return vm_call_super(ec, argc, argv, RB_NO_KEYWORDS);
311}
312
313VALUE
315{
316 const rb_execution_context_t *ec = GET_EC();
318 if (!ec || !(cfp = ec->cfp)) {
319 rb_raise(rb_eRuntimeError, "no self, no life");
320 }
321 return cfp->self;
322}
323
324#endif /* #ifndef MJIT_HEADER */
325
326static inline void
327stack_check(rb_execution_context_t *ec)
328{
330 rb_ec_stack_check(ec)) {
333 }
334}
335
336#ifndef MJIT_HEADER
337
338static inline const rb_callable_method_entry_t *rb_search_method_entry(VALUE recv, ID mid);
339static inline enum method_missing_reason rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry_t *me, call_type scope, VALUE self);
340
357static inline VALUE
358rb_call0(rb_execution_context_t *ec,
359 VALUE recv, ID mid, int argc, const VALUE *argv,
360 call_type call_scope, VALUE self)
361{
364 call_type scope = call_scope;
365 int kw_splat = RB_NO_KEYWORDS;
366
367 switch(scope) {
368 case(CALL_PUBLIC_KW):
369 scope = CALL_PUBLIC;
370 kw_splat = 1;
371 break;
372 case(CALL_FCALL_KW):
373 scope = CALL_FCALL;
374 kw_splat = 1;
375 break;
376 default:
377 break;
378 }
379
380 if (scope == CALL_PUBLIC) {
382 }
383 else {
384 me = rb_search_method_entry(recv, mid);
385 }
386 call_status = rb_method_call_status(ec, me, scope, self);
387
388 if (call_status != MISSING_NONE) {
389 return method_missing(recv, mid, argc, argv, call_status, kw_splat);
390 }
391 stack_check(ec);
392 return rb_vm_call_kw(ec, recv, mid, argc, argv, me, kw_splat);
393}
394
401 unsigned int respond: 1;
402 unsigned int respond_to_missing: 1;
403 int argc;
404 const VALUE *argv;
406};
407
408static VALUE
409check_funcall_exec(VALUE v)
410{
411 struct rescue_funcall_args *args = (void *)v;
412 return call_method_entry(args->ec, args->defined_class,
413 args->recv, idMethodMissing,
414 args->me, args->argc, args->argv, args->kw_splat);
415}
416
417static VALUE
418check_funcall_failed(VALUE v, VALUE e)
419{
420 struct rescue_funcall_args *args = (void *)v;
421 int ret = args->respond;
422 if (!ret) {
423 switch (rb_method_boundp(args->defined_class, args->mid,
425 case 2:
426 ret = TRUE;
427 break;
428 case 0:
429 ret = args->respond_to_missing;
430 break;
431 default:
432 ret = FALSE;
433 break;
434 }
435 }
436 if (ret) {
437 rb_exc_raise(e);
438 }
439 return Qundef;
440}
441
442static int
443check_funcall_respond_to(rb_execution_context_t *ec, VALUE klass, VALUE recv, ID mid)
444{
445 return vm_respond_to(ec, klass, recv, mid, TRUE);
446}
447
448static int
449check_funcall_callable(rb_execution_context_t *ec, const rb_callable_method_entry_t *me)
450{
451 return rb_method_call_status(ec, me, CALL_FCALL, ec->cfp->self) == MISSING_NONE;
452}
453
454static VALUE
455check_funcall_missing(rb_execution_context_t *ec, VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int respond, VALUE def, int kw_splat)
456{
457 struct rescue_funcall_args args;
458 const rb_method_entry_t *me;
459 VALUE ret = Qundef;
460
461 ret = basic_obj_respond_to_missing(ec, klass, recv,
462 ID2SYM(mid), Qtrue);
463 if (!RTEST(ret)) return def;
464 args.respond = respond > 0;
465 args.respond_to_missing = (ret != Qundef);
466 ret = def;
467 me = method_entry_get(klass, idMethodMissing, &args.defined_class);
468 if (me && !METHOD_ENTRY_BASIC(me)) {
469 VALUE argbuf, *new_args = ALLOCV_N(VALUE, argbuf, argc+1);
470
471 new_args[0] = ID2SYM(mid);
472 #ifdef __GLIBC__
473 if (!argv) {
474 static const VALUE buf = Qfalse;
475 VM_ASSERT(argc == 0);
476 argv = &buf;
477 }
478 #endif
479 MEMCPY(new_args+1, argv, VALUE, argc);
481 args.ec = ec;
482 args.recv = recv;
483 args.me = me;
484 args.mid = mid;
485 args.argc = argc + 1;
486 args.argv = new_args;
487 args.kw_splat = kw_splat;
488 ret = rb_rescue2(check_funcall_exec, (VALUE)&args,
489 check_funcall_failed, (VALUE)&args,
491 ALLOCV_END(argbuf);
492 }
493 return ret;
494}
495
496static VALUE rb_check_funcall_default_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def, int kw_splat);
497
498VALUE
500{
501 return rb_check_funcall_default_kw(recv, mid, argc, argv, Qundef, kw_splat);
502}
503
504VALUE
506{
507 return rb_check_funcall_default_kw(recv, mid, argc, argv, Qundef, RB_NO_KEYWORDS);
508}
509
510static VALUE
511rb_check_funcall_default_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def, int kw_splat)
512{
516 int respond = check_funcall_respond_to(ec, klass, recv, mid);
517
518 if (!respond)
519 return def;
520
521 me = rb_search_method_entry(recv, mid);
522 if (!check_funcall_callable(ec, me)) {
523 VALUE ret = check_funcall_missing(ec, klass, recv, mid, argc, argv,
524 respond, def, kw_splat);
525 if (ret == Qundef) ret = def;
526 return ret;
527 }
528 stack_check(ec);
529 return rb_vm_call_kw(ec, recv, mid, argc, argv, me, kw_splat);
530}
531
532VALUE
534{
535 return rb_check_funcall_default_kw(recv, mid, argc, argv, def, RB_NO_KEYWORDS);
536}
537
538VALUE
541{
545 int respond = check_funcall_respond_to(ec, klass, recv, mid);
546
547 if (!respond) {
548 (*hook)(FALSE, recv, mid, argc, argv, arg);
549 return Qundef;
550 }
551
552 me = rb_search_method_entry(recv, mid);
553 if (!check_funcall_callable(ec, me)) {
554 VALUE ret = check_funcall_missing(ec, klass, recv, mid, argc, argv,
556 (*hook)(ret != Qundef, recv, mid, argc, argv, arg);
557 return ret;
558 }
559 stack_check(ec);
560 (*hook)(TRUE, recv, mid, argc, argv, arg);
561 return rb_vm_call_kw(ec, recv, mid, argc, argv, me, kw_splat);
562}
563
564VALUE
567{
569}
570
571const char *
573{
574#define type_case(t) t: return #t
575 switch (type) {
576 case type_case(T_NONE);
577 case type_case(T_OBJECT);
578 case type_case(T_CLASS);
579 case type_case(T_MODULE);
580 case type_case(T_FLOAT);
581 case type_case(T_STRING);
582 case type_case(T_REGEXP);
583 case type_case(T_ARRAY);
584 case type_case(T_HASH);
585 case type_case(T_STRUCT);
586 case type_case(T_BIGNUM);
587 case type_case(T_FILE);
588 case type_case(T_DATA);
589 case type_case(T_MATCH);
590 case type_case(T_COMPLEX);
591 case type_case(T_RATIONAL);
592 case type_case(T_NIL);
593 case type_case(T_TRUE);
594 case type_case(T_FALSE);
595 case type_case(T_SYMBOL);
596 case type_case(T_FIXNUM);
597 case type_case(T_IMEMO);
598 case type_case(T_UNDEF);
599 case type_case(T_NODE);
600 case type_case(T_ICLASS);
601 case type_case(T_ZOMBIE);
602 case type_case(T_MOVED);
603 case T_MASK: break;
604 }
605#undef type_case
606 return NULL;
607}
608
609NORETURN(static void uncallable_object(VALUE recv, ID mid));
610static void
611uncallable_object(VALUE recv, ID mid)
612{
613 VALUE flags;
614 int type;
615 const char *typestr;
616 VALUE mname = rb_id2str(mid);
617
618 if (SPECIAL_CONST_P(recv)) {
620 "method `%"PRIsVALUE"' called on unexpected immediate object (%p)",
621 mname, (void *)recv);
622 }
623 else if ((flags = RBASIC(recv)->flags) == 0) {
625 "method `%"PRIsVALUE"' called on terminated object (%p)",
626 mname, (void *)recv);
627 }
628 else if (!(typestr = rb_type_str(type = BUILTIN_TYPE(recv)))) {
630 "method `%"PRIsVALUE"' called on broken T_?""?""?(0x%02x) object"
631 " (%p flags=0x%"PRIxVALUE")",
632 mname, type, (void *)recv, flags);
633 }
634 else if (T_OBJECT <= type && type < T_NIL) {
636 "method `%"PRIsVALUE"' called on hidden %s object"
637 " (%p flags=0x%"PRIxVALUE")",
638 mname, typestr, (void *)recv, flags);
639 }
640 else {
642 "method `%"PRIsVALUE"' called on unexpected %s object"
643 " (%p flags=0x%"PRIxVALUE")",
644 mname, typestr, (void *)recv, flags);
645 }
646}
647
648static inline const rb_callable_method_entry_t *
649rb_search_method_entry(VALUE recv, ID mid)
650{
652
653 if (!klass) uncallable_object(recv, mid);
655}
656
657static inline enum method_missing_reason
658rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry_t *me, call_type scope, VALUE self)
659{
660 VALUE klass;
661 ID oid;
663
665 undefined:
666 return scope == CALL_VCALL ? MISSING_VCALL : MISSING_NOENTRY;
667 }
671 }
672
673 klass = me->owner;
674 oid = me->def->original_id;
675 visi = METHOD_ENTRY_VISI(me);
676
677 if (oid != idMethodMissing) {
678 /* receiver specified form for private method */
679 if (UNLIKELY(visi != METHOD_VISI_PUBLIC)) {
680 if (visi == METHOD_VISI_PRIVATE && scope == CALL_PUBLIC) {
681 return MISSING_PRIVATE;
682 }
683
684 /* self must be kind of a specified form for protected method */
685 if (visi == METHOD_VISI_PROTECTED && scope == CALL_PUBLIC) {
687
690 }
691
692 if (self == Qundef || !rb_obj_is_kind_of(self, defined_class)) {
693 return MISSING_PROTECTED;
694 }
695 }
696 }
697 }
698
699 return MISSING_NONE;
700}
701
702
714static inline VALUE
715rb_call(VALUE recv, ID mid, int argc, const VALUE *argv, call_type scope)
716{
718 return rb_call0(ec, recv, mid, argc, argv, scope, ec->cfp->self);
719}
720
721NORETURN(static void raise_method_missing(rb_execution_context_t *ec, int argc, const VALUE *argv,
723
724/*
725 * call-seq:
726 * obj.method_missing(symbol [, *args] ) -> result
727 *
728 * Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
729 * <i>symbol</i> is the symbol for the method called, and <i>args</i>
730 * are any arguments that were passed to it. By default, the interpreter
731 * raises an error when this method is called. However, it is possible
732 * to override the method to provide more dynamic behavior.
733 * If it is decided that a particular method should not be handled, then
734 * <i>super</i> should be called, so that ancestors can pick up the
735 * missing method.
736 * The example below creates
737 * a class <code>Roman</code>, which responds to methods with names
738 * consisting of roman numerals, returning the corresponding integer
739 * values.
740 *
741 * class Roman
742 * def roman_to_int(str)
743 * # ...
744 * end
745 *
746 * def method_missing(symbol, *args)
747 * str = symbol.id2name
748 * begin
749 * roman_to_int(str)
750 * rescue
751 * super(symbol, *args)
752 * end
753 * end
754 * end
755 *
756 * r = Roman.new
757 * r.iv #=> 4
758 * r.xxiii #=> 23
759 * r.mm #=> 2000
760 * r.foo #=> NoMethodError
761 */
762
763static VALUE
764rb_method_missing(int argc, const VALUE *argv, VALUE obj)
765{
767 raise_method_missing(ec, argc, argv, obj, ec->method_missing_reason);
769}
770
773 int argc, const VALUE *argv, int priv)
774{
775 VALUE name = argv[0];
776
777 if (!format) {
778 format = rb_fstring_lit("undefined method `%s' for %s%s%s");
779 }
780 if (exc == rb_eNoMethodError) {
781 VALUE args = rb_ary_new4(argc - 1, argv + 1);
782 return rb_nomethod_err_new(format, obj, name, args, priv);
783 }
784 else {
785 return rb_name_err_new(format, obj, name);
786 }
787}
788
789#endif /* #ifndef MJIT_HEADER */
790
791static void
792raise_method_missing(rb_execution_context_t *ec, int argc, const VALUE *argv, VALUE obj,
793 enum method_missing_reason last_call_status)
794{
796 VALUE format = 0;
797
798 if (UNLIKELY(argc == 0)) {
799 rb_raise(rb_eArgError, "no method name given");
800 }
801 else if (UNLIKELY(!SYMBOL_P(argv[0]))) {
802 const VALUE e = rb_eArgError; /* TODO: TypeError? */
803 rb_raise(e, "method name must be a Symbol but %"PRIsVALUE" is given",
804 rb_obj_class(argv[0]));
805 }
806
807 stack_check(ec);
808
809 if (last_call_status & MISSING_PRIVATE) {
810 format = rb_fstring_lit("private method `%s' called for %s%s%s");
811 }
812 else if (last_call_status & MISSING_PROTECTED) {
813 format = rb_fstring_lit("protected method `%s' called for %s%s%s");
814 }
815 else if (last_call_status & MISSING_VCALL) {
816 format = rb_fstring_lit("undefined local variable or method `%s' for %s%s%s");
818 }
819 else if (last_call_status & MISSING_SUPER) {
820 format = rb_fstring_lit("super: no superclass method `%s' for %s%s%s");
821 }
822
823 {
825 last_call_status & (MISSING_FCALL|MISSING_VCALL));
826 if (!(last_call_status & MISSING_MISSING)) {
828 }
830 }
831}
832
833static void
834vm_raise_method_missing(rb_execution_context_t *ec, int argc, const VALUE *argv,
835 VALUE obj, int call_status)
836{
837 vm_passed_block_handler_set(ec, VM_BLOCK_HANDLER_NONE);
838 raise_method_missing(ec, argc, argv, obj, call_status | MISSING_MISSING);
839}
840
841static inline VALUE
842method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status, int kw_splat)
843{
844 VALUE *nargv, result, work, klass;
846 VALUE block_handler = vm_passed_block_handler(ec);
848
850
851 if (id == idMethodMissing) {
852 missing:
853 raise_method_missing(ec, argc, argv, obj, call_status | MISSING_MISSING);
854 }
855
856 nargv = ALLOCV_N(VALUE, work, argc + 1);
857 nargv[0] = ID2SYM(id);
858 #ifdef __GLIBC__
859 if (!argv) {
860 static const VALUE buf = Qfalse;
861 VM_ASSERT(argc == 0);
862 argv = &buf;
863 }
864 #endif
865 MEMCPY(nargv + 1, argv, VALUE, argc);
866 ++argc;
867 argv = nargv;
868
869 klass = CLASS_OF(obj);
870 if (!klass) goto missing;
872 if (!me || METHOD_ENTRY_BASIC(me)) goto missing;
873 vm_passed_block_handler_set(ec, block_handler);
875 if (work) ALLOCV_END(work);
876 return result;
877}
878
879#ifndef MJIT_HEADER
880
889VALUE
891{
892 int argc;
893 VALUE *argv, ret;
894
895 argc = RARRAY_LENINT(args);
896 if (argc >= 0x100) {
897 args = rb_ary_subseq(args, 0, argc);
898 RBASIC_CLEAR_CLASS(args);
899 OBJ_FREEZE(args);
900 ret = rb_call(recv, mid, argc, RARRAY_CONST_PTR(args), CALL_FCALL);
901 RB_GC_GUARD(args);
902 return ret;
903 }
906 return rb_call(recv, mid, argc, argv, CALL_FCALL);
907}
908
909#ifdef rb_funcall
910#undef rb_funcall
911#endif
921VALUE
923{
924 VALUE *argv;
925 va_list ar;
926
927 if (n > 0) {
928 long i;
929
930 va_init_list(ar, n);
931
932 argv = ALLOCA_N(VALUE, n);
933
934 for (i = 0; i < n; i++) {
935 argv[i] = va_arg(ar, VALUE);
936 }
937 va_end(ar);
938 }
939 else {
940 argv = 0;
941 }
942 return rb_call(recv, mid, n, argv, CALL_FCALL);
943}
944
945#ifdef rb_funcallv
946#undef rb_funcallv
947#endif
955VALUE
957{
958 return rb_call(recv, mid, argc, argv, CALL_FCALL);
959}
960
961VALUE
963{
965 VALUE ret = rb_call(recv, mid, argc, argv, kw_splat ? CALL_FCALL_KW : CALL_FCALL);
967 return ret;
968}
969
979VALUE
981{
982 return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
983}
984
985VALUE
987{
989 VALUE ret = rb_call(recv, mid, argc, argv, kw_splat ? CALL_PUBLIC_KW : CALL_PUBLIC);
991 return ret;
992}
993
1003VALUE
1004rb_funcallv_with_cc(struct rb_call_data *cd, VALUE recv, ID mid, int argc, const VALUE *argv)
1005{
1006 const struct rb_call_info *ci = &cd->ci;
1007 struct rb_call_cache *cc = &cd->cc;
1008
1009 if (LIKELY(ci->mid == mid)) {
1010 vm_search_method(cd, recv);
1011
1013 return vm_call0_body(
1014 GET_EC(),
1015 &(struct rb_calling_info) {
1016 Qundef,
1017 recv,
1018 argc,
1020 },
1021 cd,
1022 argv
1023 );
1024 }
1025 }
1026
1027 *cd = (struct rb_call_data) /* reset */ { { 0, }, { mid, }, };
1028 return rb_funcallv(recv, mid, argc, argv);
1029}
1030
1031VALUE
1033{
1035 return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
1036}
1037
1038VALUE
1039rb_funcall_passing_block_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
1040{
1041 VALUE v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1042 VALUE ret;
1044 ret = rb_call(recv, mid, argc, argv, kw_splat ? CALL_PUBLIC_KW : CALL_PUBLIC);
1046 return ret;
1047}
1048
1049VALUE
1050rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval)
1051{
1052 if (!NIL_P(passed_procval)) {
1053 vm_passed_block_handler_set(GET_EC(), passed_procval);
1054 }
1055
1056 return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
1057}
1058
1059VALUE
1060rb_funcall_with_block_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval, int kw_splat)
1061{
1062 if (!NIL_P(passed_procval)) {
1063 vm_passed_block_handler_set(GET_EC(), passed_procval);
1064 }
1065
1066 VALUE v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1067 VALUE ret = rb_call(recv, mid, argc, argv, kw_splat ? CALL_PUBLIC_KW : CALL_PUBLIC);
1069 return ret;
1070}
1071
1072static VALUE *
1073current_vm_stack_arg(const rb_execution_context_t *ec, const VALUE *argv)
1074{
1076 if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, prev_cfp)) return NULL;
1077 if (prev_cfp->sp + 1 != argv) return NULL;
1078 return prev_cfp->sp + 1;
1079}
1080
1081static VALUE
1082send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope)
1083{
1084 ID id;
1085 VALUE vid;
1086 VALUE self;
1087 VALUE ret, vargv = 0;
1089 int public = scope == CALL_PUBLIC || scope == CALL_PUBLIC_KW;
1090
1091 if (public) {
1092 self = Qundef;
1093 }
1094 else {
1095 self = RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp)->self;
1096 }
1097
1098 if (argc == 0) {
1099 rb_raise(rb_eArgError, "no method name given");
1100 }
1101
1102 vid = *argv;
1103
1104 id = rb_check_id(&vid);
1105 if (!id) {
1108 recv, argc, argv,
1109 !public);
1111 }
1112 if (!SYMBOL_P(*argv)) {
1113 VALUE *tmp_argv = current_vm_stack_arg(ec, argv);
1114 vid = rb_str_intern(vid);
1115 if (tmp_argv) {
1116 tmp_argv[0] = vid;
1117 }
1118 else if (argc > 1) {
1119 tmp_argv = ALLOCV_N(VALUE, vargv, argc);
1120 tmp_argv[0] = vid;
1121 MEMCPY(tmp_argv+1, argv+1, VALUE, argc-1);
1122 argv = tmp_argv;
1123 }
1124 else {
1125 argv = &vid;
1126 }
1127 }
1128 id = idMethodMissing;
1130 }
1131 else {
1132 argv++; argc--;
1133 }
1135 ret = rb_call0(ec, recv, id, argc, argv, scope, self);
1136 ALLOCV_END(vargv);
1137 return ret;
1138}
1139
1140static VALUE
1141send_internal_kw(int argc, const VALUE *argv, VALUE recv, call_type scope)
1142{
1143 VALUE v=0, ret;
1144 int kw_splat = RB_PASS_CALLED_KEYWORDS;
1145 v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1146 if (kw_splat) {
1147 switch (scope) {
1148 case CALL_PUBLIC:
1149 scope = CALL_PUBLIC_KW;
1150 break;
1151 case CALL_FCALL:
1152 scope = CALL_FCALL_KW;
1153 break;
1154 default:
1155 break;
1156 }
1157 }
1158 ret = send_internal(argc, argv, recv, scope);
1160 return ret;
1161}
1162
1163/*
1164 * call-seq:
1165 * foo.send(symbol [, args...]) -> obj
1166 * foo.__send__(symbol [, args...]) -> obj
1167 * foo.send(string [, args...]) -> obj
1168 * foo.__send__(string [, args...]) -> obj
1169 *
1170 * Invokes the method identified by _symbol_, passing it any
1171 * arguments specified. You can use <code>__send__</code> if the name
1172 * +send+ clashes with an existing method in _obj_.
1173 * When the method is identified by a string, the string is converted
1174 * to a symbol.
1175 *
1176 * BasicObject implements +__send__+, Kernel implements +send+.
1177 *
1178 * class Klass
1179 * def hello(*args)
1180 * "Hello " + args.join(' ')
1181 * end
1182 * end
1183 * k = Klass.new
1184 * k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
1185 */
1186
1187VALUE
1189{
1190 return send_internal_kw(argc, argv, recv, CALL_FCALL);
1191}
1192
1193/*
1194 * call-seq:
1195 * obj.public_send(symbol [, args...]) -> obj
1196 * obj.public_send(string [, args...]) -> obj
1197 *
1198 * Invokes the method identified by _symbol_, passing it any
1199 * arguments specified. Unlike send, public_send calls public
1200 * methods only.
1201 * When the method is identified by a string, the string is converted
1202 * to a symbol.
1203 *
1204 * 1.public_send(:puts, "hello") # causes NoMethodError
1205 */
1206
1207static VALUE
1208rb_f_public_send(int argc, VALUE *argv, VALUE recv)
1209{
1210 return send_internal_kw(argc, argv, recv, CALL_PUBLIC);
1211}
1212
1213/* yield */
1214
1215static inline VALUE
1216rb_yield_0_kw(int argc, const VALUE * argv, int kw_splat)
1217{
1218 VALUE v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1219 VALUE ret = vm_yield(GET_EC(), argc, argv, kw_splat);
1221 return ret;
1222}
1223
1224static inline VALUE
1225rb_yield_0(int argc, const VALUE * argv)
1226{
1227 return vm_yield(GET_EC(), argc, argv, RB_NO_KEYWORDS);
1228}
1229
1230VALUE
1232{
1233 return rb_yield_0(1, &val);
1234}
1235
1236VALUE
1238{
1239 if (val == Qundef) {
1240 return rb_yield_0(0, 0);
1241 }
1242 else {
1243 return rb_yield_1(val);
1244 }
1245}
1246
1247#undef rb_yield_values
1248VALUE
1250{
1251 if (n == 0) {
1252 return rb_yield_0(0, 0);
1253 }
1254 else {
1255 int i;
1256 VALUE *argv;
1257 va_list args;
1258 argv = ALLOCA_N(VALUE, n);
1259
1260 va_init_list(args, n);
1261 for (i=0; i<n; i++) {
1262 argv[i] = va_arg(args, VALUE);
1263 }
1264 va_end(args);
1265
1266 return rb_yield_0(n, argv);
1267 }
1268}
1269
1270VALUE
1272{
1273 return rb_yield_0(argc, argv);
1274}
1275
1276VALUE
1277rb_yield_values_kw(int argc, const VALUE *argv, int kw_splat)
1278{
1279 return rb_yield_0_kw(argc, argv, kw_splat);
1280}
1281
1282VALUE
1284{
1285 VALUE tmp = rb_check_array_type(values);
1286 VALUE v;
1287 if (NIL_P(tmp)) {
1288 rb_raise(rb_eArgError, "not an array");
1289 }
1290 v = rb_yield_0(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp));
1291 RB_GC_GUARD(tmp);
1292 return v;
1293}
1294
1295VALUE
1296rb_yield_splat_kw(VALUE values, int kw_splat)
1297{
1298 VALUE tmp = rb_check_array_type(values);
1299 VALUE v;
1300 if (NIL_P(tmp)) {
1301 rb_raise(rb_eArgError, "not an array");
1302 }
1303 v = rb_yield_0_kw(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), kw_splat);
1304 RB_GC_GUARD(tmp);
1305 return v;
1306}
1307
1308VALUE
1310{
1311 return vm_yield_force_blockarg(GET_EC(), values);
1312}
1313
1314VALUE
1316{
1317 int kw_splat = RB_PASS_CALLED_KEYWORDS;
1318 VALUE v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1319 VALUE ret = vm_yield_with_block(GET_EC(), argc, argv,
1320 NIL_P(blockarg) ? VM_BLOCK_HANDLER_NONE : blockarg,
1321 kw_splat);
1323 return ret;
1324}
1325
1326static VALUE
1327loop_i(VALUE _)
1328{
1329 for (;;) {
1330 rb_yield_0(0, 0);
1331 }
1332 return Qnil;
1333}
1334
1335static VALUE
1336loop_stop(VALUE dummy, VALUE exc)
1337{
1338 return rb_attr_get(exc, id_result);
1339}
1340
1341static VALUE
1342rb_f_loop_size(VALUE self, VALUE args, VALUE eobj)
1343{
1344 return DBL2NUM(HUGE_VAL);
1345}
1346
1347/*
1348 * call-seq:
1349 * loop { block }
1350 * loop -> an_enumerator
1351 *
1352 * Repeatedly executes the block.
1353 *
1354 * If no block is given, an enumerator is returned instead.
1355 *
1356 * loop do
1357 * print "Input: "
1358 * line = gets
1359 * break if !line or line =~ /^qQ/
1360 * # ...
1361 * end
1362 *
1363 * StopIteration raised in the block breaks the loop. In this case,
1364 * loop returns the "result" value stored in the exception.
1365 *
1366 * enum = Enumerator.new { |y|
1367 * y << "one"
1368 * y << "two"
1369 * :ok
1370 * }
1371 *
1372 * result = loop {
1373 * puts enum.next
1374 * } #=> :ok
1375 */
1376
1377static VALUE
1378rb_f_loop(VALUE self)
1379{
1380 RETURN_SIZED_ENUMERATOR(self, 0, 0, rb_f_loop_size);
1381 return rb_rescue2(loop_i, (VALUE)0, loop_stop, (VALUE)0, rb_eStopIteration, (VALUE)0);
1382}
1383
1384#if VMDEBUG
1385static const char *
1386vm_frametype_name(const rb_control_frame_t *cfp);
1387#endif
1388
1389static VALUE
1390rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
1391 const struct vm_ifunc *const ifunc,
1393{
1394 enum ruby_tag_type state;
1395 volatile VALUE retval = Qnil;
1396 rb_control_frame_t *const cfp = ec->cfp;
1397
1398 EC_PUSH_TAG(ec);
1399 state = EC_EXEC_TAG();
1400 if (state == 0) {
1401 iter_retry:
1402 {
1404
1405 if (ifunc) {
1406 struct rb_captured_block *captured = VM_CFP_TO_CAPTURED_BLOCK(cfp);
1407 captured->code.ifunc = ifunc;
1408 block_handler = VM_BH_FROM_IFUNC_BLOCK(captured);
1409 }
1410 else {
1411 block_handler = VM_CF_BLOCK_HANDLER(cfp);
1412 }
1413 vm_passed_block_handler_set(ec, block_handler);
1414 }
1415 retval = (*it_proc) (data1);
1416 }
1417 else if (state == TAG_BREAK || state == TAG_RETRY) {
1418 const struct vm_throw_data *const err = (struct vm_throw_data *)ec->errinfo;
1419 const rb_control_frame_t *const escape_cfp = THROW_DATA_CATCH_FRAME(err);
1420
1421 if (cfp == escape_cfp) {
1422 rb_vm_rewind_cfp(ec, cfp);
1423
1424 state = 0;
1425 ec->tag->state = TAG_NONE;
1426 ec->errinfo = Qnil;
1427
1428 if (state == TAG_RETRY) goto iter_retry;
1429 retval = THROW_DATA_VAL(err);
1430 }
1431 else if (0) {
1432 SDR(); fprintf(stderr, "%p, %p\n", (void *)cfp, (void *)escape_cfp);
1433 }
1434 }
1435 EC_POP_TAG();
1436
1437 if (state) {
1438 EC_JUMP_TAG(ec, state);
1439 }
1440 return retval;
1441}
1442
1443VALUE
1444rb_iterate(VALUE (* it_proc)(VALUE), VALUE data1,
1445 rb_block_call_func_t bl_proc, VALUE data2)
1446{
1447 return rb_iterate0(it_proc, data1,
1448 bl_proc ? rb_vm_ifunc_proc_new(bl_proc, (void *)data2) : 0,
1449 GET_EC());
1450}
1451
1455 int argc;
1456 const VALUE *argv;
1458};
1459
1460static VALUE
1461iterate_method(VALUE obj)
1462{
1463 const struct iter_method_arg * arg =
1464 (struct iter_method_arg *) obj;
1465
1466 return rb_call(arg->obj, arg->mid, arg->argc, arg->argv, arg->kw_splat ? CALL_FCALL_KW : CALL_FCALL);
1467}
1468
1469VALUE
1471 rb_block_call_func_t bl_proc, VALUE data2)
1472{
1473 struct iter_method_arg arg;
1474
1475 arg.obj = obj;
1476 arg.mid = mid;
1477 arg.argc = argc;
1478 arg.argv = argv;
1479 arg.kw_splat = 0;
1480 return rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2);
1481}
1482
1483VALUE
1485 rb_block_call_func_t bl_proc, VALUE data2, int kw_splat)
1486{
1487 struct iter_method_arg arg;
1488
1490 arg.obj = obj;
1491 arg.mid = mid;
1492 arg.argc = argc;
1493 arg.argv = argv;
1494 arg.kw_splat = kw_splat;
1495 VALUE ret = rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2);
1497 return ret;
1498}
1499
1500VALUE
1502 rb_block_call_func_t bl_proc, int min_argc, int max_argc,
1503 VALUE data2)
1504{
1505 struct iter_method_arg arg;
1506 struct vm_ifunc *block;
1507
1508 if (!bl_proc) rb_raise(rb_eArgError, "NULL lambda function");
1509 arg.obj = obj;
1510 arg.mid = mid;
1511 arg.argc = argc;
1512 arg.argv = argv;
1513 arg.kw_splat = 0;
1514 block = rb_vm_ifunc_new(bl_proc, (void *)data2, min_argc, max_argc);
1515 return rb_iterate0(iterate_method, (VALUE)&arg, block, GET_EC());
1516}
1517
1518static VALUE
1519iterate_check_method(VALUE obj)
1520{
1521 const struct iter_method_arg * arg =
1522 (struct iter_method_arg *) obj;
1523
1524 return rb_check_funcall(arg->obj, arg->mid, arg->argc, arg->argv);
1525}
1526
1527VALUE
1529 rb_block_call_func_t bl_proc, VALUE data2)
1530{
1531 struct iter_method_arg arg;
1532
1533 arg.obj = obj;
1534 arg.mid = mid;
1535 arg.argc = argc;
1536 arg.argv = argv;
1537 arg.kw_splat = 0;
1538 return rb_iterate(iterate_check_method, (VALUE)&arg, bl_proc, data2);
1539}
1540
1541VALUE
1543{
1544 return rb_call(obj, idEach, 0, 0, CALL_FCALL);
1545}
1546
1548static const rb_iseq_t *
1549eval_make_iseq(VALUE src, VALUE fname, int line, const rb_binding_t *bind,
1550 const struct rb_block *base_block)
1551{
1552 const VALUE parser = rb_parser_new();
1553 const rb_iseq_t *const parent = vm_block_iseq(base_block);
1555 rb_iseq_t *iseq = NULL;
1556 rb_ast_t *ast;
1557
1558 if (!fname) {
1559 fname = rb_source_location(&line);
1560 }
1561
1562 if (fname != Qundef) {
1563 if (!NIL_P(fname)) fname = rb_fstring(fname);
1564 realpath = fname;
1565 }
1566 else if (bind) {
1567 fname = pathobj_path(bind->pathobj);
1568 realpath = pathobj_realpath(bind->pathobj);
1569 line = bind->first_lineno;
1571 }
1572 else {
1573 fname = rb_fstring_lit("(eval)");
1574 }
1575
1576 rb_parser_set_context(parser, parent, FALSE);
1577 ast = rb_parser_compile_string_path(parser, fname, src, line);
1578 if (ast->body.root) {
1580 parent->body->location.label,
1581 fname, realpath, INT2FIX(line),
1582 parent, ISEQ_TYPE_EVAL, NULL);
1583 }
1584 rb_ast_dispose(ast);
1585
1586 if (iseq != NULL) {
1587 if (0 && iseq) { /* for debug */
1588 VALUE disasm = rb_iseq_disasm(iseq);
1589 printf("%s\n", StringValuePtr(disasm));
1590 }
1591
1592 rb_exec_event_hook_script_compiled(GET_EC(), iseq, src);
1593 }
1594
1595 return iseq;
1596}
1597
1598static VALUE
1599eval_string_with_cref(VALUE self, VALUE src, rb_cref_t *cref, VALUE file, int line)
1600{
1602 struct rb_block block;
1603 const rb_iseq_t *iseq;
1605 if (!cfp) {
1606 rb_raise(rb_eRuntimeError, "Can't eval on top of Fiber or Thread");
1607 }
1608
1609 block.as.captured = *VM_CFP_TO_CAPTURED_BLOCK(cfp);
1610 block.as.captured.self = self;
1611 block.as.captured.code.iseq = cfp->iseq;
1612 block.type = block_type_iseq;
1613
1614 iseq = eval_make_iseq(src, file, line, NULL, &block);
1615 if (!iseq) {
1616 rb_exc_raise(ec->errinfo);
1617 }
1618
1619 /* TODO: what the code checking? */
1620 if (!cref && block.as.captured.code.val) {
1621 rb_cref_t *orig_cref = vm_get_cref(vm_block_ep(&block));
1622 cref = vm_cref_dup(orig_cref);
1623 }
1624 vm_set_eval_stack(ec, iseq, cref, &block);
1625
1626 /* kick */
1627 return vm_exec(ec, TRUE);
1628}
1629
1630static VALUE
1631eval_string_with_scope(VALUE scope, VALUE src, VALUE file, int line)
1632{
1635 const rb_iseq_t *iseq = eval_make_iseq(src, file, line, bind, &bind->block);
1636 if (!iseq) {
1637 rb_exc_raise(ec->errinfo);
1638 }
1639
1640 vm_set_eval_stack(ec, iseq, NULL, &bind->block);
1641
1642 /* save new env */
1643 if (iseq->body->local_table_size > 0) {
1644 vm_bind_update_env(scope, bind, vm_make_env_object(ec, ec->cfp));
1645 }
1646
1647 /* kick */
1648 return vm_exec(ec, TRUE);
1649}
1650
1651/*
1652 * call-seq:
1653 * eval(string [, binding [, filename [,lineno]]]) -> obj
1654 *
1655 * Evaluates the Ruby expression(s) in <em>string</em>. If
1656 * <em>binding</em> is given, which must be a Binding object, the
1657 * evaluation is performed in its context. If the optional
1658 * <em>filename</em> and <em>lineno</em> parameters are present, they
1659 * will be used when reporting syntax errors.
1660 *
1661 * def get_binding(str)
1662 * return binding
1663 * end
1664 * str = "hello"
1665 * eval "str + ' Fred'" #=> "hello Fred"
1666 * eval "str + ' Fred'", get_binding("bye") #=> "bye Fred"
1667 */
1668
1669VALUE
1670rb_f_eval(int argc, const VALUE *argv, VALUE self)
1671{
1672 VALUE src, scope, vfile, vline;
1673 VALUE file = Qundef;
1674 int line = 1;
1675
1676 rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
1678 if (argc >= 3) {
1679 StringValue(vfile);
1680 }
1681 if (argc >= 4) {
1682 line = NUM2INT(vline);
1683 }
1684
1685 if (!NIL_P(vfile))
1686 file = vfile;
1687
1688 if (NIL_P(scope))
1689 return eval_string_with_cref(self, src, NULL, file, line);
1690 else
1691 return eval_string_with_scope(scope, src, file, line);
1692}
1693
1695VALUE
1696ruby_eval_string_from_file(const char *str, const char *filename)
1697{
1698 VALUE file = filename ? rb_str_new_cstr(filename) : 0;
1699 return eval_string_with_cref(rb_vm_top_self(), rb_str_new2(str), NULL, file, 1);
1700}
1701
1714VALUE
1716{
1717 return ruby_eval_string_from_file(str, "eval");
1718}
1719
1720static VALUE
1721eval_string_protect(VALUE str)
1722{
1723 return rb_eval_string((char *)str);
1724}
1725
1736VALUE
1737rb_eval_string_protect(const char *str, int *pstate)
1738{
1739 return rb_protect(eval_string_protect, (VALUE)str, pstate);
1740}
1741
1745 const char *str;
1746};
1747
1748static VALUE
1749eval_string_wrap_protect(VALUE data)
1750{
1751 const struct eval_string_wrap_arg *const arg = (struct eval_string_wrap_arg*)data;
1753 cref->klass = arg->klass;
1754 return eval_string_with_cref(arg->top_self, rb_str_new_cstr(arg->str), cref, rb_str_new_cstr("eval"), 1);
1755}
1756
1768VALUE
1769rb_eval_string_wrap(const char *str, int *pstate)
1770{
1771 int state;
1772 rb_thread_t *th = GET_THREAD();
1773 VALUE self = th->top_self;
1774 VALUE wrapper = th->top_wrapper;
1775 VALUE val;
1776 struct eval_string_wrap_arg data;
1777
1778 th->top_wrapper = rb_module_new();
1781
1782 data.top_self = th->top_self;
1783 data.klass = th->top_wrapper;
1784 data.str = str;
1785
1786 val = rb_protect(eval_string_wrap_protect, (VALUE)&data, &state);
1787
1788 th->top_self = self;
1789 th->top_wrapper = wrapper;
1790
1791 if (pstate) {
1792 *pstate = state;
1793 }
1794 else if (state != TAG_NONE) {
1795 EC_JUMP_TAG(th->ec, state);
1796 }
1797 return val;
1798}
1799
1800VALUE
1801rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat)
1802{
1803 enum ruby_tag_type state;
1804 volatile VALUE val = Qnil; /* OK */
1805 rb_execution_context_t * volatile ec = GET_EC();
1806
1807 EC_PUSH_TAG(ec);
1808 if ((state = EC_EXEC_TAG()) == TAG_NONE) {
1809 if (!RB_TYPE_P(cmd, T_STRING)) {
1811 RARRAY_CONST_PTR(arg), kw_splat);
1812 }
1813 else {
1814 val = eval_string_with_cref(rb_vm_top_self(), cmd, NULL, 0, 0);
1815 }
1816 }
1817 EC_POP_TAG();
1818
1819 if (state) EC_JUMP_TAG(ec, state);
1820 return val;
1821}
1822
1823VALUE
1824rb_eval_cmd(VALUE cmd, VALUE arg, int _level)
1825{
1826 rb_warn("rb_eval_cmd will be removed in Ruby 3.0");
1827 return rb_eval_cmd_kw(cmd, arg, RB_NO_KEYWORDS);
1828}
1829
1830/* block eval under the class/module context */
1831
1832static VALUE
1833yield_under(VALUE under, VALUE self, int argc, const VALUE *argv, int kw_splat)
1834{
1836 rb_control_frame_t *cfp = ec->cfp;
1837 VALUE block_handler = VM_CF_BLOCK_HANDLER(cfp);
1838 VALUE new_block_handler = 0;
1839 const struct rb_captured_block *captured = NULL;
1840 struct rb_captured_block new_captured;
1841 const VALUE *ep = NULL;
1842 rb_cref_t *cref;
1843 int is_lambda = FALSE;
1844 VALUE v = 0, ret;
1845
1846 v = rb_adjust_argv_kw_splat(&argc, &argv, &kw_splat);
1847
1849 again:
1850 switch (vm_block_handler_type(block_handler)) {
1852 captured = VM_BH_TO_CAPT_BLOCK(block_handler);
1853 new_captured = *captured;
1854 new_block_handler = VM_BH_FROM_ISEQ_BLOCK(&new_captured);
1855 break;
1857 captured = VM_BH_TO_CAPT_BLOCK(block_handler);
1858 new_captured = *captured;
1859 new_block_handler = VM_BH_FROM_IFUNC_BLOCK(&new_captured);
1860 break;
1862 is_lambda = rb_proc_lambda_p(block_handler) != Qfalse;
1863 block_handler = vm_proc_to_block_handler(VM_BH_TO_PROC(block_handler));
1864 goto again;
1866 ret = rb_sym_proc_call(SYM2ID(VM_BH_TO_SYMBOL(block_handler)),
1867 argc, argv, kw_splat, VM_BLOCK_HANDLER_NONE);
1869 return ret;
1870 }
1871
1872 new_captured.self = self;
1873 ep = captured->ep;
1874
1875 VM_FORCE_WRITE_SPECIAL_CONST(&VM_CF_LEP(ec->cfp)[VM_ENV_DATA_INDEX_SPECVAL], new_block_handler);
1876 }
1877
1878 cref = vm_cref_push(ec, under, ep, TRUE);
1879 ret = vm_yield_with_cref(ec, argc, argv, kw_splat, cref, is_lambda);
1881 return ret;
1882}
1883
1884VALUE
1885rb_yield_refine_block(VALUE refinement, VALUE refinements)
1886{
1888 VALUE block_handler = VM_CF_BLOCK_HANDLER(ec->cfp);
1889
1890 if (vm_block_handler_type(block_handler) != block_handler_type_iseq) {
1891 rb_bug("rb_yield_refine_block: an iseq block is required");
1892 }
1893 else {
1894 const struct rb_captured_block *captured = VM_BH_TO_ISEQ_BLOCK(block_handler);
1895 struct rb_captured_block new_captured = *captured;
1896 VALUE new_block_handler = VM_BH_FROM_ISEQ_BLOCK(&new_captured);
1897 const VALUE *ep = captured->ep;
1898 rb_cref_t *cref = vm_cref_push(ec, refinement, ep, TRUE);
1899 CREF_REFINEMENTS_SET(cref, refinements);
1900 VM_FORCE_WRITE_SPECIAL_CONST(&VM_CF_LEP(ec->cfp)[VM_ENV_DATA_INDEX_SPECVAL], new_block_handler);
1901 new_captured.self = refinement;
1902 return vm_yield_with_cref(ec, 0, NULL, RB_NO_KEYWORDS, cref, FALSE);
1903 }
1904}
1905
1906/* string eval under the class/module context */
1907static VALUE
1908eval_under(VALUE under, VALUE self, VALUE src, VALUE file, int line)
1909{
1910 rb_cref_t *cref = vm_cref_push(GET_EC(), under, NULL, SPECIAL_CONST_P(self) && !NIL_P(under));
1912 return eval_string_with_cref(self, src, cref, file, line);
1913}
1914
1915static VALUE
1916specific_eval(int argc, const VALUE *argv, VALUE klass, VALUE self, int kw_splat)
1917{
1918 if (rb_block_given_p()) {
1919 rb_check_arity(argc, 0, 0);
1920 return yield_under(klass, self, 1, &self, kw_splat);
1921 }
1922 else {
1923 VALUE file = Qundef;
1924 int line = 1;
1925 VALUE code;
1926
1927 rb_check_arity(argc, 1, 3);
1928 code = argv[0];
1930 if (argc > 2)
1931 line = NUM2INT(argv[2]);
1932 if (argc > 1) {
1933 file = argv[1];
1934 if (!NIL_P(file)) StringValue(file);
1935 }
1936 return eval_under(klass, self, code, file, line);
1937 }
1938}
1939
1940static VALUE
1941singleton_class_for_eval(VALUE self)
1942{
1943 if (SPECIAL_CONST_P(self)) {
1944 return rb_special_singleton_class(self);
1945 }
1946 switch (BUILTIN_TYPE(self)) {
1947 case T_FLOAT: case T_BIGNUM: case T_SYMBOL:
1948 return Qnil;
1949 case T_STRING:
1950 if (FL_TEST_RAW(self, RSTRING_FSTR)) return Qnil;
1951 default:
1952 return rb_singleton_class(self);
1953 }
1954}
1955
1956/*
1957 * call-seq:
1958 * obj.instance_eval(string [, filename [, lineno]] ) -> obj
1959 * obj.instance_eval {|obj| block } -> obj
1960 *
1961 * Evaluates a string containing Ruby source code, or the given block,
1962 * within the context of the receiver (_obj_). In order to set the
1963 * context, the variable +self+ is set to _obj_ while
1964 * the code is executing, giving the code access to _obj_'s
1965 * instance variables and private methods.
1966 *
1967 * When <code>instance_eval</code> is given a block, _obj_ is also
1968 * passed in as the block's only argument.
1969 *
1970 * When <code>instance_eval</code> is given a +String+, the optional
1971 * second and third parameters supply a filename and starting line number
1972 * that are used when reporting compilation errors.
1973 *
1974 * class KlassWithSecret
1975 * def initialize
1976 * @secret = 99
1977 * end
1978 * private
1979 * def the_secret
1980 * "Ssssh! The secret is #{@secret}."
1981 * end
1982 * end
1983 * k = KlassWithSecret.new
1984 * k.instance_eval { @secret } #=> 99
1985 * k.instance_eval { the_secret } #=> "Ssssh! The secret is 99."
1986 * k.instance_eval {|obj| obj == self } #=> true
1987 */
1988
1989static VALUE
1990rb_obj_instance_eval_internal(int argc, const VALUE *argv, VALUE self)
1991{
1992 VALUE klass = singleton_class_for_eval(self);
1993 return specific_eval(argc, argv, klass, self, RB_PASS_CALLED_KEYWORDS);
1994}
1995
1996VALUE
1998{
1999 VALUE klass = singleton_class_for_eval(self);
2000 return specific_eval(argc, argv, klass, self, RB_NO_KEYWORDS);
2001}
2002
2003/*
2004 * call-seq:
2005 * obj.instance_exec(arg...) {|var...| block } -> obj
2006 *
2007 * Executes the given block within the context of the receiver
2008 * (_obj_). In order to set the context, the variable +self+ is set
2009 * to _obj_ while the code is executing, giving the code access to
2010 * _obj_'s instance variables. Arguments are passed as block parameters.
2011 *
2012 * class KlassWithSecret
2013 * def initialize
2014 * @secret = 99
2015 * end
2016 * end
2017 * k = KlassWithSecret.new
2018 * k.instance_exec(5) {|x| @secret+x } #=> 104
2019 */
2020
2021static VALUE
2022rb_obj_instance_exec_internal(int argc, const VALUE *argv, VALUE self)
2023{
2024 VALUE klass = singleton_class_for_eval(self);
2025 return yield_under(klass, self, argc, argv, RB_PASS_CALLED_KEYWORDS);
2026}
2027
2028VALUE
2030{
2031 VALUE klass = singleton_class_for_eval(self);
2032 return yield_under(klass, self, argc, argv, RB_NO_KEYWORDS);
2033}
2034
2035/*
2036 * call-seq:
2037 * mod.class_eval(string [, filename [, lineno]]) -> obj
2038 * mod.class_eval {|mod| block } -> obj
2039 * mod.module_eval(string [, filename [, lineno]]) -> obj
2040 * mod.module_eval {|mod| block } -> obj
2041 *
2042 * Evaluates the string or block in the context of _mod_, except that when
2043 * a block is given, constant/class variable lookup is not affected. This
2044 * can be used to add methods to a class. <code>module_eval</code> returns
2045 * the result of evaluating its argument. The optional _filename_ and
2046 * _lineno_ parameters set the text for error messages.
2047 *
2048 * class Thing
2049 * end
2050 * a = %q{def hello() "Hello there!" end}
2051 * Thing.module_eval(a)
2052 * puts Thing.new.hello()
2053 * Thing.module_eval("invalid code", "dummy", 123)
2054 *
2055 * <em>produces:</em>
2056 *
2057 * Hello there!
2058 * dummy:123:in `module_eval': undefined local variable
2059 * or method `code' for Thing:Class
2060 */
2061
2062static VALUE
2063rb_mod_module_eval_internal(int argc, const VALUE *argv, VALUE mod)
2064{
2065 return specific_eval(argc, argv, mod, mod, RB_PASS_CALLED_KEYWORDS);
2066}
2067
2068VALUE
2070{
2071 return specific_eval(argc, argv, mod, mod, RB_NO_KEYWORDS);
2072}
2073
2074/*
2075 * call-seq:
2076 * mod.module_exec(arg...) {|var...| block } -> obj
2077 * mod.class_exec(arg...) {|var...| block } -> obj
2078 *
2079 * Evaluates the given block in the context of the class/module.
2080 * The method defined in the block will belong to the receiver.
2081 * Any arguments passed to the method will be passed to the block.
2082 * This can be used if the block needs to access instance variables.
2083 *
2084 * class Thing
2085 * end
2086 * Thing.class_exec{
2087 * def hello() "Hello there!" end
2088 * }
2089 * puts Thing.new.hello()
2090 *
2091 * <em>produces:</em>
2092 *
2093 * Hello there!
2094 */
2095
2096static VALUE
2097rb_mod_module_exec_internal(int argc, const VALUE *argv, VALUE mod)
2098{
2099 return yield_under(mod, mod, argc, argv, RB_PASS_CALLED_KEYWORDS);
2100}
2101
2102VALUE
2104{
2105 return yield_under(mod, mod, argc, argv, RB_NO_KEYWORDS);
2106}
2107
2108/*
2109 * Document-class: UncaughtThrowError
2110 *
2111 * Raised when +throw+ is called with a _tag_ which does not have
2112 * corresponding +catch+ block.
2113 *
2114 * throw "foo", "bar"
2115 *
2116 * <em>raises the exception:</em>
2117 *
2118 * UncaughtThrowError: uncaught throw "foo"
2119 */
2120
2121static VALUE
2122uncaught_throw_init(int argc, const VALUE *argv, VALUE exc)
2123{
2125 rb_call_super(argc - 2, argv + 2);
2126 rb_ivar_set(exc, id_tag, argv[0]);
2127 rb_ivar_set(exc, id_value, argv[1]);
2128 return exc;
2129}
2130
2131/*
2132 * call-seq:
2133 * uncaught_throw.tag -> obj
2134 *
2135 * Return the tag object which was called for.
2136 */
2137
2138static VALUE
2139uncaught_throw_tag(VALUE exc)
2140{
2141 return rb_ivar_get(exc, id_tag);
2142}
2143
2144/*
2145 * call-seq:
2146 * uncaught_throw.value -> obj
2147 *
2148 * Return the return value which was called for.
2149 */
2150
2151static VALUE
2152uncaught_throw_value(VALUE exc)
2153{
2154 return rb_ivar_get(exc, id_value);
2155}
2156
2157/*
2158 * call-seq:
2159 * uncaught_throw.to_s -> string
2160 *
2161 * Returns formatted message with the inspected tag.
2162 */
2163
2164static VALUE
2165uncaught_throw_to_s(VALUE exc)
2166{
2167 VALUE mesg = rb_attr_get(exc, id_mesg);
2168 VALUE tag = uncaught_throw_tag(exc);
2169 return rb_str_format(1, &tag, mesg);
2170}
2171
2172/*
2173 * call-seq:
2174 * throw(tag [, obj])
2175 *
2176 * Transfers control to the end of the active +catch+ block
2177 * waiting for _tag_. Raises +UncaughtThrowError+ if there
2178 * is no +catch+ block for the _tag_. The optional second
2179 * parameter supplies a return value for the +catch+ block,
2180 * which otherwise defaults to +nil+. For examples, see
2181 * Kernel::catch.
2182 */
2183
2184static VALUE
2185rb_f_throw(int argc, VALUE *argv, VALUE _)
2186{
2187 VALUE tag, value;
2188
2189 rb_scan_args(argc, argv, "11", &tag, &value);
2190 rb_throw_obj(tag, value);
2192}
2193
2194void
2196{
2198 struct rb_vm_tag *tt = ec->tag;
2199
2200 while (tt) {
2201 if (tt->tag == tag) {
2202 tt->retval = value;
2203 break;
2204 }
2205 tt = tt->prev;
2206 }
2207 if (!tt) {
2208 VALUE desc[3];
2209 desc[0] = tag;
2210 desc[1] = value;
2211 desc[2] = rb_str_new_cstr("uncaught throw %p");
2212 rb_exc_raise(rb_class_new_instance(numberof(desc), desc, rb_eUncaughtThrow));
2213 }
2214
2215 ec->errinfo = (VALUE)THROW_DATA_NEW(tag, NULL, TAG_THROW);
2217}
2218
2219void
2220rb_throw(const char *tag, VALUE val)
2221{
2223}
2224
2225static VALUE
2227{
2228 return rb_yield_0(1, &tag);
2229}
2230
2231/*
2232 * call-seq:
2233 * catch([tag]) {|tag| block } -> obj
2234 *
2235 * +catch+ executes its block. If +throw+ is not called, the block executes
2236 * normally, and +catch+ returns the value of the last expression evaluated.
2237 *
2238 * catch(1) { 123 } # => 123
2239 *
2240 * If <code>throw(tag2, val)</code> is called, Ruby searches up its stack for
2241 * a +catch+ block whose +tag+ has the same +object_id+ as _tag2_. When found,
2242 * the block stops executing and returns _val_ (or +nil+ if no second argument
2243 * was given to +throw+).
2244 *
2245 * catch(1) { throw(1, 456) } # => 456
2246 * catch(1) { throw(1) } # => nil
2247 *
2248 * When +tag+ is passed as the first argument, +catch+ yields it as the
2249 * parameter of the block.
2250 *
2251 * catch(1) {|x| x + 2 } # => 3
2252 *
2253 * When no +tag+ is given, +catch+ yields a new unique object (as from
2254 * +Object.new+) as the block parameter. This object can then be used as the
2255 * argument to +throw+, and will match the correct +catch+ block.
2256 *
2257 * catch do |obj_A|
2258 * catch do |obj_B|
2259 * throw(obj_B, 123)
2260 * puts "This puts is not reached"
2261 * end
2262 *
2263 * puts "This puts is displayed"
2264 * 456
2265 * end
2266 *
2267 * # => 456
2268 *
2269 * catch do |obj_A|
2270 * catch do |obj_B|
2271 * throw(obj_A, 123)
2272 * puts "This puts is still not reached"
2273 * end
2274 *
2275 * puts "Now this puts is also not reached"
2276 * 456
2277 * end
2278 *
2279 * # => 123
2280 */
2281
2282static VALUE
2283rb_f_catch(int argc, VALUE *argv, VALUE self)
2284{
2286 return rb_catch_obj(tag, catch_i, 0);
2287}
2288
2289VALUE
2290rb_catch(const char *tag, rb_block_call_func_t func, VALUE data)
2291{
2293 return rb_catch_obj(vtag, func, data);
2294}
2295
2296static VALUE
2297vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
2298 enum ruby_tag_type *stateptr, rb_execution_context_t *volatile ec)
2299{
2300 enum ruby_tag_type state;
2301 VALUE val = Qnil; /* OK */
2302 rb_control_frame_t *volatile saved_cfp = ec->cfp;
2303
2304 EC_PUSH_TAG(ec);
2305
2306 _tag.tag = tag;
2307
2308 if ((state = EC_EXEC_TAG()) == TAG_NONE) {
2309 /* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
2310 val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
2311 }
2312 else if (state == TAG_THROW && THROW_DATA_VAL((struct vm_throw_data *)ec->errinfo) == tag) {
2313 rb_vm_rewind_cfp(ec, saved_cfp);
2314 val = ec->tag->retval;
2315 ec->errinfo = Qnil;
2316 state = 0;
2317 }
2318 EC_POP_TAG();
2319 if (stateptr)
2320 *stateptr = state;
2321
2322 return val;
2323}
2324
2325VALUE
2327{
2328 return vm_catch_protect(t, func, data, stateptr, GET_EC());
2329}
2330
2331VALUE
2333{
2334 enum ruby_tag_type state;
2336 VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, ec);
2337 if (state) EC_JUMP_TAG(ec, state);
2338 return val;
2339}
2340
2341static void
2342local_var_list_init(struct local_var_list *vars)
2343{
2344 vars->tbl = rb_ident_hash_new();
2346}
2347
2348static VALUE
2349local_var_list_finish(struct local_var_list *vars)
2350{
2351 /* TODO: not to depend on the order of st_table */
2352 VALUE ary = rb_hash_keys(vars->tbl);
2353 rb_hash_clear(vars->tbl);
2354 vars->tbl = 0;
2355 return ary;
2356}
2357
2358static int
2359local_var_list_update(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
2360{
2361 if (existing) return ST_STOP;
2362 *value = (st_data_t)Qtrue; /* INT2FIX(arg) */
2363 return ST_CONTINUE;
2364}
2365
2366static void
2367local_var_list_add(const struct local_var_list *vars, ID lid)
2368{
2369 if (lid && rb_is_local_id(lid)) {
2370 /* should skip temporary variable */
2371 st_data_t idx = 0; /* tbl->num_entries */
2372 rb_hash_stlike_update(vars->tbl, ID2SYM(lid), local_var_list_update, idx);
2373 }
2374}
2375
2376/*
2377 * call-seq:
2378 * local_variables -> array
2379 *
2380 * Returns the names of the current local variables.
2381 *
2382 * fred = 1
2383 * for i in 1..10
2384 * # ...
2385 * end
2386 * local_variables #=> [:fred, :i]
2387 */
2388
2389static VALUE
2390rb_f_local_variables(VALUE _)
2391{
2392 struct local_var_list vars;
2394 rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp));
2395 unsigned int i;
2396
2397 local_var_list_init(&vars);
2398 while (cfp) {
2399 if (cfp->iseq) {
2400 for (i = 0; i < cfp->iseq->body->local_table_size; i++) {
2401 local_var_list_add(&vars, cfp->iseq->body->local_table[i]);
2402 }
2403 }
2404 if (!VM_ENV_LOCAL_P(cfp->ep)) {
2405 /* block */
2406 const VALUE *ep = VM_CF_PREV_EP(cfp);
2407
2408 if (vm_collect_local_variables_in_heap(ep, &vars)) {
2409 break;
2410 }
2411 else {
2412 while (cfp->ep != ep) {
2414 }
2415 }
2416 }
2417 else {
2418 break;
2419 }
2420 }
2421 return local_var_list_finish(&vars);
2422}
2423
2424/*
2425 * call-seq:
2426 * block_given? -> true or false
2427 * iterator? -> true or false
2428 *
2429 * Returns <code>true</code> if <code>yield</code> would execute a
2430 * block in the current context. The <code>iterator?</code> form
2431 * is mildly deprecated.
2432 *
2433 * def try
2434 * if block_given?
2435 * yield
2436 * else
2437 * "no block"
2438 * end
2439 * end
2440 * try #=> "no block"
2441 * try { "hello" } #=> "hello"
2442 * try do "hello" end #=> "hello"
2443 */
2444
2445
2446static VALUE
2447rb_f_block_given_p(VALUE _)
2448{
2450 rb_control_frame_t *cfp = ec->cfp;
2451 cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
2452
2453 if (cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE) {
2454 return Qtrue;
2455 }
2456 else {
2457 return Qfalse;
2458 }
2459}
2460
2461VALUE
2463{
2464 const rb_execution_context_t *ec = GET_EC();
2465 rb_control_frame_t *cfp = ec->cfp;
2466 cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
2467 if (cfp != 0) return rb_iseq_realpath(cfp->iseq);
2468 return Qnil;
2469}
2470
2471void
2473{
2475 rb_define_global_function("local_variables", rb_f_local_variables, 0);
2476 rb_define_global_function("iterator?", rb_f_block_given_p, 0);
2477 rb_define_global_function("block_given?", rb_f_block_given_p, 0);
2478
2479 rb_define_global_function("catch", rb_f_catch, -1);
2480 rb_define_global_function("throw", rb_f_throw, -1);
2481
2482 rb_define_global_function("loop", rb_f_loop, 0);
2483
2484 rb_define_method(rb_cBasicObject, "instance_eval", rb_obj_instance_eval_internal, -1);
2485 rb_define_method(rb_cBasicObject, "instance_exec", rb_obj_instance_exec_internal, -1);
2486 rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);
2487
2488#if 1
2493#else
2494 rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
2496#endif
2497 rb_define_method(rb_mKernel, "public_send", rb_f_public_send, -1);
2498
2499 rb_define_method(rb_cModule, "module_exec", rb_mod_module_exec_internal, -1);
2500 rb_define_method(rb_cModule, "class_exec", rb_mod_module_exec_internal, -1);
2501 rb_define_method(rb_cModule, "module_eval", rb_mod_module_eval_internal, -1);
2502 rb_define_method(rb_cModule, "class_eval", rb_mod_module_eval_internal, -1);
2503
2504 rb_eUncaughtThrow = rb_define_class("UncaughtThrowError", rb_eArgError);
2505 rb_define_method(rb_eUncaughtThrow, "initialize", uncaught_throw_init, -1);
2506 rb_define_method(rb_eUncaughtThrow, "tag", uncaught_throw_tag, 0);
2507 rb_define_method(rb_eUncaughtThrow, "value", uncaught_throw_value, 0);
2508 rb_define_method(rb_eUncaughtThrow, "to_s", uncaught_throw_to_s, 0);
2509
2510 id_result = rb_intern_const("result");
2511 id_tag = rb_intern_const("tag");
2512 id_value = rb_intern_const("value");
2513}
2514
2515#endif /* #ifndef MJIT_HEADER */
#define rb_ary_subseq(ary, beg, len)
Definition: cparse.c:76
#define mod(x, y)
Definition: date_strftime.c:28
struct RIMemo * ptr
Definition: debug.c:65
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
void rb_extend_object(VALUE, VALUE)
Extend the object with the module.
Definition: eval.c:1701
VALUE rb_define_class(const char *, VALUE)
Defines a top-level class.
Definition: class.c:662
VALUE rb_singleton_class(VALUE)
Returns the singleton class of obj.
Definition: class.c:1743
VALUE rb_module_new(void)
Definition: class.c:771
VALUE rb_special_singleton_class(VALUE)
Definition: class.c:1639
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition: eval.c:898
VALUE rb_call_super_kw(int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:298
VALUE rb_eval_string(const char *str)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1715
VALUE rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv)
Calls a method.
Definition: vm_eval.c:956
VALUE rb_mKernel
Kernel module.
Definition: ruby.h:2000
VALUE rb_eStopIteration
Definition: enumerator.c:124
VALUE rb_funcallv_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:962
VALUE rb_block_call_kw(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2, int kw_splat)
Definition: vm_eval.c:1484
VALUE rb_cBasicObject
BasicObject class.
Definition: ruby.h:2011
VALUE rb_cObject
Object class.
Definition: ruby.h:2012
VALUE rb_current_receiver(void)
Definition: vm_eval.c:314
VALUE rb_funcall(VALUE recv, ID mid, int n,...)
Calls a method.
Definition: vm_eval.c:922
VALUE rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval)
Definition: vm_eval.c:1050
VALUE rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE *argv)
Definition: vm_eval.c:1032
VALUE rb_catch(const char *tag, rb_block_call_func_t func, VALUE data)
Definition: vm_eval.c:2290
VALUE rb_iterate(VALUE(*it_proc)(VALUE), VALUE data1, rb_block_call_func_t bl_proc, VALUE data2)
Definition: vm_eval.c:1444
VALUE rb_yield_values(int n,...)
Definition: vm_eval.c:1249
VALUE rb_yield_values2(int argc, const VALUE *argv)
Definition: vm_eval.c:1271
VALUE rb_yield_values_kw(int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:1277
VALUE rb_funcallv_public_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:986
VALUE rb_funcall_passing_block_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:1039
VALUE rb_funcall_with_block_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval, int kw_splat)
Definition: vm_eval.c:1060
VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
Definition: ruby.h:1968
VALUE rb_eval_string_wrap(const char *str, int *pstate)
Evaluates the given string under a module binding in an isolated binding.
Definition: vm_eval.c:1769
VALUE rb_each(VALUE obj)
Definition: vm_eval.c:1542
VALUE rb_yield_splat(VALUE values)
Definition: vm_eval.c:1283
VALUE rb_yield_splat_kw(VALUE values, int kw_splat)
Definition: vm_eval.c:1296
@ RSTRING_FSTR
Definition: ruby.h:983
VALUE rb_cModule
Module class.
Definition: ruby.h:2036
VALUE rb_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2)
Definition: vm_eval.c:1470
VALUE rb_eval_string_protect(const char *str, int *pstate)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1737
VALUE rb_yield(VALUE val)
Definition: vm_eval.c:1237
VALUE rb_catch_obj(VALUE t, rb_block_call_func_t func, VALUE data)
Definition: vm_eval.c:2332
VALUE rb_funcallv_public(VALUE recv, ID mid, int argc, const VALUE *argv)
Calls a method.
Definition: vm_eval.c:980
VALUE rb_call_super(int argc, const VALUE *argv)
Definition: vm_eval.c:306
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2671
VALUE rb_rescue2(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE,...)
An equivalent of rescue clause.
Definition: eval.c:962
VALUE rb_eNotImpError
Definition: error.c:934
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
Definition: eval.c:668
void rb_bug(const char *fmt,...)
Definition: error.c:636
VALUE rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv)
Definition: error.c:1675
VALUE rb_protect(VALUE(*)(VALUE), VALUE, int *)
Protects a function call from potential global escapes from the function.
Definition: eval.c:1072
VALUE rb_eNameError
Definition: error.c:929
VALUE rb_eNoMethodError
Definition: error.c:932
VALUE rb_eRuntimeError
Definition: error.c:922
VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method)
Definition: error.c:1594
void rb_warn(const char *fmt,...)
Definition: error.c:315
VALUE rb_eArgError
Definition: error.c:925
VALUE rb_obj_alloc(VALUE)
Allocates an instance of klass.
Definition: object.c:1895
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
Allocates and initializes an instance of klass.
Definition: object.c:1955
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
Definition: object.c:217
VALUE rb_obj_clone(VALUE)
Almost same as Object::clone.
Definition: object.c:410
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Determines if obj is a kind of c.
Definition: object.c:692
MJIT_STATIC void rb_vm_pop_cfunc_frame(void)
Definition: vm.c:590
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
const char * name
Definition: nkf.c:208
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4322
rb_cref_t * rb_vm_cref_new_toplevel(void)
Definition: vm.c:298
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
#define SafeStringValue(v)
#define rb_str_new2
void rb_ast_dispose(rb_ast_t *)
Definition: node.c:1387
#define MEMCPY(p1, p2, type, n)
#define T_COMPLEX
#define NULL
#define RUBY_EVENT_C_CALL
#define RBASIC_CLEAR_CLASS(obj)
#define T_FILE
#define UNLIMITED_ARGUMENTS
use StringValue() instead")))
#define _(args)
#define RTEST(v)
#define rb_ec_raised_p(ec, f)
#define ALLOCV_END(v)
#define ALLOCA_N(type, n)
#define TAG_NONE
#define CHECK_CFP_CONSISTENCY(func)
VALUE rb_parser_new(void)
Definition: ripper.c:20026
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
#define RBASIC(obj)
int rb_empty_keyword_given_p(void)
Definition: eval.c:919
VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int)
Definition: ripper.c:20036
static const VALUE int int int int int int VALUE * vars[]
const rb_callable_method_entry_t * rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class)
Definition: vm_method.c:934
void rb_define_private_method(VALUE, const char *, VALUE(*)(), int)
#define T_STRING
const rb_iseq_t const int const int min_argc
#define StringValuePtr(v)
#define TAG_RETRY
#define RARRAY_LENINT(ary)
rb_control_frame_t * cfp
void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi)
Definition: vm_method.c:675
void rb_define_global_function(const char *, VALUE(*)(), int)
#define T_MASK
#define Qundef
#define rb_ec_raised_set(ec, f)
VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc)
Definition: string.c:10816
const rb_data_type_t ruby_binding_data_type
Definition: proc.c:319
void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE)
#define UNALIGNED_MEMBER_PTR(ptr, mem)
char * realpath(const char *__restrict__ path, char *__restrict__ resolved_path)
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1070
rb_iseq_t * rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t *)
Definition: iseq.c:807
const VALUE VALUE obj
#define va_init_list(a, b)
#define T_NIL
#define T_FLOAT
#define T_IMEMO
#define T_BIGNUM
int int int printf(const char *__restrict__,...) __attribute__((__format__(__printf__
#define GET_EC()
VALUE rb_ident_hash_new(void)
Definition: hash.c:4278
#define NIL_P(v)
#define T_STRUCT
VALUE rb_str_format(int, const VALUE *, VALUE)
Definition: sprintf.c:204
const rb_callable_method_entry_t * me
#define numberof(array)
#define DBL2NUM(dbl)
#define VM_ASSERT(expr)
#define ID2SYM(x)
#define EC_EXEC_TAG()
@ block_handler_type_ifunc
@ block_handler_type_proc
@ block_handler_type_symbol
@ block_handler_type_iseq
#define T_FIXNUM
int const VALUE VALUE int call_status
int fprintf(FILE *__restrict__, const char *__restrict__,...) __attribute__((__format__(__printf__
const char size_t n
#define T_DATA
#define rb_intern_const(str)
#define SYM2ID(x)
const char const char *typedef unsigned long VALUE
#define stderr
#define T_NONE
#define T_NODE
#define rb_ary_new4
#define EC_PUSH_TAG(ec)
__inline__ const void *__restrict__ src
#define EC_JUMP_TAG(ec, st)
rb_control_frame_t struct rb_calling_info const struct rb_call_info * ci
rb_control_frame_t * reg_cfp
#define rb_sym_intern_ascii_cstr(ptr)
#define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, klass, id)
#define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_)
@ METHOD_VISI_PROTECTED
int rb_ec_stack_check(rb_execution_context_t *ec)
Definition: gc.c:4681
#define T_MODULE
#define TAG_THROW
uint32_t i
#define rb_fstring_lit(str)
const rb_callable_method_entry_t * rb_callable_method_entry(VALUE klass, ID id)
Definition: vm_method.c:895
VALUE rb_fstring(VALUE)
Definition: string.c:312
@ RAISED_STACKOVERFLOW
__inline__ const void *__restrict__ size_t len
#define FL_TEST_RAW(x, f)
#define OBJ_FREEZE(x)
#define RUBY_VM_CHECK_INTS(ec)
#define T_TRUE
#define T_RATIONAL
#define va_end(v)
#define T_ICLASS
#define T_HASH
#define RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, klass, id)
__gnuc_va_list va_list
#define NUM2INT(x)
@ VM_METHOD_TYPE_ATTRSET
@ VM_METHOD_TYPE_CFUNC
@ VM_METHOD_TYPE_OPTIMIZED
@ VM_METHOD_TYPE_REFINED
@ VM_METHOD_TYPE_NOTIMPLEMENTED
@ VM_METHOD_TYPE_MISSING
@ VM_METHOD_TYPE_BMETHOD
@ VM_METHOD_TYPE_ZSUPER
@ VM_METHOD_TYPE_ALIAS
@ VM_METHOD_TYPE_UNDEF
#define RB_GC_GUARD(v)
#define GET_THREAD()
@ OPTIMIZED_METHOD_TYPE_CALL
@ OPTIMIZED_METHOD_TYPE_SEND
#define PRIsVALUE
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
#define RCLASS_ORIGIN(c)
int VALUE v
#define rb_method_basic_definition_p(klass, mid)
#define rb_scan_args(argc, argvp, fmt,...)
#define RB_PASS_EMPTY_KEYWORDS
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 EC_POP_TAG()
VALUE rb_proc_lambda_p(VALUE)
Definition: proc.c:275
#define T_FALSE
#define va_arg(v, l)
rb_control_frame_t struct rb_calling_info * calling
#define PASS_PASSED_BLOCK_HANDLER()
#define UNREACHABLE_RETURN(val)
#define CHECK_VM_STACK_OVERFLOW(cfp, margin)
#define PRIxVALUE
#define ALLOCV_N(type, v, n)
const rb_iseq_t * iseq
#define T_UNDEF
#define TAG_BREAK
#define RARRAY_CONST_PTR_TRANSIENT(a)
#define TRUE
#define RUBY_EVENT_C_RETURN
#define FALSE
#define UNDEFINED_METHOD_ENTRY_P(me)
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
rb_block_call_func * rb_block_call_func_t
const rb_iseq_t const int const int const int max_argc
void rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp)
Definition: vm.c:604
#define UNLIKELY(x)
#define RB_NO_KEYWORDS
const struct rb_call_cache * cc
VALUE rb_vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, int argc, const VALUE *argv, int kw_splat, VALUE block_handler)
Definition: vm.c:1249
#define T_ZOMBIE
#define vm_check_canary(ec, sp)
VALUE rb_attr_get(VALUE, ID)
Definition: variable.c:1084
#define Qnil
#define Qfalse
#define T_ARRAY
void * memcpy(void *__restrict__, const void *__restrict__, size_t)
struct vm_ifunc * rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc)
Definition: proc.c:699
#define T_OBJECT
VALUE rb_str_intern(VALUE)
Definition: symbol.c:710
VALUE rb_source_location(int *pline)
Definition: vm.c:1360
#define SDR()
ID rb_check_id(volatile VALUE *)
Returns ID for the given name if it is interned already, or 0.
Definition: symbol.c:919
#define RB_TYPE_P(obj, type)
#define INT2FIX(i)
#define SPECIAL_CONST_P(x)
VALUE rb_check_array_type(VALUE)
Definition: array.c:909
#define T_SYMBOL
#define MJIT_FUNC_EXPORTED
const VALUE * argv
#define VM_BLOCK_HANDLER_NONE
#define T_MATCH
#define SYMBOL_P(x)
VALUE rb_ivar_set(VALUE, ID, VALUE)
Definition: variable.c:1300
#define VM_ENV_DATA_INDEX_SPECVAL
int rb_method_boundp(VALUE, ID, int)
Definition: vm_method.c:1119
VALUE rb_iseq_disasm(const rb_iseq_t *iseq)
Definition: iseq.c:2278
#define T_CLASS
#define CLASS_OF(v)
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func func, st_data_t arg)
Definition: hash.c:1651
#define T_MOVED
#define Check_TypedStruct(v, t)
#define rb_check_arity
#define GetProcPtr(obj, ptr)
@ VM_FRAME_FLAG_CFRAME_KW
@ VM_FRAME_FLAG_CFRAME
@ VM_FRAME_MAGIC_CFUNC
@ VM_FRAME_FLAG_FINISH
@ VM_FRAME_FLAG_CFRAME_EMPTY_KW
#define VM_CALL_KW_SPLAT
unsigned long ID
#define RHASH_EMPTY_P(h)
int rb_keyword_given_p(void)
Definition: eval.c:911
rb_ast_t * rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line)
Definition: ripper.c:13740
VALUE ID id
VALUE rb_hash_clear(VALUE)
Definition: hash.c:2769
const rb_iseq_t const VALUE exc
void rb_define_method(VALUE, const char *, VALUE(*)(), int)
#define BUILTIN_TYPE(x)
VALUE rb_iseq_realpath(const rb_iseq_t *iseq)
Definition: iseq.c:1033
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
VALUE rb_hash_new(void)
Definition: hash.c:1523
#define HUGE_VAL
#define rb_str_new_cstr(str)
#define RARRAY_CONST_PTR(a)
#define PASS_PASSED_BLOCK_HANDLER_EC(ec)
#define METHOD_ENTRY_BASIC(me)
#define T_REGEXP
#define METHOD_ENTRY_VISI(me)
#define LIKELY(x)
unsigned long VALUE
Definition: ruby.h:102
const char * str
Definition: vm_eval.c:1745
const VALUE * argv
Definition: vm_eval.c:1456
unsigned short first_lineno
const struct rb_block block
const struct rb_callable_method_entry_struct * me
struct rb_call_info ci
struct rb_call_cache cc
struct rb_method_definition_struct *const def
const VALUE defined_class
const VALUE owner
const struct vm_ifunc * ifunc
union rb_captured_block::@53 code
CREF (Class REFerence)
enum method_missing_reason method_missing_reason
struct rb_iseq_constant_body * body
VALUE(* invoker)(VALUE recv, int argc, const VALUE *argv, VALUE(*func)())
enum method_optimized_type optimize_type
union rb_method_definition_struct::@41 body
struct rb_method_entry_struct * orig_me
rb_execution_context_t * ec
struct rb_vm_tag * prev
enum ruby_tag_type state
unsigned int respond_to_missing
Definition: vm_eval.c:402
const VALUE * argv
Definition: vm_eval.c:404
rb_execution_context_t * ec
Definition: vm_eval.c:399
unsigned int respond
Definition: vm_eval.c:401
const rb_method_entry_t * me
Definition: vm_eval.c:400
IFUNC (Internal FUNCtion)
int rb_is_local_id(ID id)
Definition: symbol.c:884
VALUE rb_vm_top_self(void)
Definition: vm.c:3349
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 const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv)
Definition: vm_eval.c:1188
VALUE rb_eval_cmd(VALUE cmd, VALUE arg, int _level)
Definition: vm_eval.c:1824
call_type
Definition: vm_eval.c:31
@ CALL_PUBLIC
Definition: vm_eval.c:32
@ CALL_PUBLIC_KW
Definition: vm_eval.c:35
@ CALL_FCALL
Definition: vm_eval.c:33
@ CALL_VCALL
Definition: vm_eval.c:34
@ CALL_FCALL_KW
Definition: vm_eval.c:36
@ CALL_TYPE_MAX
Definition: vm_eval.c:37
VALUE rb_yield_1(VALUE val)
Definition: vm_eval.c:1231
MJIT_FUNC_EXPORTED VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv, int priv)
Definition: vm_eval.c:772
void Init_vm_eval(void)
Definition: vm_eval.c:2472
VALUE vm_exec(rb_execution_context_t *ec, int mjit_enable_p)
Definition: vm.c:1909
#define id_mesg
Definition: vm_eval.c:29
MJIT_FUNC_EXPORTED VALUE rb_vm_call_kw(rb_execution_context_t *ec, VALUE recv, VALUE id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat)
Definition: vm_eval.c:265
#define type_case(t)
NORETURN(static void uncallable_object(VALUE recv, ID mid))
const char * rb_type_str(enum ruby_value_type type)
Definition: vm_eval.c:572
VALUE rb_obj_instance_exec(int argc, const VALUE *argv, VALUE self)
Definition: vm_eval.c:2029
VALUE rb_check_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2)
Definition: vm_eval.c:1528
VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv)
Definition: vm_eval.c:505
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
Definition: vm_eval.c:1885
VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self)
Definition: vm_eval.c:1670
VALUE rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:499
VALUE rb_check_funcall_default(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def)
Definition: vm_eval.c:533
void rb_throw(const char *tag, VALUE val)
Definition: vm_eval.c:2220
VALUE rb_yield_force_blockarg(VALUE values)
Definition: vm_eval.c:1309
VALUE rb_check_funcall_with_hook_kw(VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg, int kw_splat)
Definition: vm_eval.c:539
VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr)
Definition: vm_eval.c:2326
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg)
Definition: vm_eval.c:565
VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, int min_argc, int max_argc, VALUE data2)
Definition: vm_eval.c:1501
VALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod)
Definition: vm_eval.c:2069
MJIT_FUNC_EXPORTED VALUE rb_adjust_argv_kw_splat(int *argc, const VALUE **argv, int *kw_splat)
Definition: vm_eval.c:237
VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(val, arg))
Definition: vm_eval.c:1315
VALUE rb_mod_module_exec(int argc, const VALUE *argv, VALUE mod)
Definition: vm_eval.c:2103
VALUE ruby_eval_string_from_file(const char *str, const char *filename)
Definition: vm_eval.c:1696
VALUE rb_obj_instance_eval(int argc, const VALUE *argv, VALUE self)
Definition: vm_eval.c:1997
MJIT_FUNC_EXPORTED VALUE rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat)
Definition: vm_eval.c:46
VALUE rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat)
Definition: vm_eval.c:1801
void rb_parser_warn_location(VALUE, int)
Definition: ripper.c:19849
VALUE rb_apply(VALUE recv, ID mid, VALUE args)
Calls a method.
Definition: vm_eval.c:890
VALUE rb_current_realfilepath(void)
Definition: vm_eval.c:2462
void rb_throw_obj(VALUE tag, VALUE value)
Definition: vm_eval.c:2195
MJIT_STATIC void rb_ec_stack_overflow(rb_execution_context_t *ec, int crit)
Definition: vm_insnhelper.c:67
#define BOUND_PRIVATE
Definition: vm_method.c:1115
#define undefined
Definition: vm_method.c:36
#define BOUND_RESPONDS
Definition: vm_method.c:1116