30 #define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
35 #define CLASS_OR_MODULE_P(obj) \
36 (!SPECIAL_CONST_P(obj) && \
37 (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
46 static int initialized = 0;
96 void *
volatile iseq = 0;
160 volatile VALUE errs[2];
196 #if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
198 #if EXIT_SUCCESS != 0
201 #if EXIT_FAILURE != 1
208 for (nerr = 0; nerr <
numberof(errs); ++nerr) {
211 if (!
RTEST(err))
continue;
294 if (status) *status =
s;
342 while (cref && cref->nd_next) {
348 cref = cref->nd_next;
388 klass = cref->nd_clss;
396 cref = cref->nd_next;
447 CONST_ID(id_true_cause,
"true_cause");
458 if (!
NIL_P(cause) && cause != exc) {
470 volatile int line = 0;
483 if (file && !
NIL_P(mesg)) {
754 result = (*b_proc) (data1);
773 while ((eclass = va_arg(args,
VALUE)) != 0) {
785 result = (*r_proc) (data2, th->
errinfo);
843 volatile VALUE errinfo;
853 result = (*b_proc) (data1);
874 while (cfp_limit > cfp) {
875 if (cfp->
iseq == iseq)
893 if (ifunc->nd_aid)
return ifunc->nd_aid;
923 if (ifunc->nd_aid)
return ifunc->nd_aid;
969 if (!prev_cfp)
return 0;
977 if (!prev_cfp)
return 0;
1028 ID id_append_features, id_included;
1030 CONST_ID(id_append_features,
"append_features");
1033 for (i = 0; i <
argc; i++)
1036 rb_funcall(argv[argc], id_append_features, 1, module);
1037 rb_funcall(argv[argc], id_included, 1, module);
1076 ID id_prepend_features, id_prepended;
1078 CONST_ID(id_prepend_features,
"prepend_features");
1079 CONST_ID(id_prepended,
"prepended");
1080 for (i = 0; i <
argc; i++)
1083 rb_funcall(argv[argc], id_prepend_features, 1, module);
1084 rb_funcall(argv[argc], id_prepended, 1, module);
1106 if (
NIL_P(cref->nd_refinements)) {
1117 if (
RBASIC(c)->klass == module) {
1133 while (module && module != klass) {
1155 VALUE super, module, refinements;
1167 module =
RBASIC(klass)->klass;
1175 CONST_ID(id_refinements,
"__refinements__");
1176 refinements =
rb_attr_get(module, id_refinements);
1177 if (
NIL_P(refinements))
return;
1192 ID id_refined_class;
1194 CONST_ID(id_refined_class,
"__refined_class__");
1207 if (
RBASIC(c)->klass == refinement) {
1218 while (refinement) {
1242 ID id_refinements, id_activated_refinements,
1243 id_refined_class, id_defined_at;
1244 VALUE refinements, activated_refinements;
1253 "can't pass a Proc as a block to Module#refine");
1256 CONST_ID(id_refinements,
"__refinements__");
1257 refinements =
rb_attr_get(module, id_refinements);
1258 if (
NIL_P(refinements)) {
1262 CONST_ID(id_activated_refinements,
"__activated_refinements__");
1263 activated_refinements =
rb_attr_get(module, id_activated_refinements);
1264 if (
NIL_P(activated_refinements)) {
1267 activated_refinements);
1270 if (
NIL_P(refinement)) {
1274 CONST_ID(id_refined_class,
"__refined_class__");
1276 CONST_ID(id_defined_at,
"__defined_at__");
1301 "Module#using is not permitted in methods");
1303 if (prev_cfp && prev_cfp->
self !=
self) {
1386 ID id_extend_object, id_extended;
1388 CONST_ID(id_extend_object,
"extend_object");
1392 for (i = 0; i <
argc; i++)
1395 rb_funcall(argv[argc], id_extend_object, 1, obj);
1416 rb_warning(
"main.include in the wrapped load is effective only in wrapper module");
1436 if (cref->nd_next || (prev_cfp && prev_cfp->
me)) {
1438 "main.using is permitted only at toplevel");
1452 if (cfp->
iseq->
type == ISEQ_TYPE_RESCUE) {
1453 return &cfp->
ep[-2];
1455 else if (cfp->
iseq->
type == ISEQ_TYPE_ENSURE &&
1458 return &cfp->
ep[-2];
#define RB_TYPE_P(obj, type)
static void ruby_finalize_0(void)
VALUE rb_const_list(void *)
void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
#define RUBY_VM_CHECK_INTS(th)
#define RCLASS_M_TBL_WRAPPER(c)
VALUE rb_exc_new(VALUE etype, const char *ptr, long len)
int register char * block
int ruby_cleanup(volatile int ex)
Destructs the VM.
struct rb_ensure_entry entry
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)
VALUE rb_f_trace_var(int, VALUE *)
rb_funcall2(argv[0], id_yield, argc-1, argv+1)
#define RB_OBJ_WRITE(a, slot, b)
static VALUE rb_f_raise(int argc, VALUE *argv)
RUBY_EXTERN VALUE rb_cModule
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)
const char * rb_obj_classname(VALUE)
void * rb_mod_const_at(VALUE, void *)
VALUE rb_iv_set(VALUE, const char *, VALUE)
#define UNLIMITED_ARGUMENTS
void ruby_finalize(void)
Runs the VM finalization processes.
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE exc_setup_cause(VALUE exc, VALUE cause)
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
#define RUBY_VM_NORMAL_ISEQ_P(ptr)
rb_funcall(memo->yielder, id_lshift, 1, rb_assoc_new(memo->prev_value, memo->prev_elts))
void rb_error_frozen(const char *what)
void rb_exec_end_proc(void)
#define RUBY_EVENT_C_RETURN
#define RUBY_DTRACE_RAISE(arg0, arg1, arg2)
void rb_using_refinement(NODE *cref, VALUE klass, VALUE module)
#define CLASS_OR_MODULE_P(obj)
VALUE rb_refinement_module_get_refined_class(VALUE module)
static void set_backtrace(VALUE info, VALUE bt)
VALUE rb_iv_get(VALUE, const char *)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
ID rb_frame_this_func(void)
VALUE rb_obj_freeze(VALUE)
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)
#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
static VALUE mod_using(VALUE self, VALUE module)
#define OBJ_WB_UNPROTECT(x)
void rb_vm_localjump_error(const char *mesg, VALUE value, int reason)
void rb_include_module(VALUE klass, VALUE module)
#define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)
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)
ID rb_frame_last_func(void)
void rb_thread_terminate_all(void)
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
void rb_hash_foreach(VALUE, int(*)(ANYARGS), VALUE)
void rb_exc_raise(VALUE mesg)
void rb_prepend_module(VALUE klass, VALUE module)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
enum rb_iseq_struct::iseq_type type
VALUE rb_f_untrace_var(int, VALUE *)
#define NODE_FL_CREF_OMOD_SHARED
VALUE rb_file_dirname(VALUE fname)
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 ID prev_frame_callee(void)
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)
int rb_threadptr_set_raised(rb_thread_t *th)
RUBY_EXTERN VALUE rb_mKernel
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
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)
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
static VALUE hidden_identity_hash_new()
void * ruby_process_options(int, char **)
#define rb_thread_raised_clear(th)
VALUE rb_obj_as_string(VALUE)
void * rb_mod_const_of(VALUE, void *)
static VALUE rb_mod_nesting(void)
VALUE rb_include_class_new(VALUE module, VALUE super)
static ID prev_frame_func(void)
void ruby_prog_init(void)
Defines built-in variables.
#define CONST_ID(var, str)
static void ruby_finalize_1(void)
VALUE rb_f_global_variables(void)
struct rb_iseq_struct * parent_iseq
rb_encoding * rb_usascii_encoding(void)
VALUE rb_vm_backtrace_object(void)
void rb_clear_method_cache_by_class(VALUE)
#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)
rb_hash_aset(hash, RARRAY_AREF(key_value_pair, 0), RARRAY_AREF(key_value_pair, 1))
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
VALUE rb_attr_get(VALUE, ID)
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)
struct rb_ensure_list * next
void rb_jump_tag(int tag)
VALUE rb_mod_constants(int, VALUE *, VALUE)
#define RUBY_VM_END_CONTROL_FRAME(th)
void rb_using_module(NODE *cref, VALUE module)
static void using_module_recursive(NODE *cref, VALUE klass)
#define MEMCPY(p1, p2, type, n)
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)
VALUE rb_exc_new_cstr(VALUE etype, const char *s)
static VALUE top_using(VALUE self, VALUE module)
#define RMODULE_IS_OVERLAID
VALUE rb_module_new(void)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
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)
static VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super)
void ruby_sig_finalize(void)
RUBY_EXTERN VALUE rb_cClass
RUBY_EXTERN VALUE rb_cObject
void ruby_default_signal(int)
rb_block_t * rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp)
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
rb_ensure_list_t * ensure_list
rb_ivar_set(yielder, id_memo, LONG2NUM(++count))
#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 *)
void rb_gc_call_finalizer_at_exit(void)
#define RBASIC_CLEAR_CLASS(obj)
static VALUE rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
void rb_warning(const char *fmt,...)
VALUE rb_current_realfilepath(void)
static void rb_longjmp(int tag, volatile VALUE mesg)
#define RMODULE_IS_REFINEMENT
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 SPECIAL_CONST_P(x)
void rb_clear_trace_func(void)
#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp)
static VALUE rb_mod_append_features(VALUE module, VALUE include)
#define NODE_FL_CREF_PUSHED_BY_EVAL
static VALUE errat_getter(ID id)
void rb_exc_fatal(VALUE mesg)
#define RCLASS_REFINED_CLASS(c)
VALUE rb_check_string_type(VALUE)
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_check_funcall(VALUE, ID, int, const VALUE *)
static void errat_setter(VALUE val, ID id, VALUE *var)
void Init_eval_method(void)
int ruby_executable_node(void *n, int *status)
Checks the return value of ruby_options().
static VALUE make_exception(int argc, VALUE *argv, int isstr)
static VALUE rb_f_callee_name(void)
static VALUE rb_mod_refine(VALUE module, VALUE klass)