Ruby  2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
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 
16 };
17 
18 static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status, int kw_splat);
19 static 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);
20 static inline VALUE vm_yield(rb_execution_context_t *ec, int argc, const VALUE *argv, int kw_splat);
21 static inline VALUE vm_yield_with_block(rb_execution_context_t *ec, int argc, const VALUE *argv, VALUE block_handler, int kw_splat);
22 static inline VALUE vm_yield_force_blockarg(rb_execution_context_t *ec, VALUE args);
23 VALUE vm_exec(rb_execution_context_t *ec, int mjit_enable_p);
24 static 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);
25 static int vm_collect_local_variables_in_heap(const VALUE *dfp, const struct local_var_list *vars);
26 
27 static VALUE rb_eUncaughtThrow;
28 static ID id_result, id_tag, id_value;
29 #define id_mesg idMesg
30 
31 typedef enum call_type {
39 
40 static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope);
41 static 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 
46 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)
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 
55 static VALUE
56 vm_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");
94  rb_vm_pop_frame(ec);
95  }
96  EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, recv, me->def->original_id, mid, me->owner, val);
98 
99  return val;
100 }
101 
102 static VALUE
103 vm_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) */
109 static VALUE
110 vm_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) {
121  case VM_METHOD_TYPE_ISEQ:
122  {
124  int i;
125 
127  vm_check_canary(ec, reg_cfp->sp);
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;
158  case VM_METHOD_TYPE_IVAR:
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 
178  if (type == VM_METHOD_TYPE_ZSUPER) {
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) {
190  RUBY_VM_CHECK_INTS(ec);
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:
231  RUBY_VM_CHECK_INTS(ec);
232  return ret;
233 }
234 
235 /* Caller should keep the reference to the return value until argv becomes useless. */
237 rb_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 
265 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)
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 
273 static inline VALUE
274 vm_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;
279  rb_control_frame_t *cfp = ec->cfp;
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 
297 VALUE
298 rb_call_super_kw(int argc, const VALUE *argv, int kw_splat)
299 {
302  return vm_call_super(ec, argc, argv, kw_splat);
303 }
304 
305 VALUE
307 {
310  return vm_call_super(ec, argc, argv, RB_NO_KEYWORDS);
311 }
312 
313 VALUE
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 
326 static inline void
327 stack_check(rb_execution_context_t *ec)
328 {
330  rb_ec_stack_check(ec)) {
333  }
334 }
335 
336 #ifndef MJIT_HEADER
337 
338 static inline const rb_callable_method_entry_t *rb_search_method_entry(VALUE recv, ID mid);
339 static 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 
357 static inline VALUE
358 rb_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;
405  int kw_splat;
406 };
407 
408 static VALUE
409 check_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 
417 static VALUE
418 check_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 
442 static int
443 check_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 
448 static int
449 check_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 
454 static VALUE
455 check_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 
496 static VALUE rb_check_funcall_default_kw(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def, int kw_splat);
497 
498 VALUE
500 {
501  return rb_check_funcall_default_kw(recv, mid, argc, argv, Qundef, kw_splat);
502 }
503 
504 VALUE
506 {
507  return rb_check_funcall_default_kw(recv, mid, argc, argv, Qundef, RB_NO_KEYWORDS);
508 }
509 
510 static VALUE
511 rb_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 
532 VALUE
534 {
535  return rb_check_funcall_default_kw(recv, mid, argc, argv, def, RB_NO_KEYWORDS);
536 }
537 
538 VALUE
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 
564 VALUE
567 {
569 }
570 
571 const 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 
609 NORETURN(static void uncallable_object(VALUE recv, ID mid));
610 static void
611 uncallable_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 
648 static inline const rb_callable_method_entry_t *
649 rb_search_method_entry(VALUE recv, ID mid)
650 {
652 
653  if (!klass) uncallable_object(recv, mid);
655 }
656 
657 static inline enum method_missing_reason
658 rb_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  }
668  if (me->def->type == VM_METHOD_TYPE_REFINED) {
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 
714 static inline VALUE
715 rb_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 
721 NORETURN(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 
763 static VALUE
764 rb_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 
791 static void
792 raise_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");
817  exc = rb_eNameError;
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  }
829  rb_exc_raise(exc);
830  }
831 }
832 
833 static void
834 vm_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 
841 static inline VALUE
842 method_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 
889 VALUE
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  }
904  argv = ALLOCA_N(VALUE, argc);
906  return rb_call(recv, mid, argc, argv, CALL_FCALL);
907 }
908 
909 #ifdef rb_funcall
910 #undef rb_funcall
911 #endif
912 
921 VALUE
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
948 
955 VALUE
957 {
958  return rb_call(recv, mid, argc, argv, CALL_FCALL);
959 }
960 
961 VALUE
963 {
965  VALUE ret = rb_call(recv, mid, argc, argv, kw_splat ? CALL_FCALL_KW : CALL_FCALL);
967  return ret;
968 }
969 
979 VALUE
981 {
982  return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
983 }
984 
985 VALUE
987 {
989  VALUE ret = rb_call(recv, mid, argc, argv, kw_splat ? CALL_PUBLIC_KW : CALL_PUBLIC);
991  return ret;
992 }
993 
1003 VALUE
1004 rb_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 
1012  if (LIKELY(! UNDEFINED_METHOD_ENTRY_P(cc->me))) {
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 
1031 VALUE
1033 {
1035  return rb_call(recv, mid, argc, argv, CALL_PUBLIC);
1036 }
1037 
1038 VALUE
1039 rb_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 
1049 VALUE
1050 rb_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 
1059 VALUE
1060 rb_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 
1072 static VALUE *
1073 current_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 
1081 static VALUE
1082 send_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);
1110  rb_exc_raise(exc);
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 
1140 static VALUE
1141 send_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 
1187 VALUE
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 
1207 static VALUE
1208 rb_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 
1215 static inline VALUE
1216 rb_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 
1224 static inline VALUE
1225 rb_yield_0(int argc, const VALUE * argv)
1226 {
1227  return vm_yield(GET_EC(), argc, argv, RB_NO_KEYWORDS);
1228 }
1229 
1230 VALUE
1232 {
1233  return rb_yield_0(1, &val);
1234 }
1235 
1236 VALUE
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
1248 VALUE
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 
1270 VALUE
1272 {
1273  return rb_yield_0(argc, argv);
1274 }
1275 
1276 VALUE
1277 rb_yield_values_kw(int argc, const VALUE *argv, int kw_splat)
1278 {
1279  return rb_yield_0_kw(argc, argv, kw_splat);
1280 }
1281 
1282 VALUE
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 
1295 VALUE
1296 rb_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 
1308 VALUE
1310 {
1311  return vm_yield_force_blockarg(GET_EC(), values);
1312 }
1313 
1314 VALUE
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 
1326 static VALUE
1327 loop_i(VALUE _)
1328 {
1329  for (;;) {
1330  rb_yield_0(0, 0);
1331  }
1332  return Qnil;
1333 }
1334 
1335 static VALUE
1336 loop_stop(VALUE dummy, VALUE exc)
1337 {
1338  return rb_attr_get(exc, id_result);
1339 }
1340 
1341 static VALUE
1342 rb_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 
1377 static VALUE
1378 rb_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
1385 static const char *
1386 vm_frametype_name(const rb_control_frame_t *cfp);
1387 #endif
1388 
1389 static VALUE
1390 rb_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 
1443 VALUE
1444 rb_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 
1460 static VALUE
1461 iterate_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 
1469 VALUE
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 
1483 VALUE
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 
1500 VALUE
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 
1518 static VALUE
1519 iterate_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 
1527 VALUE
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 
1541 VALUE
1543 {
1544  return rb_call(obj, idEach, 0, 0, CALL_FCALL);
1545 }
1546 
1547 void rb_parser_warn_location(VALUE, int);
1548 static const rb_iseq_t *
1549 eval_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);
1554  VALUE realpath = Qnil;
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;
1570  rb_parser_warn_location(parser, TRUE);
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) {
1579  iseq = rb_iseq_new_with_opt(&ast->body,
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 
1598 static VALUE
1599 eval_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 
1630 static VALUE
1631 eval_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 
1669 VALUE
1670 rb_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 
1695 VALUE
1696 ruby_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 
1714 VALUE
1715 rb_eval_string(const char *str)
1716 {
1717  return ruby_eval_string_from_file(str, "eval");
1718 }
1719 
1720 static VALUE
1721 eval_string_protect(VALUE str)
1722 {
1723  return rb_eval_string((char *)str);
1724 }
1725 
1736 VALUE
1737 rb_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 
1748 static VALUE
1749 eval_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 
1768 VALUE
1769 rb_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 
1800 VALUE
1801 rb_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)) {
1810  val = rb_funcallv_kw(cmd, idCall, RARRAY_LENINT(arg),
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 
1823 VALUE
1824 rb_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 
1832 static VALUE
1833 yield_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 
1884 VALUE
1885 rb_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 */
1907 static VALUE
1908 eval_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 
1915 static VALUE
1916 specific_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 
1940 static VALUE
1941 singleton_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 
1989 static VALUE
1990 rb_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 
1996 VALUE
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 
2021 static VALUE
2022 rb_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 
2028 VALUE
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 
2062 static VALUE
2063 rb_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 
2068 VALUE
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 
2096 static VALUE
2097 rb_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 
2102 VALUE
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 
2121 static VALUE
2122 uncaught_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 
2138 static VALUE
2139 uncaught_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 
2151 static VALUE
2152 uncaught_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 
2164 static VALUE
2165 uncaught_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 
2184 static VALUE
2185 rb_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 
2194 void
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);
2216  EC_JUMP_TAG(ec, TAG_THROW);
2217 }
2218 
2219 void
2220 rb_throw(const char *tag, VALUE val)
2221 {
2223 }
2224 
2225 static VALUE
2226 catch_i(RB_BLOCK_CALL_FUNC_ARGLIST(tag, _))
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 
2282 static VALUE
2283 rb_f_catch(int argc, VALUE *argv, VALUE self)
2284 {
2286  return rb_catch_obj(tag, catch_i, 0);
2287 }
2288 
2289 VALUE
2290 rb_catch(const char *tag, rb_block_call_func_t func, VALUE data)
2291 {
2293  return rb_catch_obj(vtag, func, data);
2294 }
2295 
2296 static VALUE
2297 vm_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 
2325 VALUE
2327 {
2328  return vm_catch_protect(t, func, data, stateptr, GET_EC());
2329 }
2330 
2331 VALUE
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 
2341 static void
2342 local_var_list_init(struct local_var_list *vars)
2343 {
2344  vars->tbl = rb_ident_hash_new();
2345  RBASIC_CLEAR_CLASS(vars->tbl);
2346 }
2347 
2348 static VALUE
2349 local_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 
2358 static int
2359 local_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 
2366 static void
2367 local_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 
2389 static VALUE
2390 rb_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 
2446 static VALUE
2447 rb_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 
2461 VALUE
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 
2471 void
2473 {
2474  rb_define_global_function("eval", rb_f_eval, -1);
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);
2495  rb_define_method(rb_mKernel, "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 */
rb_iseq_realpath
VALUE rb_iseq_realpath(const rb_iseq_t *iseq)
Definition: iseq.c:1033
METHOD_VISI_PRIVATE
@ METHOD_VISI_PRIVATE
Definition: method.h:29
va_end
#define va_end(v)
Definition: rb_mjit_min_header-2.7.2.h:3982
rb_check_block_call
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
rb_parser_new
VALUE rb_parser_new(void)
Definition: ripper.c:19206
min_argc
const rb_iseq_t const int const int min_argc
Definition: rb_mjit_min_header-2.7.2.h:13470
rb_proc_lambda_p
VALUE rb_proc_lambda_p(VALUE)
Definition: proc.c:275
UNLIKELY
#define UNLIKELY(x)
Definition: ffi_common.h:126
ID
unsigned long ID
Definition: ruby.h:103
rb_define_class
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
Definition: class.c:649
T_FALSE
#define T_FALSE
Definition: ruby.h:537
rescue_funcall_args::respond_to_missing
unsigned int respond_to_missing
Definition: vm_eval.c:402
rb_fstring
VALUE rb_fstring(VALUE)
Definition: string.c:312
rb_check_funcall_with_hook_kw
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
idSend
@ idSend
Definition: rb_mjit_min_header-2.7.2.h:8670
iter_method_arg::obj
VALUE obj
Definition: vm_eval.c:1453
MISSING_SUPER
@ MISSING_SUPER
Definition: internal.h:2341
TRUE
#define TRUE
Definition: nkf.h:175
rb_f_send
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv)
Definition: vm_eval.c:1188
rb_callable_method_entry_with_refinements
const rb_callable_method_entry_t * rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class)
Definition: vm_method.c:917
block_handler_type_iseq
@ block_handler_type_iseq
Definition: vm_core.h:738
rb_check_id
ID rb_check_id(volatile VALUE *)
Returns ID for the given name if it is interned already, or 0.
Definition: symbol.c:919
T_FLOAT
#define T_FLOAT
Definition: ruby.h:527
rb_str_new2
#define rb_str_new2
Definition: intern.h:903
rb_thread_struct::top_self
VALUE top_self
Definition: vm_core.h:923
rb_obj_instance_eval
VALUE rb_obj_instance_eval(int argc, const VALUE *argv, VALUE self)
Definition: vm_eval.c:1997
rb_ast_struct::body
rb_ast_body_t body
Definition: node.h:402
eval_string_wrap_arg::klass
VALUE klass
Definition: vm_eval.c:1744
rb_block_call
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
id
const int id
Definition: nkf.c:209
NORETURN
NORETURN(static void uncallable_object(VALUE recv, ID mid))
VM_METHOD_TYPE_REFINED
@ VM_METHOD_TYPE_REFINED
refinement
Definition: method.h:113
VM_FRAME_FLAG_FINISH
@ VM_FRAME_FLAG_FINISH
Definition: vm_core.h:1177
RB_PASS_CALLED_KEYWORDS
#define RB_PASS_CALLED_KEYWORDS
Definition: ruby.h:1980
rb_iseq_struct
Definition: vm_core.h:456
ruby_value_type
ruby_value_type
Definition: ruby.h:486
iter_method_arg::argc
int argc
Definition: vm_eval.c:1455
rb_method_definition_struct::method_serial
uintptr_t method_serial
Definition: method.h:180
rb_vm_invoke_proc
MJIT_FUNC_EXPORTED VALUE rb_vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, int argc, const VALUE *argv, int kw_splat, VALUE passed_block_handler)
Definition: vm.c:1249
rb_ident_hash_new
VALUE rb_ident_hash_new(void)
Definition: hash.c:4278
rb_hash_new
VALUE rb_hash_new(void)
Definition: hash.c:1523
rb_iterate
VALUE rb_iterate(VALUE(*it_proc)(VALUE), VALUE data1, rb_block_call_func_t bl_proc, VALUE data2)
Definition: vm_eval.c:1444
cfp
rb_control_frame_t * cfp
Definition: rb_mjit_min_header-2.7.2.h:14524
rb_method_cfunc_struct::invoker
VALUE(* invoker)(VALUE recv, int argc, const VALUE *argv, VALUE(*func)(ANYARGS))
Definition: method.h:133
calling
rb_control_frame_t struct rb_calling_info * calling
Definition: rb_mjit_min_header-2.7.2.h:14524
VM_METHOD_TYPE_OPTIMIZED
@ VM_METHOD_TYPE_OPTIMIZED
Kernel::send, Proc::call, etc.
Definition: method.h:111
rb_warn
void rb_warn(const char *fmt,...)
Definition: error.c:315
VM_FRAME_FLAG_CFRAME_KW
@ VM_FRAME_FLAG_CFRAME_KW
Definition: vm_core.h:1182
rb_block_given_p
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition: eval.c:898
rb_current_receiver
VALUE rb_current_receiver(void)
Definition: vm_eval.c:314
rb_method_definition_struct::attr
rb_method_attr_t attr
Definition: method.h:171
rb_iseq_disasm
VALUE rb_iseq_disasm(const rb_iseq_t *iseq)
Definition: iseq.c:2278
RBASIC_CLEAR_CLASS
#define RBASIC_CLEAR_CLASS(obj)
Definition: internal.h:1987
rb_funcallv_kw
VALUE rb_funcallv_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:962
rb_yield_values_kw
VALUE rb_yield_values_kw(int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:1277
ST_STOP
@ ST_STOP
Definition: st.h:99
rb_ast_dispose
void rb_ast_dispose(rb_ast_t *ast)
Definition: node.c:1387
INT2FIX
#define INT2FIX(i)
Definition: ruby.h:263
rb_hash_clear
VALUE rb_hash_clear(VALUE hash)
Definition: hash.c:2769
T_MASK
#define T_MASK
Definition: md5.c:131
rb_call_cache::me
const struct rb_callable_method_entry_struct * me
Definition: internal.h:2379
rb_funcallv
VALUE rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv)
Calls a method.
Definition: vm_eval.c:956
PRIxVALUE
#define PRIxVALUE
Definition: ruby.h:164
rb_binding_t::pathobj
const VALUE pathobj
Definition: vm_core.h:1070
rb_yield_1
VALUE rb_yield_1(VALUE val)
Definition: vm_eval.c:1231
id_mesg
#define id_mesg
Definition: vm_eval.c:29
i
uint32_t i
Definition: rb_mjit_min_header-2.7.2.h:5460
rb_empty_keyword_given_p
int rb_empty_keyword_given_p(void)
Definition: eval.c:919
rb_thread_struct::top_wrapper
VALUE top_wrapper
Definition: vm_core.h:924
rb_callable_method_entry_struct::owner
const VALUE owner
Definition: method.h:64
rb_attr_get
VALUE rb_attr_get(VALUE, ID)
Definition: variable.c:1084
EXEC_EVENT_HOOK
#define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_)
Definition: vm_core.h:1935
ci
rb_control_frame_t struct rb_calling_info const struct rb_call_info * ci
Definition: rb_mjit_min_header-2.7.2.h:15126
rb_throw_obj
void rb_throw_obj(VALUE tag, VALUE value)
Definition: vm_eval.c:2195
rb_method_attr_struct::id
ID id
Definition: method.h:138
rb_yield_refine_block
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
Definition: vm_eval.c:1885
rb_type_str
const char * rb_type_str(enum ruby_value_type type)
Definition: vm_eval.c:572
VALUE
unsigned long VALUE
Definition: ruby.h:102
rb_adjust_argv_kw_splat
MJIT_FUNC_EXPORTED VALUE rb_adjust_argv_kw_splat(int *argc, const VALUE **argv, int *kw_splat)
Definition: vm_eval.c:237
rb_funcallv_public
VALUE rb_funcallv_public(VALUE recv, ID mid, int argc, const VALUE *argv)
Calls a method.
Definition: vm_eval.c:980
rb_module_new
VALUE rb_module_new(void)
Definition: class.c:758
rb_eArgError
VALUE rb_eArgError
Definition: error.c:925
va_list
__gnuc_va_list va_list
Definition: rb_mjit_min_header-2.7.2.h:834
rb_lambda_call
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
RB_TYPE_P
#define RB_TYPE_P(obj, type)
Definition: ruby.h:560
rb_intern_const
#define rb_intern_const(str)
Definition: ruby.h:1879
rb_callable_method_entry_struct
Definition: method.h:59
rb_cModule
RUBY_EXTERN VALUE rb_cModule
Definition: ruby.h:2034
block_handler_type_proc
@ block_handler_type_proc
Definition: vm_core.h:741
rb_current_realfilepath
VALUE rb_current_realfilepath(void)
Definition: vm_eval.c:2462
rb_name_err_new
VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method)
Definition: error.c:1594
rb_method_definition_struct::type
rb_method_type_t type
Definition: rb_mjit_min_header-2.7.2.h:8841
rescue_funcall_args
Definition: vm_eval.c:395
rb_define_global_function
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
Definition: class.c:1787
idMethodMissing
@ idMethodMissing
Definition: rb_mjit_min_header-2.7.2.h:8656
rb_call_super
VALUE rb_call_super(int argc, const VALUE *argv)
Definition: vm_eval.c:306
EC_JUMP_TAG
#define EC_JUMP_TAG(ec, st)
Definition: eval_intern.h:184
rb_funcall_passing_block_kw
VALUE rb_funcall_passing_block_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:1039
rb_iseq_constant_body::location
rb_iseq_location_t location
Definition: vm_core.h:399
RB_PASS_EMPTY_KEYWORDS
#define RB_PASS_EMPTY_KEYWORDS
Definition: ruby.h:1979
rb_execution_context_struct::tag
struct rb_vm_tag * tag
Definition: vm_core.h:849
VM_ENV_DATA_INDEX_SPECVAL
#define VM_ENV_DATA_INDEX_SPECVAL
Definition: vm_core.h:1194
rb_method_definition_struct::optimize_type
enum method_optimized_type optimize_type
Definition: method.h:176
exc
const rb_iseq_t const VALUE exc
Definition: rb_mjit_min_header-2.7.2.h:13469
rb_method_definition_struct::refined
rb_method_refined_t refined
Definition: method.h:173
rb_method_visibility_t
rb_method_visibility_t
Definition: method.h:26
vm_check_canary
#define vm_check_canary(ec, sp)
Definition: vm_insnhelper.c:257
rb_vm_tag::prev
struct rb_vm_tag * prev
Definition: vm_core.h:803
rb_method_refined_struct::orig_me
struct rb_method_entry_struct * orig_me
Definition: method.h:147
Qundef
#define Qundef
Definition: ruby.h:470
T_RATIONAL
#define T_RATIONAL
Definition: ruby.h:541
rb_catch_obj
VALUE rb_catch_obj(VALUE t, rb_block_call_func_t func, VALUE data)
Definition: vm_eval.c:2332
max_argc
const rb_iseq_t const int const int const int max_argc
Definition: rb_mjit_min_header-2.7.2.h:13470
Check_TypedStruct
#define Check_TypedStruct(v, t)
Definition: ruby.h:1200
rb_captured_block::self
VALUE self
Definition: vm_core.h:728
rb_define_method
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1551
GET_EC
#define GET_EC()
Definition: vm_core.h:1766
RUBY_VM_CHECK_INTS
#define RUBY_VM_CHECK_INTS(ec)
Definition: vm_core.h:1862
rb_eNameError
VALUE rb_eNameError
Definition: error.c:929
eval_string_wrap_arg::str
const char * str
Definition: vm_eval.c:1745
rb_hash_keys
MJIT_FUNC_EXPORTED VALUE rb_hash_keys(VALUE hash)
Definition: hash.c:3409
rb_calling_info
Definition: vm_core.h:250
ptr
struct RIMemo * ptr
Definition: debug.c:65
vm_ifunc
IFUNC (Internal FUNCtion)
Definition: internal.h:1215
iter_method_arg::kw_splat
int kw_splat
Definition: vm_eval.c:1457
T_DATA
#define T_DATA
Definition: ruby.h:538
Qfalse
#define Qfalse
Definition: ruby.h:467
RETURN_SIZED_ENUMERATOR
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
Definition: intern.h:271
DBL2NUM
#define DBL2NUM(dbl)
Definition: ruby.h:967
iter_method_arg::mid
ID mid
Definition: vm_eval.c:1454
rb_method_boundp
int rb_method_boundp(VALUE, ID, int)
Definition: vm_method.c:1102
rb_id2str
#define rb_id2str(id)
Definition: vm_backtrace.c:30
T_NODE
#define T_NODE
Definition: ruby.h:545
SPECIAL_CONST_P
#define SPECIAL_CONST_P(x)
Definition: ruby.h:1313
NULL
#define NULL
Definition: _sdbm.c:101
T_COMPLEX
#define T_COMPLEX
Definition: ruby.h:542
SafeStringValue
#define SafeStringValue(v)
Definition: ruby.h:607
rb_eval_string_wrap
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
rb_ec_stack_check
int rb_ec_stack_check(rb_execution_context_t *ec)
Definition: gc.c:4668
PRIsVALUE
#define PRIsVALUE
Definition: ruby.h:166
MISSING_NONE
@ MISSING_NONE
Definition: internal.h:2343
rb_funcallv_public_kw
VALUE rb_funcallv_public_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:986
VM_FRAME_FLAG_CFRAME_EMPTY_KW
@ VM_FRAME_FLAG_CFRAME_EMPTY_KW
Definition: vm_core.h:1183
rb_parser_warn_location
void rb_parser_warn_location(VALUE, int)
Definition: ripper.c:19029
ID2SYM
#define ID2SYM(x)
Definition: ruby.h:414
OPTIMIZED_METHOD_TYPE_SEND
@ OPTIMIZED_METHOD_TYPE_SEND
Definition: method.h:157
rb_funcall_with_block_kw
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
OBJ_FREEZE
#define OBJ_FREEZE(x)
Definition: ruby.h:1377
rb_thread_struct::ec
rb_execution_context_t * ec
Definition: vm_core.h:915
T_SYMBOL
#define T_SYMBOL
Definition: ruby.h:540
T_OBJECT
#define T_OBJECT
Definition: ruby.h:523
rb_free_tmp_buffer
void rb_free_tmp_buffer(volatile VALUE *store)
Definition: gc.c:10277
VM_METHOD_TYPE_IVAR
@ VM_METHOD_TYPE_IVAR
attr_reader or attr_accessor
Definition: method.h:105
VM_ASSERT
#define VM_ASSERT(expr)
Definition: vm_core.h:56
RB_BLOCK_CALL_FUNC_ARGLIST
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Definition: ruby.h:1964
iter_method_arg
Definition: vm_eval.c:1452
rb_protect
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *pstate)
Protects a function call from potential global escapes from the function.
Definition: eval.c:1072
rb_check_arity
#define rb_check_arity
Definition: intern.h:347
CALL_VCALL
@ CALL_VCALL
Definition: vm_eval.c:34
MISSING_MISSING
@ MISSING_MISSING
Definition: internal.h:2342
VM_BLOCK_HANDLER_NONE
#define VM_BLOCK_HANDLER_NONE
Definition: vm_core.h:1291
RARRAY_LENINT
#define RARRAY_LENINT(ary)
Definition: ruby.h:1071
VM_METHOD_TYPE_UNDEF
@ VM_METHOD_TYPE_UNDEF
Definition: method.h:109
rb_funcall_passing_block
VALUE rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE *argv)
Definition: vm_eval.c:1032
rb_control_frame_struct::sp
VALUE * sp
Definition: vm_core.h:762
UNLIMITED_ARGUMENTS
#define UNLIMITED_ARGUMENTS
Definition: intern.h:57
rb_obj_instance_exec
VALUE rb_obj_instance_exec(int argc, const VALUE *argv, VALUE self)
Definition: vm_eval.c:2029
rb_yield_force_blockarg
VALUE rb_yield_force_blockarg(VALUE values)
Definition: vm_eval.c:1309
rb_raise
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2671
RCLASS_ORIGIN
#define RCLASS_ORIGIN(c)
Definition: internal.h:1075
rb_method_definition_struct::cfunc
rb_method_cfunc_t cfunc
Definition: method.h:170
rb_sym_intern_ascii_cstr
#define rb_sym_intern_ascii_cstr(ptr)
Definition: rb_mjit_min_header-2.7.2.h:7721
rb_call_cache
Definition: internal.h:2361
rb_ivar_get
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1070
T_FILE
#define T_FILE
Definition: ruby.h:534
rb_execution_context_struct::cfp
rb_control_frame_t * cfp
Definition: vm_core.h:847
rb_iseq_constant_body::local_table
const ID * local_table
Definition: vm_core.h:411
rb_each
VALUE rb_each(VALUE obj)
Definition: vm_eval.c:1542
VM_FRAME_FLAG_CFRAME
@ VM_FRAME_FLAG_CFRAME
Definition: vm_core.h:1179
CHECK_CFP_CONSISTENCY
#define CHECK_CFP_CONSISTENCY(func)
Definition: vm_insnhelper.c:2448
rb_hash_stlike_update
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func func, st_data_t arg)
Definition: hash.c:1651
rb_obj_class
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
Definition: object.c:217
MISSING_PROTECTED
@ MISSING_PROTECTED
Definition: internal.h:2338
rb_special_singleton_class
VALUE rb_special_singleton_class(VALUE obj)
Definition: class.c:1621
RUBY_DTRACE_CMETHOD_ENTRY_HOOK
#define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, klass, id)
Definition: probes_helper.h:36
rb_str_format
VALUE rb_str_format(int, const VALUE *, VALUE)
Definition: sprintf.c:204
OPTIMIZED_METHOD_TYPE_CALL
@ OPTIMIZED_METHOD_TYPE_CALL
Definition: method.h:158
rb_vm_tag::retval
VALUE retval
Definition: vm_core.h:801
T_ICLASS
#define T_ICLASS
Definition: ruby.h:525
rb_ast_struct
Definition: node.h:399
HUGE_VAL
#define HUGE_VAL
Definition: missing.h:161
rb_f_eval
VALUE rb_f_eval(int argc, const VALUE *argv, VALUE self)
Definition: vm_eval.c:1670
VM_FRAME_MAGIC_CFUNC
@ VM_FRAME_MAGIC_CFUNC
Definition: vm_core.h:1167
rb_vm_pop_cfunc_frame
MJIT_STATIC void rb_vm_pop_cfunc_frame(void)
Definition: rb_mjit_min_header-2.7.2.h:17248
klass
VALUE klass
Definition: rb_mjit_min_header-2.7.2.h:13222
LIKELY
#define LIKELY(x)
Definition: ffi_common.h:125
EC_POP_TAG
#define EC_POP_TAG()
Definition: eval_intern.h:137
undefined
#define undefined
Definition: vm_method.c:36
rb_calling_info::kw_splat
int kw_splat
Definition: vm_core.h:254
rb_cBasicObject
RUBY_EXTERN VALUE rb_cBasicObject
Definition: ruby.h:2009
ALLOCV_END
#define ALLOCV_END(v)
Definition: ruby.h:1750
rb_captured_block::ep
const VALUE * ep
Definition: vm_core.h:729
rb_callable_method_entry_struct::defined_class
const VALUE defined_class
Definition: method.h:61
rb_str_intern
VALUE rb_str_intern(VALUE)
Definition: symbol.c:710
SDR
#define SDR()
Definition: vm_core.h:1639
block_handler
rb_control_frame_t struct rb_calling_info const struct rb_call_info VALUE block_handler
Definition: rb_mjit_min_header-2.7.2.h:15126
rb_eval_cmd_kw
VALUE rb_eval_cmd_kw(VALUE cmd, VALUE arg, int kw_splat)
Definition: vm_eval.c:1801
MISSING_VCALL
@ MISSING_VCALL
Definition: internal.h:2340
rb_nomethod_err_new
VALUE rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv)
Definition: error.c:1675
METHOD_ENTRY_VISI
#define METHOD_ENTRY_VISI(me)
Definition: method.h:67
VM_CALL_KW_SPLAT
#define VM_CALL_KW_SPLAT
Definition: vm_core.h:1108
rb_iseq_location_struct::label
VALUE label
Definition: vm_core.h:275
ALLOCV_N
#define ALLOCV_N(type, v, n)
Definition: ruby.h:1749
ruby_eval_string_from_file
VALUE ruby_eval_string_from_file(const char *str, const char *filename)
Definition: vm_eval.c:1696
rb_iseq_constant_body::local_table_size
unsigned int local_table_size
Definition: vm_core.h:435
T_FIXNUM
#define T_FIXNUM
Definition: ruby.h:535
rb_vm_top_self
VALUE rb_vm_top_self(void)
Definition: vm.c:3347
rb_sym_proc_call
VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc)
Definition: string.c:10816
RHASH_EMPTY_P
#define RHASH_EMPTY_P(h)
Definition: ruby.h:1131
rb_vm_ifunc_new
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
rb_yield_splat
VALUE rb_yield_splat(VALUE values)
Definition: vm_eval.c:1283
st_data_t
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
Definition: st.h:22
VM_METHOD_TYPE_CFUNC
@ VM_METHOD_TYPE_CFUNC
C method.
Definition: method.h:103
rb_vm_call_kw
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
rb_execution_context_struct::errinfo
VALUE errinfo
Definition: vm_core.h:875
rb_method_cfunc_struct::func
VALUE(* func)(ANYARGS)
Definition: method.h:132
rb_check_funcall_hook
void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE)
Definition: internal.h:2314
T_REGEXP
#define T_REGEXP
Definition: ruby.h:529
VM_METHOD_TYPE_NOTIMPLEMENTED
@ VM_METHOD_TYPE_NOTIMPLEMENTED
Definition: method.h:110
RAISED_STACKOVERFLOW
@ RAISED_STACKOVERFLOW
Definition: eval_intern.h:255
rb_cref_struct
CREF (Class REFerence)
Definition: method.h:41
call_type
call_type
Definition: vm_eval.c:31
rb_check_funcall_default
VALUE rb_check_funcall_default(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def)
Definition: vm_eval.c:533
rb_method_basic_definition_p
#define rb_method_basic_definition_p(klass, mid)
Definition: rb_mjit_min_header-2.7.2.h:7863
MISSING_FCALL
@ MISSING_FCALL
Definition: internal.h:2339
type_case
#define type_case(t)
vm_throw_data
THROW_DATA.
Definition: internal.h:1193
VM_METHOD_TYPE_BMETHOD
@ VM_METHOD_TYPE_BMETHOD
Definition: method.h:106
EC_EXEC_TAG
#define EC_EXEC_TAG()
Definition: eval_intern.h:181
METHOD_ENTRY_BASIC
#define METHOD_ENTRY_BASIC(me)
Definition: method.h:68
me
const rb_callable_method_entry_t * me
Definition: rb_mjit_min_header-2.7.2.h:13194
rb_block_call_func
VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
Definition: ruby.h:1966
rb_binding_t::block
const struct rb_block block
Definition: vm_core.h:1069
rb_call_data::cc
struct rb_call_cache cc
Definition: internal.h:2400
eval_string_wrap_arg
Definition: vm_eval.c:1742
vars
const VALUE int int int int int int VALUE * vars[]
Definition: rb_mjit_min_header-2.7.2.h:6458
rescue_funcall_args::respond
unsigned int respond
Definition: vm_eval.c:401
T_CLASS
#define T_CLASS
Definition: ruby.h:524
rb_catch_protect
VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr)
Definition: vm_eval.c:2326
T_MATCH
#define T_MATCH
Definition: ruby.h:539
idCall
@ idCall
Definition: rb_mjit_min_header-2.7.2.h:8691
rb_ary_subseq
#define rb_ary_subseq(ary, beg, len)
Definition: cparse.c:76
block_handler_type_ifunc
@ block_handler_type_ifunc
Definition: vm_core.h:739
rb_eRuntimeError
VALUE rb_eRuntimeError
Definition: error.c:922
va_arg
#define va_arg(v, l)
Definition: rb_mjit_min_header-2.7.2.h:3983
ALLOCA_N
#define ALLOCA_N(type, n)
Definition: ruby.h:1684
METHOD_VISI_PROTECTED
@ METHOD_VISI_PROTECTED
Definition: method.h:30
rb_yield_splat_kw
VALUE rb_yield_splat_kw(VALUE values, int kw_splat)
Definition: vm_eval.c:1296
mod
#define mod(x, y)
Definition: date_strftime.c:28
rb_control_frame_struct
Definition: vm_core.h:760
rb_eval_cmd
VALUE rb_eval_cmd(VALUE cmd, VALUE arg, int _level)
Definition: vm_eval.c:1824
iter_method_arg::argv
const VALUE * argv
Definition: vm_eval.c:1456
StringValuePtr
#define StringValuePtr(v)
Definition: ruby.h:603
rb_vm_tag::tag
VALUE tag
Definition: vm_core.h:800
rescue_funcall_args::defined_class
VALUE defined_class
Definition: vm_eval.c:396
rb_execution_context_struct::method_missing_reason
enum method_missing_reason method_missing_reason
Definition: rb_mjit_min_header-2.7.2.h:9837
rescue_funcall_args::argc
int argc
Definition: vm_eval.c:403
FALSE
#define FALSE
Definition: nkf.h:174
RCLASS_SUPER
#define RCLASS_SUPER(c)
Definition: classext.h:16
RSTRING_FSTR
@ RSTRING_FSTR
Definition: ruby.h:983
TAG_RETRY
#define TAG_RETRY
Definition: vm_core.h:201
VM_METHOD_TYPE_ZSUPER
@ VM_METHOD_TYPE_ZSUPER
Definition: method.h:107
arg
VALUE arg
Definition: rb_mjit_min_header-2.7.2.h:5597
METHOD_VISI_PUBLIC
@ METHOD_VISI_PUBLIC
Definition: method.h:28
rb_parser_compile_string_path
rb_ast_t * rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
Definition: ripper.c:12878
CALL_TYPE_MAX
@ CALL_TYPE_MAX
Definition: vm_eval.c:37
rb_yield_block
VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(val, arg))
Definition: vm_eval.c:1315
rb_check_funcall_kw
VALUE rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:499
rb_vm_tag::state
enum ruby_tag_type state
Definition: vm_core.h:804
local_var_list::tbl
VALUE tbl
Definition: vm_eval.c:15
T_NONE
#define T_NONE
Definition: ruby.h:521
rescue_funcall_args::kw_splat
int kw_splat
Definition: vm_eval.c:405
rb_ec_raised_set
#define rb_ec_raised_set(ec, f)
Definition: eval_intern.h:258
rb_extend_object
void rb_extend_object(VALUE obj, VALUE module)
Extend the object with the module.
Definition: eval.c:1701
GetProcPtr
#define GetProcPtr(obj, ptr)
Definition: vm_core.h:1046
rb_check_array_type
VALUE rb_check_array_type(VALUE ary)
Definition: array.c:909
realpath
char * realpath(const char *__restrict path, char *__restrict resolved_path)
key
key
Definition: openssl_missing.h:181
T_HASH
#define T_HASH
Definition: ruby.h:531
ruby_binding_data_type
const rb_data_type_t ruby_binding_data_type
Definition: proc.c:319
rb_yield_values2
VALUE rb_yield_values2(int argc, const VALUE *argv)
Definition: vm_eval.c:1271
rb_scan_args
#define rb_scan_args(argc, argvp, fmt,...)
Definition: rb_mjit_min_header-2.7.2.h:6368
rb_eNotImpError
VALUE rb_eNotImpError
Definition: error.c:934
CLASS_OF
#define CLASS_OF(v)
Definition: ruby.h:484
rb_vm_tag
Definition: vm_core.h:799
rb_mod_module_eval
VALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod)
Definition: vm_eval.c:2069
va_init_list
#define va_init_list(a, b)
Definition: win32ole.h:34
rb_apply
VALUE rb_apply(VALUE recv, ID mid, VALUE args)
Calls a method.
Definition: vm_eval.c:890
rb_eNoMethodError
VALUE rb_eNoMethodError
Definition: error.c:932
T_MODULE
#define T_MODULE
Definition: ruby.h:526
rb_cref_struct::klass
VALUE klass
Definition: method.h:44
rb_vm_frame_method_entry
MJIT_STATIC const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
Definition: rb_mjit_min_header-2.7.2.h:12489
rb_check_funcall
VALUE rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv)
Definition: vm_eval.c:505
rb_ary_new4
#define rb_ary_new4
Definition: intern.h:105
rb_method_type_t
rb_method_type_t
Definition: method.h:101
FL_TEST_RAW
#define FL_TEST_RAW(x, f)
Definition: ruby.h:1352
rb_eval_string
VALUE rb_eval_string(const char *str)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1715
rb_throw
void rb_throw(const char *tag, VALUE val)
Definition: vm_eval.c:2220
rb_callable_method_entry
RUBY_SYMBOL_EXPORT_END const rb_callable_method_entry_t * rb_callable_method_entry(VALUE klass, ID id)
Definition: vm_method.c:878
rb_cObject
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:2010
rb_add_method
void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi)
Definition: vm_method.c:674
buf
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4322
rb_exc_raise
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
Definition: eval.c:668
obj
const VALUE VALUE obj
Definition: rb_mjit_min_header-2.7.2.h:5738
T_BIGNUM
#define T_BIGNUM
Definition: ruby.h:533
local_var_list
Definition: vm_eval.c:14
rescue_funcall_args::mid
ID mid
Definition: vm_eval.c:398
VM_METHOD_TYPE_MISSING
@ VM_METHOD_TYPE_MISSING
wrapper for method_missing(id)
Definition: method.h:112
rb_method_cfunc_struct::argc
int argc
Definition: method.h:134
rb_bug
void rb_bug(const char *fmt,...)
Definition: error.c:636
rb_control_frame_struct::self
VALUE self
Definition: vm_core.h:764
RUBY_DTRACE_CMETHOD_RETURN_HOOK
#define RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, klass, id)
Definition: probes_helper.h:39
rb_block_call_func_t
rb_block_call_func * rb_block_call_func_t
Definition: ruby.h:1967
T_ARRAY
#define T_ARRAY
Definition: ruby.h:530
rb_mKernel
RUBY_EXTERN VALUE rb_mKernel
Definition: ruby.h:1998
argv
char ** argv
Definition: ruby.c:223
rb_funcall
VALUE rb_funcall(VALUE recv, ID mid, int n,...)
Calls a method.
Definition: vm_eval.c:922
ST_CONTINUE
@ ST_CONTINUE
Definition: st.h:99
rb_vm_rewind_cfp
void rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp)
Definition: vm.c:604
rb_vm_get_ruby_level_next_cfp
MJIT_FUNC_EXPORTED 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
VM_METHOD_TYPE_ATTRSET
@ VM_METHOD_TYPE_ATTRSET
attr_writer or attr_accessor
Definition: method.h:104
StringValue
use StringValue() instead")))
eval_string_wrap_arg::top_self
VALUE top_self
Definition: vm_eval.c:1743
vm_exec
VALUE vm_exec(rb_execution_context_t *ec, int mjit_enable_p)
Definition: vm.c:1909
call_status
int const VALUE VALUE int call_status
Definition: rb_mjit_min_header-2.7.2.h:15400
rb_calling_info::recv
VALUE recv
Definition: vm_core.h:252
rb_method_definition_struct::body
union rb_method_definition_struct::@0 body
T_NIL
#define T_NIL
Definition: ruby.h:522
rb_obj_alloc
VALUE rb_obj_alloc(VALUE)
Allocates an instance of klass.
Definition: object.c:1895
T_MOVED
#define T_MOVED
Definition: ruby.h:547
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
GET_THREAD
#define GET_THREAD()
Definition: vm_core.h:1765
BOUND_RESPONDS
#define BOUND_RESPONDS
Definition: vm_method.c:1099
PASS_PASSED_BLOCK_HANDLER
#define PASS_PASSED_BLOCK_HANDLER()
Definition: eval_intern.h:23
reg_cfp
rb_control_frame_t * reg_cfp
Definition: rb_mjit_min_header-2.7.2.h:15126
src
__inline__ const void *__restrict src
Definition: rb_mjit_min_header-2.7.2.h:2842
rb_control_frame_struct::iseq
const rb_iseq_t * iseq
Definition: vm_core.h:763
rb_captured_block
Definition: vm_core.h:727
memcpy
void * memcpy(void *__restrict, const void *__restrict, size_t)
RARRAY_CONST_PTR
#define RARRAY_CONST_PTR(s)
Definition: psych_emitter.c:4
T_ZOMBIE
#define T_ZOMBIE
Definition: ruby.h:546
MEMCPY
#define MEMCPY(p1, p2, type, n)
Definition: ruby.h:1753
rb_parser_set_context
VALUE rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main)
Definition: ripper.c:19216
PASS_PASSED_BLOCK_HANDLER_EC
#define PASS_PASSED_BLOCK_HANDLER_EC(ec)
Definition: eval_intern.h:22
rescue_funcall_args::ec
rb_execution_context_t * ec
Definition: vm_eval.c:399
rb_eval_string_protect
VALUE rb_eval_string_protect(const char *str, int *pstate)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1737
rescue_funcall_args::recv
VALUE recv
Definition: vm_eval.c:397
Init_vm_eval
void Init_vm_eval(void)
Definition: vm_eval.c:2472
NIL_P
#define NIL_P(v)
Definition: ruby.h:482
TAG_NONE
#define TAG_NONE
Definition: vm_core.h:197
rb_resolve_refined_method_callable
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:979
block_handler_type_symbol
@ block_handler_type_symbol
Definition: vm_core.h:740
rb_binding_t
Definition: vm_core.h:1068
BOUND_PRIVATE
#define BOUND_PRIVATE
Definition: vm_method.c:1098
argc
int argc
Definition: ruby.c:222
VM_METHOD_TYPE_ISEQ
@ VM_METHOD_TYPE_ISEQ
Ruby method.
Definition: method.h:102
rb_captured_block::code
union rb_captured_block::@11 code
T_IMEMO
#define T_IMEMO
Definition: ruby.h:543
rb_ec_stack_overflow
MJIT_STATIC void rb_ec_stack_overflow(rb_execution_context_t *ec, int crit)
Definition: vm_insnhelper.c:67
rb_singleton_class
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
Definition: class.c:1725
RB_NO_KEYWORDS
#define RB_NO_KEYWORDS
Definition: ruby.h:1977
rb_catch
VALUE rb_catch(const char *tag, rb_block_call_func_t func, VALUE data)
Definition: vm_eval.c:2290
CALL_FCALL
@ CALL_FCALL
Definition: vm_eval.c:33
err
int err
Definition: win32.c:135
idEach
@ idEach
Definition: rb_mjit_min_header-2.7.2.h:8667
rb_is_local_id
int rb_is_local_id(ID id)
Definition: symbol.c:884
BUILTIN_TYPE
#define BUILTIN_TYPE(x)
Definition: ruby.h:551
rb_iseq_new_with_opt
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 type, const rb_compile_option_t *option)
Definition: iseq.c:807
st_data_t
unsigned long st_data_t
Definition: rb_mjit_min_header-2.7.2.h:5359
rb_method_definition_struct::original_id
ID original_id
Definition: method.h:179
rb_call_data::ci
struct rb_call_info ci
Definition: internal.h:2401
rb_vm_pop_frame
MJIT_STATIC void rb_vm_pop_frame(rb_execution_context_t *ec)
Definition: rb_mjit_min_header-2.7.2.h:12276
RBASIC
#define RBASIC(obj)
Definition: ruby.h:1267
MISSING_NOENTRY
@ MISSING_NOENTRY
Definition: internal.h:2336
printf
int int int printf(const char *__restrict,...) __attribute__((__format__(__printf__
MJIT_FUNC_EXPORTED
#define MJIT_FUNC_EXPORTED
Definition: defines.h:396
_
#define _(args)
Definition: dln.h:28
EC_PUSH_TAG
#define EC_PUSH_TAG(ec)
Definition: eval_intern.h:130
RUBY_EVENT_C_RETURN
#define RUBY_EVENT_C_RETURN
Definition: ruby.h:2248
rb_callable_method_entry_struct::def
struct rb_method_definition_struct *const def
Definition: method.h:62
rescue_funcall_args::me
const rb_method_entry_t * me
Definition: vm_eval.c:400
Qtrue
#define Qtrue
Definition: ruby.h:468
rb_eStopIteration
VALUE rb_eStopIteration
Definition: enumerator.c:124
rb_rescue2
VALUE rb_rescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
An equivalent of rescue clause.
Definition: eval.c:962
v
int VALUE v
Definition: rb_mjit_min_header-2.7.2.h:12300
rb_control_frame_struct::ep
const VALUE * ep
Definition: vm_core.h:765
len
uint8_t len
Definition: escape.c:17
rb_call_super_kw
VALUE rb_call_super_kw(int argc, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:298
SYMBOL_P
#define SYMBOL_P(x)
Definition: ruby.h:413
cc
const struct rb_call_cache * cc
Definition: rb_mjit_min_header-2.7.2.h:13196
rb_keyword_given_p
int rb_keyword_given_p(void)
Definition: eval.c:911
VM_ENV_FLAG_LOCAL
@ VM_ENV_FLAG_LOCAL
Definition: vm_core.h:1186
rb_funcall_with_block
VALUE rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval)
Definition: vm_eval.c:1050
rb_method_entry_struct
Definition: method.h:51
rb_iseq_struct::body
struct rb_iseq_constant_body * body
Definition: vm_core.h:460
rb_class_new_instance
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
Allocates and initializes an instance of klass.
Definition: object.c:1955
stderr
#define stderr
Definition: rb_mjit_min_header-2.7.2.h:1516
rb_yield_values
VALUE rb_yield_values(int n,...)
Definition: vm_eval.c:1249
rb_ivar_set
VALUE rb_ivar_set(VALUE, ID, VALUE)
Definition: variable.c:1300
T_STRING
#define T_STRING
Definition: ruby.h:528
rb_block
Definition: vm_core.h:751
RUBY_EVENT_C_CALL
#define RUBY_EVENT_C_CALL
Definition: ruby.h:2247
TAG_BREAK
#define TAG_BREAK
Definition: vm_core.h:199
id__send__
@ id__send__
Definition: rb_mjit_min_header-2.7.2.h:8671
rb_yield
VALUE rb_yield(VALUE val)
Definition: vm_eval.c:1237
rb_block_call_kw
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
rb_str_new_cstr
#define rb_str_new_cstr(str)
Definition: rb_mjit_min_header-2.7.2.h:6113
rb_method_cfunc_struct
Definition: method.h:131
rb_call_info
Definition: internal.h:2393
rb_check_funcall_with_hook
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
RARRAY_CONST_PTR_TRANSIENT
#define RARRAY_CONST_PTR_TRANSIENT(a)
Definition: ruby.h:1073
rb_ast_body_struct::root
const NODE * root
Definition: node.h:395
NUM2INT
#define NUM2INT(x)
Definition: ruby.h:715
T_STRUCT
#define T_STRUCT
Definition: ruby.h:532
Qnil
#define Qnil
Definition: ruby.h:469
rb_fstring_lit
#define rb_fstring_lit(str)
Definition: internal.h:2129
rb_captured_block::ifunc
const struct vm_ifunc * ifunc
Definition: vm_core.h:732
method_missing_reason
method_missing_reason
Definition: internal.h:2335
rb_mod_module_exec
VALUE rb_mod_module_exec(int argc, const VALUE *argv, VALUE mod)
Definition: vm_eval.c:2103
rb_vm_cref_new_toplevel
rb_cref_t * rb_vm_cref_new_toplevel(void)
Definition: vm.c:298
UNALIGNED_MEMBER_PTR
#define UNALIGNED_MEMBER_PTR(ptr, mem)
Definition: internal.h:2691
RB_GC_GUARD
#define RB_GC_GUARD(v)
Definition: ruby.h:585
numberof
#define numberof(array)
Definition: etc.c:618
rb_thread_struct
Definition: vm_core.h:910
UNREACHABLE_RETURN
#define UNREACHABLE_RETURN(val)
Definition: ruby.h:59
fprintf
int fprintf(FILE *__restrict, const char *__restrict,...) __attribute__((__format__(__printf__
rb_call_data
Definition: internal.h:2399
rb_proc_t
Definition: vm_core.h:1049
block_type_iseq
@ block_type_iseq
Definition: vm_core.h:745
rb_ec_raised_p
#define rb_ec_raised_p(ec, f)
Definition: eval_intern.h:260
rb_define_private_method
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1569
RUBY_VM_PREVIOUS_CONTROL_FRAME
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
Definition: vm_core.h:1384
TAG_THROW
#define TAG_THROW
Definition: vm_core.h:204
CALL_PUBLIC_KW
@ CALL_PUBLIC_KW
Definition: vm_eval.c:35
rb_make_no_method_exception
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
T_TRUE
#define T_TRUE
Definition: ruby.h:536
rb_obj_is_kind_of
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Determines if obj is a kind of c.
Definition: object.c:692
ruby_tag_type
ruby_tag_type
Definition: vm_core.h:184
rb_vm_call0
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
rb_binding_t::first_lineno
unsigned short first_lineno
Definition: vm_core.h:1071
RTEST
#define RTEST(v)
Definition: ruby.h:481
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
VM_METHOD_TYPE_ALIAS
@ VM_METHOD_TYPE_ALIAS
Definition: method.h:108
SYM2ID
#define SYM2ID(x)
Definition: ruby.h:415
rescue_funcall_args::argv
const VALUE * argv
Definition: vm_eval.c:404
CHECK_VM_STACK_OVERFLOW
#define CHECK_VM_STACK_OVERFLOW(cfp, margin)
Definition: vm_core.h:1746
T_UNDEF
#define T_UNDEF
Definition: ruby.h:544
CALL_PUBLIC
@ CALL_PUBLIC
Definition: vm_eval.c:32
iseq
const rb_iseq_t * iseq
Definition: rb_mjit_min_header-2.7.2.h:13469
rb_obj_clone
VALUE rb_obj_clone(VALUE)
Almost same as Object::clone.
Definition: object.c:410
CALL_FCALL_KW
@ CALL_FCALL_KW
Definition: vm_eval.c:36
UNDEFINED_METHOD_ENTRY_P
#define UNDEFINED_METHOD_ENTRY_P(me)
Definition: method.h:186
MISSING_PRIVATE
@ MISSING_PRIVATE
Definition: internal.h:2337
rb_source_location
VALUE rb_source_location(int *pline)
Definition: vm.c:1360
name
const char * name
Definition: nkf.c:208
rb_execution_context_struct
Definition: vm_core.h:843
n
const char size_t n
Definition: rb_mjit_min_header-2.7.2.h:5452