23 #define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
32 #define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
44 static int initialized = 0;
94 void *
volatile iseq = 0;
158 volatile VALUE errs[2];
200 #if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
202 #if EXIT_SUCCESS != 0
205 #if EXIT_FAILURE != 1
212 for (nerr = 0; nerr <
numberof(errs); ++nerr) {
215 if (!
RTEST(err))
continue;
291 if (status) *status = s;
339 while (cref && cref->nd_next) {
340 VALUE klass = cref->nd_clss;
345 cref = cref->nd_next;
385 klass = cref->nd_clss;
393 cref = cref->nd_next;
405 const char *desc =
"something(?!)";
411 switch (
TYPE(klass)) {
433 volatile int line = 0;
445 if (file && !
NIL_P(mesg)) {
714 result = (*b_proc) (data1);
724 while ((eclass = va_arg(args,
VALUE)) != 0) {
736 result = (*r_proc) (data2, th->
errinfo);
808 volatile VALUE errinfo;
813 result = (*b_proc) (data1);
833 while (cfp_limit > cfp) {
834 if (cfp->
iseq == iseq)
852 if (ifunc->nd_aid)
return ifunc->nd_aid;
882 if (ifunc->nd_aid)
return ifunc->nd_aid;
922 if (!prev_cfp)
return 0;
930 if (!prev_cfp)
return 0;
956 switch (
TYPE(include)) {
980 ID id_append_features, id_included;
982 CONST_ID(id_append_features,
"append_features");
985 for (i = 0; i <
argc; i++)
988 rb_funcall(argv[argc], id_append_features, 1, module);
989 rb_funcall(argv[argc], id_included, 1, module);
1009 switch (
TYPE(prepend)) {
1033 ID id_prepend_features, id_prepended;
1035 CONST_ID(id_prepend_features,
"prepend_features");
1036 CONST_ID(id_prepended,
"prepended");
1037 for (i = 0; i <
argc; i++)
1040 rb_funcall(argv[argc], id_prepend_features, 1, module);
1041 rb_funcall(argv[argc], id_prepended, 1, module);
1049 static int warned = 0;
1053 rb_warn(
"Refinements are experimental, and the behavior may change in future versions of Ruby!");
1070 VALUE iclass, c, superclass = klass;
1074 if (
NIL_P(cref->nd_refinements)) {
1079 cref->nd_refinements =
rb_hash_dup(cref->nd_refinements);
1085 if (
RBASIC(c)->klass == module) {
1098 while (module && module != klass) {
1123 CONST_ID(id_refinements,
"__refinements__");
1124 refinements =
rb_attr_get(module, id_refinements);
1125 if (
NIL_P(refinements))
return;
1131 ID id_refined_class;
1133 CONST_ID(id_refined_class,
"__refined_class__");
1141 VALUE iclass, c, superclass = klass;
1146 if (
RBASIC(c)->klass == refinement) {
1157 while (refinement) {
1182 ID id_refinements, id_activated_refinements,
1183 id_refined_class, id_defined_at;
1184 VALUE refinements, activated_refinements;
1194 "can't pass a Proc as a block to Module#refine");
1197 CONST_ID(id_refinements,
"__refinements__");
1198 refinements =
rb_attr_get(module, id_refinements);
1199 if (
NIL_P(refinements)) {
1203 CONST_ID(id_activated_refinements,
"__activated_refinements__");
1204 activated_refinements =
rb_attr_get(module, id_activated_refinements);
1205 if (
NIL_P(activated_refinements)) {
1208 activated_refinements);
1211 if (
NIL_P(refinement)) {
1215 CONST_ID(id_refined_class,
"__refined_class__");
1217 CONST_ID(id_defined_at,
"__defined_at__");
1302 ID id_extend_object, id_extended;
1304 CONST_ID(id_extend_object,
"extend_object");
1308 for (i = 0; i <
argc; i++)
1311 rb_funcall(argv[argc], id_extend_object, 1, obj);
1333 rb_warning(
"main.include in the wrapped load is effective only in wrapper module");
1354 if (cref->nd_next || (prev_cfp && prev_cfp->
me)) {
1371 if (cfp->
iseq->
type == ISEQ_TYPE_RESCUE) {
1372 return &cfp->
ep[-2];
1374 else if (cfp->
iseq->
type == ISEQ_TYPE_ENSURE &&
1377 return &cfp->
ep[-2];
static void ruby_finalize_0(void)
int ruby_run_node(void *n)
Runs the given compiled source and exits this process.
void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
#define RUBY_VM_CHECK_INTS(th)
VALUE rb_exc_new(VALUE etype, const char *ptr, long len)
int ruby_cleanup(volatile int ex)
Destructs the VM.
void rb_raise_jump(VALUE mesg)
static const rb_method_entry_t * method_entry_of_iseq(rb_control_frame_t *cfp, rb_iseq_t *iseq)
static void warn_refinements_once()
#define RUBY_EVENT_C_RETURN
static VALUE rb_f_raise(int argc, VALUE *argv)
struct rb_vm_protect_tag * protect_tag
#define RUBY_VM_IFUNC_P(ptr)
VALUE rb_make_exception(int argc, VALUE *argv)
#define INTERNAL_EXCEPTION_P(exc)
void ruby_finalize(void)
Runs the VM finalization processes.
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
VALUE rb_hash_dup(VALUE hash)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
#define RUBY_VM_NORMAL_ISEQ_P(ptr)
void * ruby_options(int argc, char **argv)
Processes command line arguments and compiles the Ruby source to execute.
VALUE rb_current_realfilepath(void)
void rb_error_frozen(const char *what)
void rb_exec_end_proc(void)
#define RUBY_DTRACE_RAISE(arg0, arg1, arg2)
void rb_using_refinement(NODE *cref, VALUE klass, VALUE module)
VALUE rb_refinement_module_get_refined_class(VALUE module)
static void set_backtrace(VALUE info, VALUE bt)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
ID rb_frame_this_func(void)
static int sysexit_status(VALUE err)
static VALUE rb_mod_include(int argc, VALUE *argv, VALUE module)
int ruby_exec_node(void *n)
Runs the given compiled source.
static ID frame_func_id(rb_control_frame_t *cfp)
VALUE rb_ary_push(VALUE ary, VALUE item)
static void add_activated_refinement(VALUE activated_refinements, VALUE klass, VALUE refinement)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
#define STACK_UPPER(x, a, b)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
struct rb_iseq_struct * local_iseq
void rb_raise(VALUE exc, const char *fmt,...)
struct rb_vm_protect_tag * prev
VALUE rb_obj_is_kind_of(VALUE, VALUE)
VALUE rb_ary_new3(long n,...)
void rb_vm_localjump_error(const char *mesg, VALUE value, int reason)
void rb_include_module(VALUE klass, VALUE module)
static VALUE errinfo_getter(ID id)
static VALUE rb_obj_extend(int argc, VALUE *argv, VALUE obj)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_rubylevel_errinfo(void)
VALUE rb_iseq_eval_main(VALUE iseqval)
void rb_thread_terminate_all(void)
const char * rb_obj_classname(VALUE)
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
void rb_hash_foreach(VALUE hash, int(*func)(ANYARGS), VALUE farg)
void rb_exc_raise(VALUE mesg)
void rb_prepend_module(VALUE klass, VALUE module)
NORETURN(void rb_raise_jump(VALUE))
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
#define RB_TYPE_P(obj, type)
enum rb_iseq_struct::iseq_type type
static VALUE rb_f_method_name(void)
static VALUE rb_mod_prepend_features(VALUE module, VALUE prepend)
VALUE rb_rescue(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2)
static VALUE get_backtrace(VALUE info)
static VALUE f_current_dirname(void)
static ID frame_called_id(rb_control_frame_t *cfp)
static int error_handle(int ex)
int rb_block_given_p(void)
void * rb_mod_const_at(VALUE, void *)
int rb_threadptr_set_raised(rb_thread_t *th)
RUBY_EXTERN VALUE rb_cObject
#define RMODULE_IS_REFINEMENT
VALUE rb_obj_as_string(VALUE)
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
RUBY_EXTERN VALUE rb_mKernel
VALUE rb_iv_get(VALUE, const char *)
#define RMODULE_IS_OVERLAID
void rb_thread_stop_timer_thread(int close_anyway)
#define PASS_PASSED_BLOCK()
static VALUE rb_mod_prepend(int argc, VALUE *argv, VALUE module)
static VALUE rb_mod_extend_object(VALUE mod, VALUE obj)
void rb_threadptr_check_signal(rb_thread_t *mth)
RUBY_EXTERN VALUE rb_cModule
#define MEMCPY(p1, p2, type, n)
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
VALUE rb_mod_constants(int, VALUE *, VALUE)
static VALUE hidden_identity_hash_new()
#define rb_thread_raised_clear(th)
#define RCLASS_REFINED_CLASS(c)
VALUE rb_check_funcall(VALUE, ID, int, VALUE *)
static VALUE rb_mod_nesting(void)
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
VALUE rb_include_class_new(VALUE module, VALUE super)
void ruby_prog_init(void)
Defines built-in variables.
VALUE rb_file_dirname(VALUE fname)
VALUE rb_iv_set(VALUE, const char *, VALUE)
static void ruby_finalize_1(void)
void * rb_mod_const_of(VALUE, void *)
VALUE rb_ivar_set(VALUE, ID, VALUE)
struct rb_iseq_struct * parent_iseq
rb_encoding * rb_usascii_encoding(void)
static ID rb_frame_caller(void)
void rb_clear_cache(void)
VALUE rb_const_list(void *)
#define SAVE_ROOT_JMPBUF(th, stmt)
int ruby_vm_destruct(ruby_vm_t *vm)
static void setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg)
void rb_extend_object(VALUE obj, VALUE module)
int rb_threadptr_reset_raised(rb_thread_t *th)
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
void ruby_init_stack(volatile VALUE *)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
static VALUE get_errinfo(void)
RUBY_EXTERN VALUE rb_cClass
void rb_jump_tag(int tag)
#define RUBY_VM_END_CONTROL_FRAME(th)
void rb_using_module(NODE *cref, VALUE module)
static int ruby_exec_internal(void *n)
enum rb_thread_status status
#define RUBY_DTRACE_RAISE_ENABLED()
#define va_init_list(a, b)
static void warn_printf(const char *fmt,...)
static VALUE top_include(int argc, VALUE *argv, VALUE self)
static rb_control_frame_t * previous_frame(rb_thread_t *th)
static VALUE top_using(VALUE self, VALUE module)
#define rb_check_arity(argc, min, max)
#define UNLIMITED_ARGUMENTS
VALUE rb_module_new(void)
void * ruby_process_options(int, char **)
VALUE rb_exc_new3(VALUE etype, VALUE str)
rb_method_definition_t * def
void rb_set_errinfo(VALUE err)
const rb_method_entry_t * me
static VALUE * errinfo_place(rb_thread_t *th)
void ruby_sig_finalize(void)
VALUE rb_check_string_type(VALUE)
rb_block_t * rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp)
VALUE rb_f_global_variables(void)
#define NODE_FL_CREF_OMOD_SHARED
VALUE rb_vm_backtrace_object()
static unsigned int hash(const char *str, unsigned int len)
#define EXEC_EVENT_HOOK(th_, flag_, self_, id_, klass_, data_)
void rb_frozen_class_p(VALUE klass)
NODE * rb_vm_get_cref(const rb_iseq_t *, const VALUE *)
static VALUE rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
void rb_warning(const char *fmt,...)
VALUE rb_f_untrace_var(int, VALUE *)
#define CONST_ID(var, str)
static void rb_longjmp(int tag, volatile VALUE mesg)
void rb_gc_call_finalizer_at_exit(void)
VALUE rb_obj_freeze(VALUE)
static void error_print(void)
static VALUE get_thread_errinfo(rb_thread_t *th)
static int using_refinement(VALUE klass, VALUE module, VALUE arg)
#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp)
static VALUE rb_mod_append_features(VALUE module, VALUE include)
VALUE rb_f_trace_var(int, VALUE *)
static VALUE errat_getter(ID id)
void rb_clear_trace_func(void)
void rb_exc_fatal(VALUE mesg)
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
void ruby_default_signal(int)
void rb_threadptr_interrupt(rb_thread_t *th)
void rb_obj_call_init(VALUE obj, int argc, VALUE *argv)
static rb_thread_t * GET_THREAD(void)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_new2(const char *)
void rb_warn(const char *fmt,...)
static void errat_setter(VALUE val, ID id, VALUE *var)
int ruby_executable_node(void *n, int *status)
Checks the return value of ruby_options().
VALUE rb_attr_get(VALUE, ID)
static VALUE make_exception(int argc, VALUE *argv, int isstr)
static VALUE rb_f_callee_name(void)
void Init_eval_method(void)
static VALUE rb_mod_refine(VALUE module, VALUE klass)
#define NODE_FL_CREF_PUSHED_BY_EVAL