29 #define id_signo ruby_static_id_signo 30 #define id_status ruby_static_id_status 32 #define exception_error GET_VM()->special_exceptions[ruby_error_reenter] 37 #define CLASS_OR_MODULE_P(obj) \ 38 (!SPECIAL_CONST_P(obj) && \ 39 (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE)) 98 void *
volatile iseq = 0;
162 volatile VALUE errs[2];
166 volatile int step = 0;
193 if (ex == 0) ex = state;
199 for (nerr = 0; nerr <
numberof(errs); ++nerr) {
202 if (!
RTEST(err))
continue;
284 if (status) *status = s;
447 CONST_ID(id_true_cause,
"true_cause");
458 if (!
NIL_P(cause) && cause != exc) {
479 if (exceptions[i] == exc)
return TRUE;
488 const char *file = 0;
515 if (file && !
NIL_P(mesg)) {
650 VALUE opt = argv[argc-1];
838 result = (*b_proc) (data1);
857 while ((eclass = va_arg(args,
VALUE)) != 0) {
869 result = (*r_proc) (data2, th->
errinfo);
937 result = (*b_proc) (data1);
1005 if (!prev_cfp)
return 0;
1013 if (!prev_cfp)
return 0;
1064 ID id_append_features, id_included;
1066 CONST_ID(id_append_features,
"append_features");
1070 for (i = 0; i <
argc; i++)
1073 rb_funcall(argv[argc], id_append_features, 1, module);
1074 rb_funcall(argv[argc], id_included, 1, module);
1113 ID id_prepend_features, id_prepended;
1115 CONST_ID(id_prepend_features,
"prepend_features");
1116 CONST_ID(id_prepended,
"prepended");
1119 for (i = 0; i <
argc; i++)
1122 rb_funcall(argv[argc], id_prepend_features, 1, module);
1123 rb_funcall(argv[argc], id_prepended, 1, module);
1133 "wrong argument type %"PRIsVALUE" (expected Class or Module)",
1150 VALUE iclass, c, superclass = klass;
1165 if (
RBASIC(c)->klass == module) {
1181 while (module && module != klass) {
1203 VALUE super, module, refinements;
1215 module =
RBASIC(klass)->klass;
1223 CONST_ID(id_refinements,
"__refinements__");
1224 refinements =
rb_attr_get(module, id_refinements);
1225 if (
NIL_P(refinements))
return;
1240 ID id_refined_class;
1242 CONST_ID(id_refined_class,
"__refined_class__");
1250 VALUE iclass, c, superclass = klass;
1255 if (
RBASIC(c)->klass == refinement) {
1266 while (refinement && refinement != klass) {
1288 ID id_refinements, id_activated_refinements,
1289 id_refined_class, id_defined_at;
1290 VALUE refinements, activated_refinements;
1302 CONST_ID(id_refinements,
"__refinements__");
1303 refinements =
rb_attr_get(module, id_refinements);
1304 if (
NIL_P(refinements)) {
1308 CONST_ID(id_activated_refinements,
"__activated_refinements__");
1309 activated_refinements =
rb_attr_get(module, id_activated_refinements);
1310 if (
NIL_P(activated_refinements)) {
1313 activated_refinements);
1316 if (
NIL_P(refinement)) {
1320 CONST_ID(id_refined_class,
"__refined_class__");
1322 CONST_ID(id_defined_at,
"__defined_at__");
1334 const char *anon =
"";
1336 anon =
", maybe for Module.new";
1338 rb_warn(
"%s""using doesn't call the given block""%s.", klass, anon);
1356 "Module#using is not permitted in methods");
1358 if (prev_cfp && prev_cfp->
self !=
self) {
1372 CONST_ID(id_defined_at,
"__defined_at__");
1497 ID id_extend_object, id_extended;
1499 CONST_ID(id_extend_object,
"extend_object");
1503 for (i = 0; i <
argc; i++)
1506 rb_funcall(argv[argc], id_extend_object, 1, obj);
1527 rb_warning(
"main.include in the wrapped load is effective only in wrapper module");
1557 static const VALUE *
#define RBASIC_CLEAR_CLASS(obj)
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.
struct rb_ensure_entry entry
VALUE rb_vm_backtrace_object(void)
#define RUBY_EVENT_C_RETURN
static VALUE rb_f_raise(int argc, VALUE *argv)
struct rb_vm_protect_tag * protect_tag
#define va_init_list(a, b)
static void using_module_recursive(const rb_cref_t *cref, VALUE klass)
#define INTERNAL_EXCEPTION_P(exc)
VALUE rb_make_exception(int argc, const VALUE *argv)
#define VM_ENV_INDEX_LAST_LVAR
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)
static int extract_raise_opts(int argc, const VALUE *argv, VALUE *opts)
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.
static VALUE exc_setup_cause(VALUE exc, VALUE cause)
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)
static int special_exception_p(rb_thread_t *th, VALUE exc)
VALUE rb_iseq_eval_main(const rb_iseq_t *iseq)
void * ruby_options(int argc, char **argv)
Processes command line arguments and compiles the Ruby source to execute.
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
VALUE rb_current_realfilepath(void)
static int used_modules_i(VALUE _, VALUE mod, VALUE ary)
void rb_error_frozen(const char *what)
void rb_exec_end_proc(void)
struct rb_method_definition_struct *const def
static int CREF_PUSHED_BY_EVAL(const rb_cref_t *cref)
#define CLASS_OR_MODULE_P(obj)
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)
static int sysstack_error_p(VALUE exc)
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 VALUE hidden_identity_hash_new(void)
#define TH_JUMP_TAG(th, st)
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)
#define VM_BLOCK_HANDLER_NONE
static void rb_longjmp(int tag, volatile VALUE mesg, VALUE cause)
struct rb_iseq_constant_body * body
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)
void rb_raise(VALUE exc, const char *fmt,...)
struct rb_vm_protect_tag * prev
VALUE rb_ivar_get(VALUE, ID)
void Init_vm_objects(void)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
static VALUE mod_using(VALUE self, VALUE module)
void rb_vm_localjump_error(const char *mesg, VALUE value, int reason)
void rb_include_module(VALUE klass, VALUE module)
static VALUE CREF_REFINEMENTS(const rb_cref_t *cref)
VALUE rb_hash_lookup(VALUE hash, VALUE key)
#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.
#define RUBY_DTRACE_HOOK(name, arg)
static int VM_FRAME_RUBYFRAME_P(const rb_control_frame_t *cfp)
#define ATOMIC_VALUE_EXCHANGE(var, val)
const char * rb_source_loc(int *pline)
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_ivar_defined(VALUE, ID)
VALUE rb_rubylevel_errinfo(void)
ID rb_frame_last_func(void)
void rb_thread_terminate_all(void)
void rb_using_module(const rb_cref_t *cref, VALUE module)
const char * rb_obj_classname(VALUE)
static void CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
static VALUE rb_class_of(VALUE obj)
#define THROW_DATA_P(err)
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)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
#define RB_TYPE_P(obj, 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 ID prev_frame_callee(void)
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 *)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
int rb_threadptr_set_raised(rb_thread_t *th)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_obj_as_string(VALUE)
static VALUE rb_mod_s_used_modules(void)
#define OBJ_WB_UNPROTECT(x)
RUBY_EXTERN VALUE rb_mKernel
static VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super)
static VALUE rb_mod_prepend(int argc, VALUE *argv, VALUE module)
static VALUE rb_mod_extend_object(VALUE mod, VALUE obj)
void rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module)
#define warn_print_str(x)
void rb_threadptr_check_signal(rb_thread_t *mth)
void rb_thread_stop_timer_thread(void)
void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE cls, const char *mesg)
char ary[RSTRING_EMBED_LEN_MAX+1]
const VALUE special_exceptions[ruby_special_error_count]
RUBY_EXTERN VALUE rb_cModule
#define MEMCPY(p1, p2, type, n)
void rb_threadptr_setup_exception(rb_thread_t *th, VALUE mesg, VALUE cause)
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements)
#define rb_thread_raised_clear(th)
#define RCLASS_REFINED_CLASS(c)
rb_cref_t * rb_vm_cref_replace_with_duplicated_cref(void)
void rb_vm_pop_frame(rb_thread_t *th)
static VALUE rb_mod_nesting(void)
VALUE rb_sprintf(const char *format,...)
static rb_cref_t * CREF_NEXT(const rb_cref_t *cref)
VALUE rb_include_class_new(VALUE module, VALUE super)
static ID prev_frame_func(void)
void ruby_prog_init(void)
Defines built-in variables.
static enum rb_block_handler_type vm_block_handler_type(VALUE block_handler)
static VALUE CREF_CLASS(const rb_cref_t *cref)
VALUE rb_file_dirname(VALUE fname)
static void ruby_finalize_1(void)
void * rb_mod_const_of(VALUE, void *)
VALUE rb_ivar_set(VALUE, ID, VALUE)
void rb_clear_method_cache_by_class(VALUE)
VALUE rb_const_list(void *)
static void ensure_class_or_module(VALUE obj)
VALUE rb_vm_top_self(void)
#define SAVE_ROOT_JMPBUF(th, stmt)
VALUE rb_f_trace_var(int, const VALUE *)
#define EXEC_EVENT_HOOK(th_, flag_, self_, id_, called_id_, klass_, data_)
int ruby_vm_destruct(ruby_vm_t *vm)
void rb_extend_object(VALUE obj, VALUE module)
int rb_threadptr_reset_raised(rb_thread_t *th)
static void ignored_block(VALUE module, const char *klass)
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
void ruby_init_stack(volatile VALUE *)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
static void error_print(rb_thread_t *th)
static VALUE get_errinfo(void)
struct rb_ensure_list * next
RUBY_EXTERN VALUE rb_cClass
static int CREF_OMOD_SHARED(const rb_cref_t *cref)
void rb_jump_tag(int tag)
enum rb_iseq_constant_body::iseq_type type
static const VALUE * errinfo_place(rb_thread_t *th)
#define RUBY_VM_END_CONTROL_FRAME(th)
VALUE rb_mod_constants(int, const VALUE *, VALUE)
static int ruby_exec_internal(void *n)
enum rb_thread_status status
static VALUE top_include(int argc, VALUE *argv, VALUE self)
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp)
VALUE rb_f_untrace_var(int, const VALUE *)
static rb_control_frame_t * previous_frame(rb_thread_t *th)
VALUE rb_ident_hash_new(void)
VALUE rb_exc_new_cstr(VALUE etype, const char *s)
static VALUE top_using(VALUE self, VALUE module)
#define UNLIMITED_ARGUMENTS
VALUE rb_module_new(void)
void * ruby_process_options(int, char **)
#define RBASIC_CLASS(obj)
void rb_set_errinfo(VALUE err)
void ruby_sig_finalize(void)
VALUE rb_check_string_type(VALUE)
VALUE rb_f_global_variables(void)
void rb_obj_call_init(VALUE obj, int argc, const VALUE *argv)
rb_ensure_list_t * ensure_list
void rb_frozen_class_p(VALUE klass)
VALUE rb_get_backtrace(VALUE exc)
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,...)
void rb_raise_jump(VALUE mesg, VALUE cause)
#define CONST_ID(var, str)
void rb_gc_call_finalizer_at_exit(void)
#define rb_intern_const(str)
static VALUE make_exception(int argc, const VALUE *argv, int isstr)
#define SPECIAL_CONST_P(x)
static VALUE get_thread_errinfo(rb_thread_t *th)
static int using_refinement(VALUE klass, VALUE module, VALUE arg)
VALUE ruby_vm_special_exception_copy(VALUE)
#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp)
static VALUE rb_mod_append_features(VALUE module, VALUE include)
static void setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
static void CREF_REFINEMENTS_SET(rb_cref_t *cref, VALUE refs)
static VALUE errat_getter(ID id)
void rb_clear_trace_func(void)
void rb_exc_fatal(VALUE mesg)
void ruby_default_signal(int)
VALUE rb_search_class_path(VALUE)
void rb_threadptr_interrupt(rb_thread_t *th)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define unknown_longjmp_status(status)
rb_cref_t * rb_vm_cref(void)
void rb_warn(const char *fmt,...)
NORETURN(void rb_raise_jump(VALUE, VALUE))
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 rb_f_callee_name(void)
#define PASS_PASSED_BLOCK_HANDLER()
VALUE rb_obj_class(VALUE)
void Init_eval_method(void)
static VALUE rb_mod_refine(VALUE module, VALUE klass)