Ruby  2.4.2p198(2017-09-14revision59899)
eval.c
Go to the documentation of this file.
1 /**********************************************************************
2 
3  eval.c -
4 
5  $Author: naruse $
6  created at: Thu Jun 10 14:22:17 JST 1993
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 
14 #include "internal.h"
15 #include "eval_intern.h"
16 #include "iseq.h"
17 #include "gc.h"
18 #include "ruby/vm.h"
19 #include "vm_core.h"
20 #include "probes_helper.h"
21 
23 
26 
28 static ID id_cause;
29 #define id_signo ruby_static_id_signo
30 #define id_status ruby_static_id_status
31 
32 #define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
33 
34 #include "eval_error.c"
35 #include "eval_jump.c"
36 
37 #define CLASS_OR_MODULE_P(obj) \
38  (!SPECIAL_CONST_P(obj) && \
39  (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
40 
41 /* Initializes the Ruby VM and builtin libraries.
42  * @retval 0 if succeeded.
43  * @retval non-zero an error occurred.
44  */
45 int
47 {
48  int state;
49 
50  if (GET_VM())
51  return 0;
52 
53  ruby_init_stack((void *)&state);
54  Init_BareVM();
55  Init_heap();
57 
58  PUSH_TAG();
59  if ((state = EXEC_TAG()) == 0) {
60  rb_call_inits();
62  GET_VM()->running = 1;
63  }
64  POP_TAG();
65 
66  return state;
67 }
68 
69 /* Calls ruby_setup() and check error.
70  *
71  * Prints errors and calls exit(3) if an error occurred.
72  */
73 void
74 ruby_init(void)
75 {
76  int state = ruby_setup();
77  if (state) {
78  if (RTEST(ruby_debug))
80  exit(EXIT_FAILURE);
81  }
82 }
83 
94 void *
95 ruby_options(int argc, char **argv)
96 {
97  int state;
98  void *volatile iseq = 0;
99 
100  ruby_init_stack((void *)&iseq);
101  PUSH_TAG();
102  if ((state = EXEC_TAG()) == 0) {
103  SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv));
104  }
105  else {
107  state = error_handle(state);
108  iseq = (void *)INT2FIX(state);
109  }
110  POP_TAG();
111  return iseq;
112 }
113 
114 static void
116 {
117  PUSH_TAG();
118  if (EXEC_TAG() == 0) {
119  rb_trap_exit();
120  }
121  POP_TAG();
124 }
125 
126 static void
128 {
130  GET_THREAD()->errinfo = Qnil;
132 }
133 
141 void
143 {
144  ruby_finalize_0();
145  ruby_finalize_1();
146 }
147 
158 int
159 ruby_cleanup(volatile int ex)
160 {
161  int state;
162  volatile VALUE errs[2];
163  rb_thread_t *th = GET_THREAD();
164  int nerr;
165  volatile int sysex = EXIT_SUCCESS;
166  volatile int step = 0;
167 
170  TH_PUSH_TAG(th);
171  if ((state = EXEC_TAG()) == 0) {
172  SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
173 
174  step_0: step++;
175  errs[1] = th->errinfo;
176  th->safe_level = 0;
177  ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
178 
180 
181  step_1: step++;
182  /* protect from Thread#raise */
183  th->status = THREAD_KILLED;
184 
185  errs[0] = th->errinfo;
187  }
188  else {
189  switch (step) {
190  case 0: goto step_0;
191  case 1: goto step_1;
192  }
193  if (ex == 0) ex = state;
194  }
195  th->errinfo = errs[1];
196  sysex = error_handle(ex);
197 
198  state = 0;
199  for (nerr = 0; nerr < numberof(errs); ++nerr) {
200  VALUE err = ATOMIC_VALUE_EXCHANGE(errs[nerr], Qnil);
201 
202  if (!RTEST(err)) continue;
203 
204  /* th->errinfo contains a NODE while break'ing */
205  if (THROW_DATA_P(err)) continue;
206 
207  if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
208  sysex = sysexit_status(err);
209  break;
210  }
211  else if (rb_obj_is_kind_of(err, rb_eSignal)) {
212  VALUE sig = rb_ivar_get(err, id_signo);
213  state = NUM2INT(sig);
214  break;
215  }
216  else if (sysex == EXIT_SUCCESS) {
217  sysex = EXIT_FAILURE;
218  }
219  }
220 
221  ruby_finalize_1();
222 
223  /* unlock again if finalizer took mutexes. */
225  TH_POP_TAG();
228  if (state) ruby_default_signal(state);
229 
230  return sysex;
231 }
232 
233 static int
235 {
236  volatile int state;
237  rb_iseq_t *iseq = (rb_iseq_t *)n;
238  rb_thread_t *th = GET_THREAD();
239 
240  if (!n) return 0;
241 
242  TH_PUSH_TAG(th);
243  if ((state = EXEC_TAG()) == 0) {
244  SAVE_ROOT_JMPBUF(th, {
245  rb_iseq_eval_main(iseq);
246  });
247  }
248  TH_POP_TAG();
249  return state;
250 }
251 
253 void
254 ruby_stop(int ex)
255 {
256  exit(ruby_cleanup(ex));
257 }
258 
271 int
272 ruby_executable_node(void *n, int *status)
273 {
274  VALUE v = (VALUE)n;
275  int s;
276 
277  switch (v) {
278  case Qtrue: s = EXIT_SUCCESS; break;
279  case Qfalse: s = EXIT_FAILURE; break;
280  default:
281  if (!FIXNUM_P(v)) return TRUE;
282  s = FIX2INT(v);
283  }
284  if (status) *status = s;
285  return FALSE;
286 }
287 
292 int
294 {
295  int status;
296  if (!ruby_executable_node(n, &status)) {
297  ruby_cleanup(0);
298  return status;
299  }
300  return ruby_cleanup(ruby_exec_node(n));
301 }
302 
304 int
306 {
307  ruby_init_stack((void *)&n);
308  return ruby_exec_internal(n);
309 }
310 
311 /*
312  * call-seq:
313  * Module.nesting -> array
314  *
315  * Returns the list of +Modules+ nested at the point of call.
316  *
317  * module M1
318  * module M2
319  * $a = Module.nesting
320  * end
321  * end
322  * $a #=> [M1::M2, M1]
323  * $a[0].name #=> "M1::M2"
324  */
325 
326 static VALUE
328 {
329  VALUE ary = rb_ary_new();
330  const rb_cref_t *cref = rb_vm_cref();
331 
332  while (cref && CREF_NEXT(cref)) {
333  VALUE klass = CREF_CLASS(cref);
334  if (!CREF_PUSHED_BY_EVAL(cref) &&
335  !NIL_P(klass)) {
336  rb_ary_push(ary, klass);
337  }
338  cref = CREF_NEXT(cref);
339  }
340  return ary;
341 }
342 
343 /*
344  * call-seq:
345  * Module.constants -> array
346  * Module.constants(inherited) -> array
347  *
348  * In the first form, returns an array of the names of all
349  * constants accessible from the point of call.
350  * This list includes the names of all modules and classes
351  * defined in the global scope.
352  *
353  * Module.constants.first(4)
354  * # => [:ARGF, :ARGV, :ArgumentError, :Array]
355  *
356  * Module.constants.include?(:SEEK_SET) # => false
357  *
358  * class IO
359  * Module.constants.include?(:SEEK_SET) # => true
360  * end
361  *
362  * The second form calls the instance method +constants+.
363  */
364 
365 static VALUE
367 {
368  const rb_cref_t *cref = rb_vm_cref();
369  VALUE klass;
370  VALUE cbase = 0;
371  void *data = 0;
372 
373  if (argc > 0 || mod != rb_cModule) {
374  return rb_mod_constants(argc, argv, mod);
375  }
376 
377  while (cref) {
378  klass = CREF_CLASS(cref);
379  if (!CREF_PUSHED_BY_EVAL(cref) &&
380  !NIL_P(klass)) {
381  data = rb_mod_const_at(CREF_CLASS(cref), data);
382  if (!cbase) {
383  cbase = klass;
384  }
385  }
386  cref = CREF_NEXT(cref);
387  }
388 
389  if (cbase) {
390  data = rb_mod_const_of(cbase, data);
391  }
392  return rb_const_list(data);
393 }
394 
395 void
397 {
398  if (SPECIAL_CONST_P(klass)) {
399  noclass:
400  Check_Type(klass, T_CLASS);
401  }
402  if (OBJ_FROZEN(klass)) {
403  const char *desc;
404 
405  if (FL_TEST(klass, FL_SINGLETON)) {
406  desc = "object";
407  klass = rb_ivar_get(klass, id__attached__);
408  if (!SPECIAL_CONST_P(klass)) {
409  switch (BUILTIN_TYPE(klass)) {
410  case T_MODULE:
411  case T_ICLASS:
412  desc = "Module";
413  break;
414  case T_CLASS:
415  desc = "Class";
416  break;
417  }
418  }
419  }
420  else {
421  switch (BUILTIN_TYPE(klass)) {
422  case T_MODULE:
423  case T_ICLASS:
424  desc = "module";
425  break;
426  case T_CLASS:
427  desc = "class";
428  break;
429  default:
430  goto noclass;
431  }
432  }
433  rb_error_frozen(desc);
434  }
435 }
436 
437 NORETURN(static void rb_longjmp(int, volatile VALUE, VALUE));
438 static VALUE get_errinfo(void);
440 
441 static VALUE
443 {
444 #if SUPPORT_JOKE
445  if (NIL_P(cause)) {
446  ID id_true_cause;
447  CONST_ID(id_true_cause, "true_cause");
448 
449  cause = rb_attr_get(rb_eFatal, id_true_cause);
450  if (NIL_P(cause)) {
451  cause = rb_exc_new_cstr(rb_eFatal, "because using such Ruby");
452  rb_ivar_set(cause, id_cause, INT2FIX(42)); /* the answer */
453  OBJ_FREEZE(cause);
454  rb_ivar_set(rb_eFatal, id_true_cause, cause);
455  }
456  }
457 #endif
458  if (!NIL_P(cause) && cause != exc) {
459  rb_ivar_set(exc, id_cause, cause);
460  if (!rb_ivar_defined(cause, id_cause)) {
461  rb_ivar_set(cause, id_cause, Qnil);
462  }
463  }
464  return exc;
465 }
466 
467 static inline int
469 {
470  return exc == sysstack_error || (!SPECIAL_CONST_P(exc) && RBASIC_CLASS(exc) == rb_eSysStackError);
471 }
472 
473 static inline int
475 {
477  const VALUE *exceptions = th->vm->special_exceptions;
478  for (i = 0; i < ruby_special_error_count; ++i) {
479  if (exceptions[i] == exc) return TRUE;
480  }
481  return FALSE;
482 }
483 
484 static void
485 setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
486 {
487  VALUE e;
488  const char *file = 0;
489  int line;
490  int nocause = 0;
491 
492  if (NIL_P(mesg)) {
493  mesg = th->errinfo;
495  nocause = 1;
496  }
497  if (NIL_P(mesg)) {
498  mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
499  nocause = 0;
500  }
501  else if (special_exception_p(th, mesg)) {
502  mesg = ruby_vm_special_exception_copy(mesg);
503  }
504  if (cause != Qundef) {
505  exc_setup_cause(mesg, cause);
506  }
507  else if (nocause) {
508  exc_setup_cause(mesg, Qnil);
509  }
510  else if (!rb_ivar_defined(mesg, id_cause)) {
512  }
513 
514  file = rb_source_loc(&line);
515  if (file && !NIL_P(mesg)) {
516  VALUE at;
517  if (sysstack_error_p(mesg)) {
518  if (NIL_P(rb_attr_get(mesg, idBt))) {
519  at = rb_vm_backtrace_object();
520  rb_ivar_set(mesg, idBt, at);
521  rb_ivar_set(mesg, idBt_locations, at);
522  }
523  }
524  else {
525  int status;
526 
527  TH_PUSH_TAG(th);
528  if ((status = EXEC_TAG()) == 0) {
529  VALUE bt;
530  if (rb_threadptr_set_raised(th)) goto fatal;
531  bt = rb_get_backtrace(mesg);
532  if (NIL_P(bt)) {
533  at = rb_vm_backtrace_object();
534  if (OBJ_FROZEN(mesg)) {
535  mesg = rb_obj_dup(mesg);
536  }
537  rb_ivar_set(mesg, idBt_locations, at);
538  set_backtrace(mesg, at);
539  }
541  }
542  TH_POP_TAG();
543  }
544  }
545 
546  if (!NIL_P(mesg)) {
547  th->errinfo = mesg;
548  }
549 
550  if (RTEST(ruby_debug) && !NIL_P(e = th->errinfo) &&
552  int status;
553 
554  mesg = e;
555  TH_PUSH_TAG(th);
556  if ((status = EXEC_TAG()) == 0) {
557  th->errinfo = Qnil;
558  e = rb_obj_as_string(mesg);
559  th->errinfo = mesg;
560  if (file && line) {
561  e = rb_sprintf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
562  rb_obj_class(mesg), file, line, e);
563  }
564  else if (file) {
565  e = rb_sprintf("Exception `%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
566  rb_obj_class(mesg), file, e);
567  }
568  else {
569  e = rb_sprintf("Exception `%"PRIsVALUE"' - %"PRIsVALUE"\n",
570  rb_obj_class(mesg), e);
571  }
572  warn_print_str(e);
573  }
574  TH_POP_TAG();
575  if (status == TAG_FATAL && th->errinfo == exception_error) {
576  th->errinfo = mesg;
577  }
578  else if (status) {
580  TH_JUMP_TAG(th, status);
581  }
582  }
583 
584  if (rb_threadptr_set_raised(th)) {
585  fatal:
586  th->errinfo = exception_error;
588  TH_JUMP_TAG(th, TAG_FATAL);
589  }
590 
591  if (tag != TAG_FATAL) {
593  EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0, 0, mesg);
594  }
595 }
596 
597 void
599 {
600  if (cause == Qundef) {
601  cause = get_thread_errinfo(th);
602  }
603  if (cause != mesg) {
604  rb_ivar_set(mesg, id_cause, cause);
605  }
606 }
607 
608 static void
609 rb_longjmp(int tag, volatile VALUE mesg, VALUE cause)
610 {
611  rb_thread_t *th = GET_THREAD();
612  setup_exception(th, tag, mesg, cause);
614  TH_JUMP_TAG(th, tag);
615 }
616 
617 static VALUE make_exception(int argc, const VALUE *argv, int isstr);
618 
619 void
621 {
622  if (!NIL_P(mesg)) {
623  mesg = make_exception(1, &mesg, FALSE);
624  }
625  rb_longjmp(TAG_RAISE, mesg, Qundef);
626 }
627 
628 void
630 {
631  if (!NIL_P(mesg)) {
632  mesg = make_exception(1, &mesg, FALSE);
633  }
634  rb_longjmp(TAG_FATAL, mesg, Qnil);
635 }
636 
637 void
639 {
640  rb_raise(rb_eInterrupt, "%s", "");
641 }
642 
644 
645 static int
646 extract_raise_opts(int argc, const VALUE *argv, VALUE *opts)
647 {
648  int i;
649  if (argc > 0) {
650  VALUE opt = argv[argc-1];
651  if (RB_TYPE_P(opt, T_HASH)) {
652  if (!RHASH_EMPTY_P(opt)) {
653  ID keywords[1];
654  CONST_ID(keywords[0], "cause");
655  rb_get_kwargs(opt, keywords, 0, -1-raise_max_opt, opts);
656  if (RHASH_EMPTY_P(opt)) --argc;
657  return argc;
658  }
659  }
660  }
661  for (i = 0; i < raise_max_opt; ++i) {
662  opts[i] = Qundef;
663  }
664  return argc;
665 }
666 
667 /*
668  * call-seq:
669  * raise
670  * raise(string)
671  * raise(exception [, string [, array]])
672  * fail
673  * fail(string)
674  * fail(exception [, string [, array]])
675  *
676  * With no arguments, raises the exception in <code>$!</code> or raises
677  * a <code>RuntimeError</code> if <code>$!</code> is +nil+.
678  * With a single +String+ argument, raises a
679  * +RuntimeError+ with the string as a message. Otherwise,
680  * the first parameter should be the name of an +Exception+
681  * class (or an object that returns an +Exception+ object when sent
682  * an +exception+ message). The optional second parameter sets the
683  * message associated with the exception, and the third parameter is an
684  * array of callback information. Exceptions are caught by the
685  * +rescue+ clause of <code>begin...end</code> blocks.
686  *
687  * raise "Failed to create socket"
688  * raise ArgumentError, "No parameters", caller
689  */
690 
691 static VALUE
692 rb_f_raise(int argc, VALUE *argv)
693 {
694  VALUE err;
695  VALUE opts[raise_max_opt], *const cause = &opts[raise_opt_cause];
696 
697  argc = extract_raise_opts(argc, argv, opts);
698  if (argc == 0) {
699  if (*cause != Qundef) {
700  rb_raise(rb_eArgError, "only cause is given with no arguments");
701  }
702  err = get_errinfo();
703  if (!NIL_P(err)) {
704  argc = 1;
705  argv = &err;
706  }
707  }
708  rb_raise_jump(rb_make_exception(argc, argv), *cause);
709 
710  UNREACHABLE;
711 }
712 
713 static VALUE
714 make_exception(int argc, const VALUE *argv, int isstr)
715 {
716  VALUE mesg, exc;
717  int n;
718 
719  mesg = Qnil;
720  switch (argc) {
721  case 0:
722  break;
723  case 1:
724  exc = argv[0];
725  if (NIL_P(exc))
726  break;
727  if (isstr) {
728  mesg = rb_check_string_type(exc);
729  if (!NIL_P(mesg)) {
730  mesg = rb_exc_new3(rb_eRuntimeError, mesg);
731  break;
732  }
733  }
734  n = 0;
735  goto exception_call;
736 
737  case 2:
738  case 3:
739  exc = argv[0];
740  n = 1;
741  exception_call:
742  if (sysstack_error_p(exc)) return exc;
743  mesg = rb_check_funcall(exc, idException, n, argv+1);
744  if (mesg == Qundef) {
745  rb_raise(rb_eTypeError, "exception class/object expected");
746  }
747  break;
748  default:
749  rb_check_arity(argc, 0, 3);
750  break;
751  }
752  if (argc > 0) {
753  if (!rb_obj_is_kind_of(mesg, rb_eException))
754  rb_raise(rb_eTypeError, "exception object expected");
755  if (argc > 2)
756  set_backtrace(mesg, argv[2]);
757  }
758 
759  return mesg;
760 }
761 
762 VALUE
763 rb_make_exception(int argc, const VALUE *argv)
764 {
765  return make_exception(argc, argv, TRUE);
766 }
767 
768 void
770 {
771  rb_thread_t *th = GET_THREAD();
772  const rb_control_frame_t *cfp = th->cfp;
774  VALUE klass = me->owner;
775  VALUE self = cfp->self;
776  ID mid = me->called_id;
777 
778  rb_vm_pop_frame(th);
779  EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, me->def->original_id, mid, klass, Qnil);
780 
781  setup_exception(th, TAG_RAISE, mesg, cause);
782 
784  TH_JUMP_TAG(th, TAG_RAISE);
785 }
786 
787 void
788 rb_jump_tag(int tag)
789 {
790  if (UNLIKELY(tag < TAG_RETURN || tag > TAG_FATAL)) {
792  }
793  JUMP_TAG(tag);
794 }
795 
796 int
798 {
799  rb_thread_t *th = GET_THREAD();
801  return FALSE;
802  }
803  else {
804  return TRUE;
805  }
806 }
807 
808 int
810 {
811  return rb_block_given_p();
812 }
813 
815 
816 void
818 {
819  if (!rb_block_given_p()) {
820  rb_vm_localjump_error("no block given", Qnil, 0);
821  }
822 }
823 
824 VALUE
825 rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
826  VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
827 {
828  int state;
829  rb_thread_t *th = GET_THREAD();
830  rb_control_frame_t *volatile cfp = th->cfp;
831  volatile VALUE result = Qfalse;
832  volatile VALUE e_info = th->errinfo;
833  va_list args;
834 
835  TH_PUSH_TAG(th);
836  if ((state = TH_EXEC_TAG()) == 0) {
837  retry_entry:
838  result = (*b_proc) (data1);
839  }
840  else if (result) {
841  /* escape from r_proc */
842  if (state == TAG_RETRY) {
843  state = 0;
844  th->errinfo = Qnil;
845  result = Qfalse;
846  goto retry_entry;
847  }
848  }
849  else {
850  rb_vm_rewind_cfp(th, cfp);
851 
852  if (state == TAG_RAISE) {
853  int handle = FALSE;
854  VALUE eclass;
855 
856  va_init_list(args, data2);
857  while ((eclass = va_arg(args, VALUE)) != 0) {
858  if (rb_obj_is_kind_of(th->errinfo, eclass)) {
859  handle = TRUE;
860  break;
861  }
862  }
863  va_end(args);
864 
865  if (handle) {
866  result = Qnil;
867  state = 0;
868  if (r_proc) {
869  result = (*r_proc) (data2, th->errinfo);
870  }
871  th->errinfo = e_info;
872  }
873  }
874  }
875  TH_POP_TAG();
876  if (state)
877  TH_JUMP_TAG(th, state);
878 
879  return result;
880 }
881 
882 VALUE
883 rb_rescue(VALUE (* b_proc)(ANYARGS), VALUE data1,
884  VALUE (* r_proc)(ANYARGS), VALUE data2)
885 {
886  return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError,
887  (VALUE)0);
888 }
889 
890 VALUE
891 rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
892 {
893  volatile VALUE result = Qnil;
894  volatile int status;
895  rb_thread_t *th = GET_THREAD();
896  rb_control_frame_t *volatile cfp = th->cfp;
897  struct rb_vm_protect_tag protect_tag;
898  rb_jmpbuf_t org_jmpbuf;
899 
900  protect_tag.prev = th->protect_tag;
901 
902  TH_PUSH_TAG(th);
903  th->protect_tag = &protect_tag;
904  MEMCPY(&org_jmpbuf, &(th)->root_jmpbuf, rb_jmpbuf_t, 1);
905  if ((status = TH_EXEC_TAG()) == 0) {
906  SAVE_ROOT_JMPBUF(th, result = (*proc) (data));
907  }
908  else {
909  rb_vm_rewind_cfp(th, cfp);
910  }
911  MEMCPY(&(th)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1);
912  th->protect_tag = protect_tag.prev;
913  TH_POP_TAG();
914 
915  if (state) {
916  *state = status;
917  }
918 
919  return result;
920 }
921 
922 VALUE
923 rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE data2)
924 {
925  int state;
926  volatile VALUE result = Qnil;
927  VALUE errinfo;
928  rb_thread_t *const th = GET_THREAD();
929  rb_ensure_list_t ensure_list;
930  ensure_list.entry.marker = 0;
931  ensure_list.entry.e_proc = e_proc;
932  ensure_list.entry.data2 = data2;
933  ensure_list.next = th->ensure_list;
934  th->ensure_list = &ensure_list;
935  TH_PUSH_TAG(th);
936  if ((state = EXEC_TAG()) == 0) {
937  result = (*b_proc) (data1);
938  }
939  TH_POP_TAG();
940  errinfo = th->errinfo;
941  if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) {
942  th->errinfo = Qnil;
943  }
944  th->ensure_list=ensure_list.next;
945  (*ensure_list.entry.e_proc)(ensure_list.entry.data2);
946  th->errinfo = errinfo;
947  if (state)
948  TH_JUMP_TAG(th, state);
949  return result;
950 }
951 
952 static ID
954 {
956 
957  if (me) {
958  return me->def->original_id;
959  }
960  else {
961  return 0;
962  }
963 }
964 
965 static ID
967 {
969 
970  if (me) {
971  return me->called_id;
972  }
973  else {
974  return 0;
975  }
976 }
977 
978 ID
980 {
981  return frame_func_id(GET_THREAD()->cfp);
982 }
983 
984 ID
986 {
987  return frame_called_id(GET_THREAD()->cfp);
988 }
989 
990 static rb_control_frame_t *
992 {
994  /* check if prev_cfp can be accessible */
995  if ((void *)(th->stack + th->stack_size) == (void *)(prev_cfp)) {
996  return 0;
997  }
998  return prev_cfp;
999 }
1000 
1001 static ID
1003 {
1005  if (!prev_cfp) return 0;
1006  return frame_called_id(prev_cfp);
1007 }
1008 
1009 static ID
1011 {
1013  if (!prev_cfp) return 0;
1014  return frame_func_id(prev_cfp);
1015 }
1016 
1017 ID
1019 {
1020  rb_thread_t *th = GET_THREAD();
1021  rb_control_frame_t *cfp = th->cfp;
1022  ID mid;
1023 
1024  while (!(mid = frame_func_id(cfp)) &&
1025  (cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp),
1027  return mid;
1028 }
1029 
1030 /*
1031  * call-seq:
1032  * append_features(mod) -> mod
1033  *
1034  * When this module is included in another, Ruby calls
1035  * <code>append_features</code> in this module, passing it the
1036  * receiving module in _mod_. Ruby's default implementation is
1037  * to add the constants, methods, and module variables of this module
1038  * to _mod_ if this module has not already been added to
1039  * _mod_ or one of its ancestors. See also <code>Module#include</code>.
1040  */
1041 
1042 static VALUE
1044 {
1045  if (!CLASS_OR_MODULE_P(include)) {
1046  Check_Type(include, T_CLASS);
1047  }
1048  rb_include_module(include, module);
1049 
1050  return module;
1051 }
1052 
1053 /*
1054  * call-seq:
1055  * include(module, ...) -> self
1056  *
1057  * Invokes <code>Module.append_features</code> on each parameter in reverse order.
1058  */
1059 
1060 static VALUE
1061 rb_mod_include(int argc, VALUE *argv, VALUE module)
1062 {
1063  int i;
1064  ID id_append_features, id_included;
1065 
1066  CONST_ID(id_append_features, "append_features");
1067  CONST_ID(id_included, "included");
1068 
1070  for (i = 0; i < argc; i++)
1071  Check_Type(argv[i], T_MODULE);
1072  while (argc--) {
1073  rb_funcall(argv[argc], id_append_features, 1, module);
1074  rb_funcall(argv[argc], id_included, 1, module);
1075  }
1076  return module;
1077 }
1078 
1079 /*
1080  * call-seq:
1081  * prepend_features(mod) -> mod
1082  *
1083  * When this module is prepended in another, Ruby calls
1084  * <code>prepend_features</code> in this module, passing it the
1085  * receiving module in _mod_. Ruby's default implementation is
1086  * to overlay the constants, methods, and module variables of this module
1087  * to _mod_ if this module has not already been added to
1088  * _mod_ or one of its ancestors. See also <code>Module#prepend</code>.
1089  */
1090 
1091 static VALUE
1093 {
1094  if (!CLASS_OR_MODULE_P(prepend)) {
1095  Check_Type(prepend, T_CLASS);
1096  }
1097  rb_prepend_module(prepend, module);
1098 
1099  return module;
1100 }
1101 
1102 /*
1103  * call-seq:
1104  * prepend(module, ...) -> self
1105  *
1106  * Invokes <code>Module.prepend_features</code> on each parameter in reverse order.
1107  */
1108 
1109 static VALUE
1110 rb_mod_prepend(int argc, VALUE *argv, VALUE module)
1111 {
1112  int i;
1113  ID id_prepend_features, id_prepended;
1114 
1115  CONST_ID(id_prepend_features, "prepend_features");
1116  CONST_ID(id_prepended, "prepended");
1117 
1119  for (i = 0; i < argc; i++)
1120  Check_Type(argv[i], T_MODULE);
1121  while (argc--) {
1122  rb_funcall(argv[argc], id_prepend_features, 1, module);
1123  rb_funcall(argv[argc], id_prepended, 1, module);
1124  }
1125  return module;
1126 }
1127 
1128 static void
1130 {
1131  if (!RB_TYPE_P(obj, T_CLASS) && !RB_TYPE_P(obj, T_MODULE)) {
1133  "wrong argument type %"PRIsVALUE" (expected Class or Module)",
1134  rb_obj_class(obj));
1135  }
1136 }
1137 
1138 static VALUE
1140 {
1142 
1143  RBASIC_CLEAR_CLASS(hash); /* hide from ObjectSpace */
1144  return hash;
1145 }
1146 
1147 void
1149 {
1150  VALUE iclass, c, superclass = klass;
1151 
1152  ensure_class_or_module(klass);
1153  Check_Type(module, T_MODULE);
1154  if (NIL_P(CREF_REFINEMENTS(cref))) {
1156  }
1157  else {
1158  if (CREF_OMOD_SHARED(cref)) {
1160  CREF_OMOD_SHARED_UNSET(cref);
1161  }
1162  if (!NIL_P(c = rb_hash_lookup(CREF_REFINEMENTS(cref), klass))) {
1163  superclass = c;
1164  while (c && RB_TYPE_P(c, T_ICLASS)) {
1165  if (RBASIC(c)->klass == module) {
1166  /* already used refinement */
1167  return;
1168  }
1169  c = RCLASS_SUPER(c);
1170  }
1171  }
1172  }
1173  FL_SET(module, RMODULE_IS_OVERLAID);
1174  c = iclass = rb_include_class_new(module, superclass);
1175  RCLASS_REFINED_CLASS(c) = klass;
1176 
1178  RCLASS_M_TBL(OBJ_WB_UNPROTECT(module)); /* TODO: check unprotecting */
1179 
1180  module = RCLASS_SUPER(module);
1181  while (module && module != klass) {
1182  FL_SET(module, RMODULE_IS_OVERLAID);
1184  RCLASS_REFINED_CLASS(c) = klass;
1185  module = RCLASS_SUPER(module);
1186  }
1187  rb_hash_aset(CREF_REFINEMENTS(cref), klass, iclass);
1188 }
1189 
1190 static int
1191 using_refinement(VALUE klass, VALUE module, VALUE arg)
1192 {
1193  rb_cref_t *cref = (rb_cref_t *) arg;
1194 
1195  rb_using_refinement(cref, klass, module);
1196  return ST_CONTINUE;
1197 }
1198 
1199 static void
1201 {
1202  ID id_refinements;
1203  VALUE super, module, refinements;
1204 
1205  super = RCLASS_SUPER(klass);
1206  if (super) {
1207  using_module_recursive(cref, super);
1208  }
1209  switch (BUILTIN_TYPE(klass)) {
1210  case T_MODULE:
1211  module = klass;
1212  break;
1213 
1214  case T_ICLASS:
1215  module = RBASIC(klass)->klass;
1216  break;
1217 
1218  default:
1219  rb_raise(rb_eTypeError, "wrong argument type %s (expected Module)",
1220  rb_obj_classname(klass));
1221  break;
1222  }
1223  CONST_ID(id_refinements, "__refinements__");
1224  refinements = rb_attr_get(module, id_refinements);
1225  if (NIL_P(refinements)) return;
1226  rb_hash_foreach(refinements, using_refinement, (VALUE) cref);
1227 }
1228 
1229 void
1230 rb_using_module(const rb_cref_t *cref, VALUE module)
1231 {
1232  Check_Type(module, T_MODULE);
1233  using_module_recursive(cref, module);
1235 }
1236 
1237 VALUE
1239 {
1240  ID id_refined_class;
1241 
1242  CONST_ID(id_refined_class, "__refined_class__");
1243  return rb_attr_get(module, id_refined_class);
1244 }
1245 
1246 static void
1247 add_activated_refinement(VALUE activated_refinements,
1248  VALUE klass, VALUE refinement)
1249 {
1250  VALUE iclass, c, superclass = klass;
1251 
1252  if (!NIL_P(c = rb_hash_lookup(activated_refinements, klass))) {
1253  superclass = c;
1254  while (c && RB_TYPE_P(c, T_ICLASS)) {
1255  if (RBASIC(c)->klass == refinement) {
1256  /* already used refinement */
1257  return;
1258  }
1259  c = RCLASS_SUPER(c);
1260  }
1261  }
1262  FL_SET(refinement, RMODULE_IS_OVERLAID);
1263  c = iclass = rb_include_class_new(refinement, superclass);
1264  RCLASS_REFINED_CLASS(c) = klass;
1265  refinement = RCLASS_SUPER(refinement);
1266  while (refinement && refinement != klass) {
1267  FL_SET(refinement, RMODULE_IS_OVERLAID);
1268  c = RCLASS_SET_SUPER(c, rb_include_class_new(refinement, RCLASS_SUPER(c)));
1269  RCLASS_REFINED_CLASS(c) = klass;
1270  refinement = RCLASS_SUPER(refinement);
1271  }
1272  rb_hash_aset(activated_refinements, klass, iclass);
1273 }
1274 
1275 /*
1276  * call-seq:
1277  * refine(mod) { block } -> module
1278  *
1279  * Refine <i>mod</i> in the receiver.
1280  *
1281  * Returns a module, where refined methods are defined.
1282  */
1283 
1284 static VALUE
1285 rb_mod_refine(VALUE module, VALUE klass)
1286 {
1287  VALUE refinement;
1288  ID id_refinements, id_activated_refinements,
1289  id_refined_class, id_defined_at;
1290  VALUE refinements, activated_refinements;
1291  rb_thread_t *th = GET_THREAD();
1292  VALUE block_handler = rb_vm_frame_block_handler(th->cfp);
1293 
1294  if (block_handler == VM_BLOCK_HANDLER_NONE) {
1295  rb_raise(rb_eArgError, "no block given");
1296  }
1297  if (vm_block_handler_type(block_handler) != block_handler_type_iseq) {
1298  rb_raise(rb_eArgError, "can't pass a Proc as a block to Module#refine");
1299  }
1300 
1301  ensure_class_or_module(klass);
1302  CONST_ID(id_refinements, "__refinements__");
1303  refinements = rb_attr_get(module, id_refinements);
1304  if (NIL_P(refinements)) {
1305  refinements = hidden_identity_hash_new();
1306  rb_ivar_set(module, id_refinements, refinements);
1307  }
1308  CONST_ID(id_activated_refinements, "__activated_refinements__");
1309  activated_refinements = rb_attr_get(module, id_activated_refinements);
1310  if (NIL_P(activated_refinements)) {
1311  activated_refinements = hidden_identity_hash_new();
1312  rb_ivar_set(module, id_activated_refinements,
1313  activated_refinements);
1314  }
1315  refinement = rb_hash_lookup(refinements, klass);
1316  if (NIL_P(refinement)) {
1317  refinement = rb_module_new();
1318  RCLASS_SET_SUPER(refinement, klass);
1319  FL_SET(refinement, RMODULE_IS_REFINEMENT);
1320  CONST_ID(id_refined_class, "__refined_class__");
1321  rb_ivar_set(refinement, id_refined_class, klass);
1322  CONST_ID(id_defined_at, "__defined_at__");
1323  rb_ivar_set(refinement, id_defined_at, module);
1324  rb_hash_aset(refinements, klass, refinement);
1325  add_activated_refinement(activated_refinements, klass, refinement);
1326  }
1327  rb_yield_refine_block(refinement, activated_refinements);
1328  return refinement;
1329 }
1330 
1331 static void
1332 ignored_block(VALUE module, const char *klass)
1333 {
1334  const char *anon = "";
1335  if (!RTEST(rb_search_class_path(module))) {
1336  anon = ", maybe for Module.new";
1337  }
1338  rb_warn("%s""using doesn't call the given block""%s.", klass, anon);
1339 }
1340 
1341 /*
1342  * call-seq:
1343  * using(module) -> self
1344  *
1345  * Import class refinements from <i>module</i> into the current class or
1346  * module definition.
1347  */
1348 
1349 static VALUE
1350 mod_using(VALUE self, VALUE module)
1351 {
1353 
1354  if (prev_frame_func()) {
1356  "Module#using is not permitted in methods");
1357  }
1358  if (prev_cfp && prev_cfp->self != self) {
1359  rb_raise(rb_eRuntimeError, "Module#using is not called on self");
1360  }
1361  if (rb_block_given_p()) {
1362  ignored_block(module, "Module#");
1363  }
1365  return self;
1366 }
1367 
1368 static int
1370 {
1371  ID id_defined_at;
1372  CONST_ID(id_defined_at, "__defined_at__");
1373  while (FL_TEST(rb_class_of(mod), RMODULE_IS_REFINEMENT)) {
1374  rb_ary_push(ary, rb_attr_get(rb_class_of(mod), id_defined_at));
1375  mod = RCLASS_SUPER(mod);
1376  }
1377  return ST_CONTINUE;
1378 }
1379 
1380 /*
1381  * call-seq:
1382  * used_modules -> array
1383  *
1384  * Returns an array of all modules used in the current scope. The ordering
1385  * of modules in the resulting array is not defined.
1386  *
1387  * module A
1388  * refine Object do
1389  * end
1390  * end
1391  *
1392  * module B
1393  * refine Object do
1394  * end
1395  * end
1396  *
1397  * using A
1398  * using B
1399  * p Module.used_modules
1400  *
1401  * <em>produces:</em>
1402  *
1403  * [B, A]
1404  */
1405 static VALUE
1407 {
1408  const rb_cref_t *cref = rb_vm_cref();
1409  VALUE ary = rb_ary_new();
1410 
1411  while(cref) {
1412  if(!NIL_P(CREF_REFINEMENTS(cref))) {
1414  }
1415  cref = CREF_NEXT(cref);
1416  }
1417 
1418  return rb_funcall(ary, rb_intern("uniq"), 0);
1419 }
1420 
1421 void
1422 rb_obj_call_init(VALUE obj, int argc, const VALUE *argv)
1423 {
1425  rb_funcallv(obj, idInitialize, argc, argv);
1426 }
1427 
1428 void
1430 {
1431  rb_include_module(rb_singleton_class(obj), module);
1432 }
1433 
1434 /*
1435  * call-seq:
1436  * extend_object(obj) -> obj
1437  *
1438  * Extends the specified object by adding this module's constants and
1439  * methods (which are added as singleton methods). This is the callback
1440  * method used by <code>Object#extend</code>.
1441  *
1442  * module Picky
1443  * def Picky.extend_object(o)
1444  * if String === o
1445  * puts "Can't add Picky to a String"
1446  * else
1447  * puts "Picky added to #{o.class}"
1448  * super
1449  * end
1450  * end
1451  * end
1452  * (s = Array.new).extend Picky # Call Object.extend
1453  * (s = "quick brown fox").extend Picky
1454  *
1455  * <em>produces:</em>
1456  *
1457  * Picky added to Array
1458  * Can't add Picky to a String
1459  */
1460 
1461 static VALUE
1463 {
1464  rb_extend_object(obj, mod);
1465  return obj;
1466 }
1467 
1468 /*
1469  * call-seq:
1470  * obj.extend(module, ...) -> obj
1471  *
1472  * Adds to _obj_ the instance methods from each module given as a
1473  * parameter.
1474  *
1475  * module Mod
1476  * def hello
1477  * "Hello from Mod.\n"
1478  * end
1479  * end
1480  *
1481  * class Klass
1482  * def hello
1483  * "Hello from Klass.\n"
1484  * end
1485  * end
1486  *
1487  * k = Klass.new
1488  * k.hello #=> "Hello from Klass.\n"
1489  * k.extend(Mod) #=> #<Klass:0x401b3bc8>
1490  * k.hello #=> "Hello from Mod.\n"
1491  */
1492 
1493 static VALUE
1494 rb_obj_extend(int argc, VALUE *argv, VALUE obj)
1495 {
1496  int i;
1497  ID id_extend_object, id_extended;
1498 
1499  CONST_ID(id_extend_object, "extend_object");
1500  CONST_ID(id_extended, "extended");
1501 
1503  for (i = 0; i < argc; i++)
1504  Check_Type(argv[i], T_MODULE);
1505  while (argc--) {
1506  rb_funcall(argv[argc], id_extend_object, 1, obj);
1507  rb_funcall(argv[argc], id_extended, 1, obj);
1508  }
1509  return obj;
1510 }
1511 
1512 /*
1513  * call-seq:
1514  * include(module, ...) -> self
1515  *
1516  * Invokes <code>Module.append_features</code>
1517  * on each parameter in turn. Effectively adds the methods and constants
1518  * in each module to the receiver.
1519  */
1520 
1521 static VALUE
1522 top_include(int argc, VALUE *argv, VALUE self)
1523 {
1524  rb_thread_t *th = GET_THREAD();
1525 
1526  if (th->top_wrapper) {
1527  rb_warning("main.include in the wrapped load is effective only in wrapper module");
1528  return rb_mod_include(argc, argv, th->top_wrapper);
1529  }
1530  return rb_mod_include(argc, argv, rb_cObject);
1531 }
1532 
1533 /*
1534  * call-seq:
1535  * using(module) -> self
1536  *
1537  * Import class refinements from <i>module</i> into the scope where
1538  * <code>using</code> is called.
1539  */
1540 
1541 static VALUE
1542 top_using(VALUE self, VALUE module)
1543 {
1544  const rb_cref_t *cref = rb_vm_cref();
1546 
1547  if (CREF_NEXT(cref) || (prev_cfp && rb_vm_frame_method_entry(prev_cfp))) {
1548  rb_raise(rb_eRuntimeError, "main.using is permitted only at toplevel");
1549  }
1550  if (rb_block_given_p()) {
1551  ignored_block(module, "main.");
1552  }
1554  return self;
1555 }
1556 
1557 static const VALUE *
1559 {
1560  rb_control_frame_t *cfp = th->cfp;
1562 
1563  while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
1564  if (VM_FRAME_RUBYFRAME_P(cfp)) {
1565  if (cfp->iseq->body->type == ISEQ_TYPE_RESCUE) {
1566  return &cfp->ep[VM_ENV_INDEX_LAST_LVAR];
1567  }
1568  else if (cfp->iseq->body->type == ISEQ_TYPE_ENSURE &&
1571  return &cfp->ep[VM_ENV_INDEX_LAST_LVAR];
1572  }
1573  }
1574  cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
1575  }
1576  return 0;
1577 }
1578 
1579 static VALUE
1581 {
1582  const VALUE *ptr = errinfo_place(th);
1583  if (ptr) {
1584  return *ptr;
1585  }
1586  else {
1587  return th->errinfo;
1588  }
1589 }
1590 
1591 static VALUE
1593 {
1594  return get_thread_errinfo(GET_THREAD());
1595 }
1596 
1597 static VALUE
1599 {
1600  return get_errinfo();
1601 }
1602 
1603 #if 0
1604 static void
1605 errinfo_setter(VALUE val, ID id, VALUE *var)
1606 {
1607  if (!NIL_P(val) && !rb_obj_is_kind_of(val, rb_eException)) {
1608  rb_raise(rb_eTypeError, "assigning non-exception to $!");
1609  }
1610  else {
1611  const VALUE *ptr = errinfo_place(GET_THREAD());
1612  if (ptr) {
1613  *ptr = val;
1614  }
1615  else {
1616  rb_raise(rb_eRuntimeError, "errinfo_setter: not in rescue clause.");
1617  }
1618  }
1619 }
1620 #endif
1621 
1622 VALUE
1624 {
1625  rb_thread_t *th = GET_THREAD();
1626  return th->errinfo;
1627 }
1628 
1629 void
1631 {
1632  if (!NIL_P(err) && !rb_obj_is_kind_of(err, rb_eException)) {
1633  rb_raise(rb_eTypeError, "assigning non-exception to $!");
1634  }
1635  GET_THREAD()->errinfo = err;
1636 }
1637 
1638 VALUE
1640 {
1641  return get_errinfo();
1642 }
1643 
1644 static VALUE
1646 {
1647  VALUE err = get_errinfo();
1648  if (!NIL_P(err)) {
1649  return rb_get_backtrace(err);
1650  }
1651  else {
1652  return Qnil;
1653  }
1654 }
1655 
1656 static void
1657 errat_setter(VALUE val, ID id, VALUE *var)
1658 {
1659  VALUE err = get_errinfo();
1660  if (NIL_P(err)) {
1661  rb_raise(rb_eArgError, "$! not set");
1662  }
1663  set_backtrace(err, val);
1664 }
1665 
1666 /*
1667  * call-seq:
1668  * __method__ -> symbol
1669  *
1670  * Returns the name at the definition of the current method as a
1671  * Symbol.
1672  * If called outside of a method, it returns <code>nil</code>.
1673  *
1674  */
1675 
1676 static VALUE
1678 {
1679  ID fname = prev_frame_func(); /* need *method* ID */
1680 
1681  if (fname) {
1682  return ID2SYM(fname);
1683  }
1684  else {
1685  return Qnil;
1686  }
1687 }
1688 
1689 /*
1690  * call-seq:
1691  * __callee__ -> symbol
1692  *
1693  * Returns the called name of the current method as a Symbol.
1694  * If called outside of a method, it returns <code>nil</code>.
1695  *
1696  */
1697 
1698 static VALUE
1700 {
1701  ID fname = prev_frame_callee(); /* need *callee* ID */
1702 
1703  if (fname) {
1704  return ID2SYM(fname);
1705  }
1706  else {
1707  return Qnil;
1708  }
1709 }
1710 
1711 /*
1712  * call-seq:
1713  * __dir__ -> string
1714  *
1715  * Returns the canonicalized absolute path of the directory of the file from
1716  * which this method is called. It means symlinks in the path is resolved.
1717  * If <code>__FILE__</code> is <code>nil</code>, it returns <code>nil</code>.
1718  * The return value equals to <code>File.dirname(File.realpath(__FILE__))</code>.
1719  *
1720  */
1721 static VALUE
1723 {
1724  VALUE base = rb_current_realfilepath();
1725  if (NIL_P(base)) {
1726  return Qnil;
1727  }
1728  base = rb_file_dirname(base);
1729  return base;
1730 }
1731 
1732 void
1734 {
1737 
1738  rb_define_global_function("raise", rb_f_raise, -1);
1740 
1741  rb_define_global_function("global_variables", rb_f_global_variables, 0); /* in variable.c */
1742 
1743  rb_define_global_function("__method__", rb_f_method_name, 0);
1744  rb_define_global_function("__callee__", rb_f_callee_name, 0);
1746 
1747  rb_define_method(rb_cModule, "include", rb_mod_include, -1);
1748  rb_define_method(rb_cModule, "prepend", rb_mod_prepend, -1);
1749 
1755  rb_define_singleton_method(rb_cModule, "used_modules",
1757  rb_undef_method(rb_cClass, "refine");
1758 
1759  rb_undef_method(rb_cClass, "module_function");
1760 
1761  Init_vm_eval();
1762  Init_eval_method();
1763 
1766 
1768  "include", top_include, -1);
1770  "using", top_using, 1);
1771 
1772  rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
1773 
1774  rb_define_global_function("trace_var", rb_f_trace_var, -1); /* in variable.c */
1775  rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
1776 
1778 
1779  id_signo = rb_intern_const("signo");
1780  id_status = rb_intern_const("status");
1781  id_cause = rb_intern_const("cause");
1782 }
#define RBASIC_CLEAR_CLASS(obj)
Definition: internal.h:1312
static void ruby_finalize_0(void)
Definition: eval.c:115
int ruby_run_node(void *n)
Runs the given compiled source and exits this process.
Definition: eval.c:293
rb_control_frame_t * cfp
Definition: vm_core.h:708
void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
Definition: thread.c:455
#define T_OBJECT
Definition: ruby.h:491
VALUE rb_eStandardError
Definition: error.c:760
VALUE rb_eLocalJumpError
Definition: eval.c:24
#define RUBY_VM_CHECK_INTS(th)
Definition: vm_core.h:1569
const VALUE * ep
Definition: vm_core.h:636
rb_vm_t * vm
Definition: vm_core.h:703
VALUE rb_exc_new(VALUE etype, const char *ptr, long len)
Definition: error.c:797
int ruby_cleanup(volatile int ex)
Destructs the VM.
Definition: eval.c:159
struct rb_ensure_entry entry
Definition: vm_core.h:693
VALUE rb_vm_backtrace_object(void)
Definition: vm_backtrace.c:530
void rb_call_inits(void)
Definition: inits.c:17
void rb_interrupt(void)
Definition: eval.c:638
#define RUBY_EVENT_C_RETURN
Definition: ruby.h:2065
#define FALSE
Definition: nkf.h:174
static VALUE rb_f_raise(int argc, VALUE *argv)
Definition: eval.c:692
struct rb_vm_protect_tag * protect_tag
Definition: vm_core.h:770
#define va_init_list(a, b)
Definition: win32ole.h:34
static void using_module_recursive(const rb_cref_t *cref, VALUE klass)
Definition: eval.c:1200
#define INTERNAL_EXCEPTION_P(exc)
Definition: eval_intern.h:190
VALUE rb_make_exception(int argc, const VALUE *argv)
Definition: eval.c:763
#define VM_ENV_INDEX_LAST_LVAR
Definition: vm_core.h:996
ID ruby_static_id_signo
Definition: eval.c:27
VALUE rb_eSignal
Definition: error.c:758
void ruby_finalize(void)
Runs the VM finalization processes.
Definition: eval.c:142
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
Definition: variable.c:647
VALUE rb_hash_dup(VALUE hash)
Definition: hash.c:457
static int extract_raise_opts(int argc, const VALUE *argv, VALUE *opts)
Definition: eval.c:646
#define NUM2INT(x)
Definition: ruby.h:684
VALUE rb_errinfo(void)
Definition: eval.c:1623
const VALUE owner
Definition: method.h:63
static unsigned int hash(str, len) register const char *str
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
Definition: class.c:1716
static VALUE exc_setup_cause(VALUE exc, VALUE cause)
Definition: eval.c:442
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
Definition: vm_core.h:1172
void Init_BareVM(void)
Definition: vm.c:3107
static int special_exception_p(rb_thread_t *th, VALUE exc)
Definition: eval.c:474
VALUE rb_iseq_eval_main(const rb_iseq_t *iseq)
Definition: vm.c:2014
#define T_MODULE
Definition: ruby.h:494
#define RUBY_EVENT_RAISE
Definition: ruby.h:2066
void * ruby_options(int argc, char **argv)
Processes command line arguments and compiles the Ruby source to execute.
Definition: eval.c:95
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
Definition: class.c:1858
#define Qtrue
Definition: ruby.h:437
VALUE rb_current_realfilepath(void)
Definition: vm_eval.c:2199
static int used_modules_i(VALUE _, VALUE mod, VALUE ary)
Definition: eval.c:1369
void rb_error_frozen(const char *what)
Definition: error.c:2447
void rb_exec_end_proc(void)
Definition: eval_jump.c:114
struct rb_method_definition_struct *const def
Definition: method.h:61
static int CREF_PUSHED_BY_EVAL(const rb_cref_t *cref)
Definition: eval_intern.h:228
#define CLASS_OR_MODULE_P(obj)
Definition: eval.c:37
Definition: st.h:99
const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
VALUE rb_refinement_module_get_refined_class(VALUE module)
Definition: eval.c:1238
static int sysstack_error_p(VALUE exc)
Definition: eval.c:468
static void set_backtrace(VALUE info, VALUE bt)
Definition: eval_error.c:53
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1527
VALUE data2
Definition: vm_core.h:688
ID rb_frame_this_func(void)
Definition: eval.c:979
#define sysstack_error
Definition: vm_core.h:1486
static VALUE hidden_identity_hash_new(void)
Definition: eval.c:1139
VALUE rb_eTypeError
Definition: error.c:762
#define TH_JUMP_TAG(th, st)
Definition: eval_intern.h:186
static int sysexit_status(VALUE err)
Definition: eval_error.c:240
static VALUE rb_mod_include(int argc, VALUE *argv, VALUE module)
Definition: eval.c:1061
#define rb_check_arity
Definition: intern.h:303
int ruby_exec_node(void *n)
Runs the given compiled source.
Definition: eval.c:305
#define UNREACHABLE
Definition: ruby.h:46
static ID frame_func_id(rb_control_frame_t *cfp)
Definition: eval.c:953
VALUE rb_ary_push(VALUE ary, VALUE item)
Definition: array.c:905
#define VM_BLOCK_HANDLER_NONE
Definition: vm_core.h:1070
static void rb_longjmp(int tag, volatile VALUE mesg, VALUE cause)
Definition: eval.c:609
struct rb_iseq_constant_body * body
Definition: vm_core.h:395
static void add_activated_refinement(VALUE activated_refinements, VALUE klass, VALUE refinement)
Definition: eval.c:1247
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
#define STACK_UPPER(x, a, b)
Definition: gc.h:77
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
Definition: eval.c:891
#define Check_Type(v, t)
Definition: ruby.h:562
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2207
struct rb_vm_protect_tag * prev
Definition: vm_core.h:670
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1260
void Init_vm_eval(void)
Definition: vm_eval.c:2209
void Init_vm_objects(void)
Definition: vm.c:3130
#define TH_EXEC_TAG()
Definition: eval_intern.h:180
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Definition: object.c:690
#define T_HASH
Definition: ruby.h:499
void Init_heap(void)
Definition: gc.c:2323
static VALUE mod_using(VALUE self, VALUE module)
Definition: eval.c:1350
void rb_vm_localjump_error(const char *mesg, VALUE value, int reason)
Definition: vm.c:1392
void rb_include_module(VALUE klass, VALUE module)
Definition: class.c:864
static VALUE CREF_REFINEMENTS(const rb_cref_t *cref)
Definition: eval_intern.h:216
VALUE rb_hash_lookup(VALUE hash, VALUE key)
Definition: hash.c:867
#define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)
Definition: vm_core.h:1178
static VALUE errinfo_getter(ID id)
Definition: eval.c:1598
#define PUSH_TAG()
Definition: eval_intern.h:146
static VALUE rb_obj_extend(int argc, VALUE *argv, VALUE obj)
Definition: eval.c:1494
void Init_eval(void)
Definition: eval.c:1733
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
Definition: class.c:1745
#define RUBY_DTRACE_HOOK(name, arg)
Definition: internal.h:1755
static int VM_FRAME_RUBYFRAME_P(const rb_control_frame_t *cfp)
Definition: vm_core.h:1061
#define FIXNUM_P(f)
Definition: ruby.h:365
#define ATOMIC_VALUE_EXCHANGE(var, val)
Definition: ruby_atomic.h:206
const char * rb_source_loc(int *pline)
Definition: vm.c:1291
void rb_undef_method(VALUE klass, const char *name)
Definition: class.c:1533
VALUE rb_ivar_defined(VALUE, ID)
Definition: variable.c:1421
VALUE rb_rubylevel_errinfo(void)
Definition: eval.c:1639
ID rb_frame_last_func(void)
Definition: eval.c:1018
void rb_thread_terminate_all(void)
Definition: thread.c:472
void rb_using_module(const rb_cref_t *cref, VALUE module)
Definition: eval.c:1230
const char * rb_obj_classname(VALUE)
Definition: variable.c:458
static void CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
Definition: eval_intern.h:252
static VALUE rb_class_of(VALUE obj)
Definition: ruby.h:1953
#define THROW_DATA_P(err)
Definition: internal.h:787
#define GET_THREAD()
Definition: vm_core.h:1513
int rb_iterator_p(void)
Definition: eval.c:809
void rb_hash_foreach(VALUE hash, int(*func)(ANYARGS), VALUE farg)
Definition: hash.c:402
void rb_exc_raise(VALUE mesg)
Definition: eval.c:620
#define FL_SINGLETON
Definition: ruby.h:1215
void rb_prepend_module(VALUE klass, VALUE module)
Definition: class.c:973
VALUE * stack
Definition: vm_core.h:706
VALUE rb_obj_dup(VALUE)
Definition: object.c:437
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
Definition: class.c:1689
#define id_signo
Definition: eval.c:29
#define RB_TYPE_P(obj, type)
Definition: ruby.h:527
#define TH_POP_TAG()
Definition: eval_intern.h:137
static VALUE rb_f_method_name(void)
Definition: eval.c:1677
#define FL_TEST(x, f)
Definition: ruby.h:1284
static VALUE rb_mod_prepend_features(VALUE module, VALUE prepend)
Definition: eval.c:1092
const rb_iseq_t * iseq
Definition: vm_core.h:634
VALUE rb_rescue(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2)
Definition: eval.c:883
static ID prev_frame_callee(void)
Definition: eval.c:1002
static VALUE f_current_dirname(void)
Definition: eval.c:1722
static ID frame_called_id(rb_control_frame_t *cfp)
Definition: eval.c:966
static int error_handle(int ex)
Definition: eval_error.c:250
int rb_block_given_p(void)
Definition: eval.c:797
void * rb_mod_const_at(VALUE, void *)
Definition: variable.c:2457
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:1576
#define EXEC_TAG()
Definition: eval_intern.h:183
int rb_threadptr_set_raised(rb_thread_t *th)
Definition: thread.c:2180
void ruby_init(void)
Definition: eval.c:74
#define val
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:1872
VALUE rb_eRuntimeError
Definition: error.c:761
VALUE rb_eSysStackError
Definition: eval.c:25
VALUE(* e_proc)(ANYARGS)
Definition: vm_core.h:687
VALUE rb_obj_as_string(VALUE)
Definition: string.c:1364
static VALUE rb_mod_s_used_modules(void)
Definition: eval.c:1406
VALUE rb_ary_new(void)
Definition: array.c:493
#define OBJ_WB_UNPROTECT(x)
Definition: ruby.h:1424
#define exception_error
Definition: eval.c:32
RUBY_EXTERN VALUE rb_mKernel
Definition: ruby.h:1860
#define JUMP_TAG(st)
Definition: eval_intern.h:188
#define NIL_P(v)
Definition: ruby.h:451
static VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super)
Definition: internal.h:714
static VALUE rb_mod_prepend(int argc, VALUE *argv, VALUE module)
Definition: eval.c:1110
static VALUE rb_mod_extend_object(VALUE mod, VALUE obj)
Definition: eval.c:1462
void rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module)
Definition: eval.c:1148
#define warn_print_str(x)
Definition: eval_error.c:16
#define OBJ_FROZEN(x)
Definition: ruby.h:1306
void rb_threadptr_check_signal(rb_thread_t *mth)
Definition: thread.c:4032
int argc
Definition: ruby.c:183
void rb_thread_stop_timer_thread(void)
Definition: thread.c:4073
void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE cls, const char *mesg)
Definition: vm.c:2142
char ary[RSTRING_EMBED_LEN_MAX+1]
Definition: ruby.h:972
#define Qfalse
Definition: ruby.h:436
const VALUE special_exceptions[ruby_special_error_count]
Definition: vm_core.h:506
static ID id_cause
Definition: eval.c:28
RUBY_EXTERN VALUE rb_cModule
Definition: ruby.h:1895
Definition: method.h:58
#define MEMCPY(p1, p2, type, n)
Definition: ruby.h:1661
void rb_threadptr_setup_exception(rb_thread_t *th, VALUE mesg, VALUE cause)
Definition: eval.c:598
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
Definition: eval.c:254
int err
Definition: win32.c:135
#define OBJ_FREEZE(x)
Definition: ruby.h:1308
#define EXIT_FAILURE
Definition: eval_intern.h:33
#define POP_TAG()
Definition: eval_intern.h:147
void rb_trap_exit(void)
Definition: signal.c:999
#define numberof(array)
Definition: etc.c:616
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
Definition: vm_eval.c:1635
#define rb_thread_raised_clear(th)
Definition: eval_intern.h:270
#define RCLASS_REFINED_CLASS(c)
Definition: internal.h:694
void rb_need_block(void)
Definition: eval.c:817
rb_cref_t * rb_vm_cref_replace_with_duplicated_cref(void)
Definition: vm.c:1312
void rb_vm_pop_frame(rb_thread_t *th)
#define RCLASS_M_TBL(c)
Definition: internal.h:690
#define TRUE
Definition: nkf.h:175
#define EXIT_SUCCESS
Definition: error.c:32
static VALUE rb_mod_nesting(void)
Definition: eval.c:327
VALUE rb_sprintf(const char *format,...)
Definition: sprintf.c:1440
static rb_cref_t * CREF_NEXT(const rb_cref_t *cref)
Definition: eval_intern.h:204
VALUE rb_include_class_new(VALUE module, VALUE super)
Definition: class.c:818
static ID prev_frame_func(void)
Definition: eval.c:1010
void ruby_prog_init(void)
Defines built-in variables.
Definition: ruby.c:2155
static enum rb_block_handler_type vm_block_handler_type(VALUE block_handler)
Definition: vm_core.h:1254
static VALUE CREF_CLASS(const rb_cref_t *cref)
Definition: eval_intern.h:198
VALUE rb_file_dirname(VALUE fname)
Definition: file.c:4177
static void ruby_finalize_1(void)
Definition: eval.c:127
void * rb_mod_const_of(VALUE, void *)
Definition: variable.c:2470
VALUE rb_ivar_set(VALUE, ID, VALUE)
Definition: variable.c:1364
#define PRIsVALUE
Definition: ruby.h:135
VALUE rb_eInterrupt
Definition: error.c:757
unsigned long ID
Definition: ruby.h:86
#define TAG_FATAL
Definition: vm_core.h:170
#define Qnil
Definition: ruby.h:438
void rb_clear_method_cache_by_class(VALUE)
Definition: vm_method.c:96
VALUE rb_const_list(void *)
Definition: variable.c:2492
static void ensure_class_or_module(VALUE obj)
Definition: eval.c:1129
#define BUILTIN_TYPE(x)
Definition: ruby.h:518
unsigned long VALUE
Definition: ruby.h:85
VALUE rb_vm_top_self(void)
Definition: vm.c:3151
#define SAVE_ROOT_JMPBUF(th, stmt)
Definition: eval_intern.h:121
static VALUE result
Definition: nkf.c:40
VALUE rb_f_trace_var(int, const VALUE *)
Definition: variable.c:687
#define EXEC_EVENT_HOOK(th_, flag_, self_, id_, called_id_, klass_, data_)
Definition: vm_core.h:1628
RUBY_JMP_BUF rb_jmpbuf_t
Definition: vm_core.h:656
int ruby_vm_destruct(ruby_vm_t *vm)
#define RBASIC(obj)
Definition: ruby.h:1204
void rb_extend_object(VALUE obj, VALUE module)
Definition: eval.c:1429
#define id_status
Definition: eval.c:30
int rb_threadptr_reset_raised(rb_thread_t *th)
Definition: thread.c:2190
#define FIX2INT(x)
Definition: ruby.h:686
ID called_id
Definition: method.h:62
static void ignored_block(VALUE module, const char *klass)
Definition: eval.c:1332
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
Definition: eval.c:825
#define TH_PUSH_TAG(th)
Definition: eval_intern.h:131
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
Definition: vm_eval.c:439
void ruby_init_stack(volatile VALUE *)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
Definition: eval.c:923
static void error_print(rb_thread_t *th)
Definition: eval_error.c:70
static VALUE get_errinfo(void)
Definition: eval.c:1592
struct rb_ensure_list * next
Definition: vm_core.h:692
RUBY_EXTERN VALUE rb_cClass
Definition: ruby.h:1878
static int CREF_OMOD_SHARED(const rb_cref_t *cref)
Definition: eval_intern.h:240
void rb_jump_tag(int tag)
Definition: eval.c:788
enum rb_iseq_constant_body::iseq_type type
static const VALUE * errinfo_place(rb_thread_t *th)
Definition: eval.c:1558
#define RUBY_VM_END_CONTROL_FRAME(th)
Definition: vm_core.h:1174
#define _(args)
Definition: dln.h:28
#define rb_funcallv
Definition: console.c:21
VALUE rb_mod_constants(int, const VALUE *, VALUE)
Definition: variable.c:2524
static int ruby_exec_internal(void *n)
Definition: eval.c:234
enum rb_thread_status status
Definition: vm_core.h:738
ruby_special_exceptions
Definition: vm_core.h:426
#define rb_exc_new3
Definition: intern.h:246
static VALUE top_include(int argc, VALUE *argv, VALUE self)
Definition: eval.c:1522
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp)
Definition: vm.c:82
VALUE rb_f_untrace_var(int, const VALUE *)
Definition: variable.c:746
static rb_control_frame_t * previous_frame(rb_thread_t *th)
Definition: eval.c:991
VALUE rb_ident_hash_new(void)
Definition: hash.c:2808
VALUE rb_exc_new_cstr(VALUE etype, const char *s)
Definition: error.c:803
static VALUE top_using(VALUE self, VALUE module)
Definition: eval.c:1542
#define TAG_RETRY
Definition: vm_core.h:166
#define INT2FIX(i)
Definition: ruby.h:232
VALUE top_wrapper
Definition: vm_core.h:727
#define UNLIMITED_ARGUMENTS
Definition: intern.h:44
#define RCLASS_SUPER(c)
Definition: classext.h:16
VALUE rb_module_new(void)
Definition: class.c:749
void * ruby_process_options(int, char **)
Definition: ruby.c:2201
ID rb_frame_callee(void)
Definition: eval.c:985
#define RBASIC_CLASS(obj)
Definition: ruby.h:878
void rb_set_errinfo(VALUE err)
Definition: eval.c:1630
#define ANYARGS
Definition: defines.h:173
VALUE marker
Definition: vm_core.h:686
void ruby_sig_finalize(void)
Definition: signal.c:1405
VALUE rb_check_string_type(VALUE)
Definition: string.c:2164
#define RTEST(v)
Definition: ruby.h:450
VALUE rb_f_global_variables(void)
Definition: variable.c:883
void rb_obj_call_init(VALUE obj, int argc, const VALUE *argv)
Definition: eval.c:1422
#define UNLIKELY(x)
Definition: ffi_common.h:126
rb_ensure_list_t * ensure_list
Definition: vm_core.h:809
#define T_CLASS
Definition: ruby.h:492
void rb_frozen_class_p(VALUE klass)
Definition: eval.c:396
#define ruby_debug
Definition: ruby.h:1793
#define FL_SET(x, f)
Definition: ruby.h:1290
#define ID2SYM(x)
Definition: ruby.h:383
VALUE rb_eFatal
Definition: error.c:759
size_t stack_size
Definition: vm_core.h:707
VALUE rb_get_backtrace(VALUE exc)
Definition: error.c:965
static VALUE rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
Definition: eval.c:366
void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
Definition: vm.c:535
void rb_warning(const char *fmt,...)
Definition: error.c:250
void rb_raise_jump(VALUE mesg, VALUE cause)
Definition: eval.c:769
#define CONST_ID(var, str)
Definition: ruby.h:1743
void rb_gc_call_finalizer_at_exit(void)
Definition: gc.c:2850
#define rb_intern_const(str)
Definition: ruby.h:1756
static VALUE make_exception(int argc, const VALUE *argv, int isstr)
Definition: eval.c:714
#define SPECIAL_CONST_P(x)
Definition: ruby.h:1249
static VALUE get_thread_errinfo(rb_thread_t *th)
Definition: eval.c:1580
static int using_refinement(VALUE klass, VALUE module, VALUE arg)
Definition: eval.c:1191
VALUE ruby_vm_special_exception_copy(VALUE)
Definition: vm_insnhelper.c:25
#define RHASH_EMPTY_P(h)
Definition: ruby.h:1067
#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp)
Definition: vm_core.h:1176
static VALUE rb_mod_append_features(VALUE module, VALUE include)
Definition: eval.c:1043
#define rb_intern(str)
static void setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
Definition: eval.c:485
static void CREF_REFINEMENTS_SET(rb_cref_t *cref, VALUE refs)
Definition: eval_intern.h:222
#define mod(x, y)
Definition: date_strftime.c:28
#define TAG_RAISE
Definition: vm_core.h:168
static VALUE errat_getter(ID id)
Definition: eval.c:1645
void rb_clear_trace_func(void)
Definition: vm_trace.c:214
void rb_exc_fatal(VALUE mesg)
Definition: eval.c:629
VALUE rb_eSystemExit
Definition: error.c:756
#define Qundef
Definition: ruby.h:439
#define T_ICLASS
Definition: ruby.h:493
void ruby_default_signal(int)
Definition: signal.c:360
VALUE rb_search_class_path(VALUE)
Definition: variable.c:336
void rb_threadptr_interrupt(rb_thread_t *th)
Definition: thread.c:426
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1515
ID ruby_static_id_status
Definition: eval.c:27
#define unknown_longjmp_status(status)
Definition: eval_error.c:246
rb_cref_t * rb_vm_cref(void)
Definition: vm.c:1299
void rb_warn(const char *fmt,...)
Definition: error.c:221
VALUE rb_eThreadError
Definition: eval.c:814
VALUE rb_eArgError
Definition: error.c:763
NORETURN(void rb_raise_jump(VALUE, VALUE))
static void errat_setter(VALUE val, ID id, VALUE *var)
Definition: eval.c:1657
int ruby_executable_node(void *n, int *status)
Checks the return value of ruby_options().
Definition: eval.c:272
VALUE rb_attr_get(VALUE, ID)
Definition: variable.c:1273
int ruby_setup(void)
Definition: eval.c:46
char ** argv
Definition: ruby.c:184
static VALUE rb_f_callee_name(void)
Definition: eval.c:1699
#define PASS_PASSED_BLOCK_HANDLER()
Definition: eval_intern.h:24
VALUE rb_eException
Definition: error.c:755
VALUE rb_obj_class(VALUE)
Definition: object.c:229
void Init_eval_method(void)
Definition: vm_method.c:2087
static VALUE rb_mod_refine(VALUE module, VALUE klass)
Definition: eval.c:1285
#define GET_VM()
Definition: vm_core.h:1507