5 #define CACHE_SIZE 0x800
6 #define CACHE_MASK 0x7ff
7 #define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
23 #define ruby_running (GET_VM()->running)
94 ume->
next =
GET_VM()->unlinked_method_entry_list;
95 GET_VM()->unlinked_method_entry_list = ume;
184 rb_warn(
"defining %s.allocate is deprecated; use rb_define_alloc_func()",
208 switch (old_def->
type) {
221 "previous definition of %s was here",
241 if (klass ==
rb_cObject && mid == idInitialize) {
242 rb_warn(
"redefining Object#initialize may cause infinite loop");
245 if (mid ==
object_id || mid == id__send__) {
256 #define CALL_METHOD_HOOK(klass, hook, mid) do { \
257 const VALUE arg = ID2SYM(mid); \
258 VALUE recv_class = (klass); \
259 ID hook_id = (hook); \
260 if (FL_TEST((klass), FL_SINGLETON)) { \
261 recv_class = rb_ivar_get((klass), attached); \
262 hook_id = singleton_##hook; \
264 rb_funcall2(recv_class, hook_id, 1, &arg); \
319 rb_bug(
"rb_add_method: unsupported method type (%d)\n", type);
422 ent->
mid ==
id && ent->
klass == klass) {
442 if (mid ==
object_id || mid == id__send__ || mid == idInitialize) {
487 for (i = 0; i <
argc; i++) {
493 #undef rb_disable_super
494 #undef rb_enable_super
526 if (me->
flag != noex) {
529 if (klass == me->
klass) {
547 if (!me->
def)
return 0;
572 "attribute accessor as module_function" :
573 "private attribute?");
616 if (
id ==
object_id ||
id == id__send__ ||
id == idInitialize) {
623 const char *s0 =
" class";
695 for (i = 0; i <
argc; i++) {
737 #define VISI_CHECK(x,f) (((x)&NOEX_MASK) == (f))
856 if (d1 == d2)
return 1;
857 if (!d1 || !d2)
return 0;
882 rb_bug(
"rb_method_entry_eq: unsupported method type (%d)\n", d1->
type);
915 flag = orig_me->
flag;
957 "Insecure: can't change method visibility");
971 for (i = 0; i <
argc; i++) {
1169 for (i = 0; i <
argc; i++) {
1285 #define rb_intern(str) rb_intern_const(str)
static struct cache_entry cache[CACHE_SIZE]
VALUE(* rb_alloc_func_t)(VALUE)
struct unlinked_method_entry_list_entry * next
int rb_method_boundp(VALUE klass, ID id, int ex)
static int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2)
#define UNDEFINED_METHOD_ENTRY_P(me)
static VALUE rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
int rb_iseq_first_lineno(rb_iseq_t *iseq)
void rb_bug(const char *fmt,...)
void rb_enc_copy(VALUE obj1, VALUE obj2)
static VALUE rb_mod_method_defined(VALUE mod, VALUE mid)
VALUE rb_ary_freeze(VALUE ary)
static VALUE rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname)
#define NOEX_WITH_SAFE(n)
void rb_remove_method(VALUE klass, const char *name)
static VALUE rb_mod_remove_method(int argc, VALUE *argv, VALUE mod)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
union rb_method_definition_struct::@42 body
static ID singleton_removed
void rb_disable_super(VALUE klass, const char *name)
rb_alloc_func_t rb_get_alloc_func(VALUE klass)
static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static ID singleton_undefined
void rb_alias(VALUE klass, ID name, ID def)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
#define RSTRING_PTR(string)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_ivar_get(VALUE, ID)
#define GET_VM_STATE_VERSION()
VALUE rb_ary_new3(long n,...)
RUBY_FUNC_EXPORTED int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
void rb_vm_change_state(void)
int rb_method_basic_definition_p(VALUE klass, ID id)
rb_control_frame_t * rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
void rb_mark_method_entry(const rb_method_entry_t *me)
rb_method_entry_t * rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex)
void rb_name_error(ID id, const char *fmt,...)
static void remove_method(VALUE klass, ID mid)
static void rb_export_method(VALUE klass, ID name, rb_method_flag_t noex)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
void rb_attr(VALUE klass, ID id, int read, int write, int ex)
int rb_is_const_id(ID id)
int rb_obj_respond_to(VALUE obj, ID id, int priv)
static rb_method_entry_t * rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type, rb_method_definition_t *def, rb_method_flag_t noex)
static rb_method_entry_t * search_method(VALUE klass, ID id)
RUBY_EXTERN VALUE rb_cObject
int rb_respond_to(VALUE obj, ID id)
void rb_clear_cache(void)
static VALUE top_public(int argc, VALUE *argv)
static VALUE obj_respond_to(int argc, VALUE *argv, VALUE obj)
rb_method_entry_t * rb_method_entry_get_without_cache(VALUE klass, ID id)
RUBY_EXTERN VALUE rb_mKernel
void rb_remove_method_id(VALUE klass, ID mid)
void rb_undef_alloc_func(VALUE klass)
static VALUE top_private(int argc, VALUE *argv)
struct unlinked_method_entry_list_entry * unlinked_method_entry_list
static void rb_clear_cache_by_id(ID id)
void rb_clear_cache_by_class(VALUE klass)
void rb_gc_mark_unlinked_live_method_entries(void *pvm)
RUBY_EXTERN VALUE rb_cModule
static int basic_obj_respond_to(VALUE obj, ID id, int pub)
static VALUE rb_mod_private_method_defined(VALUE mod, VALUE mid)
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE(*func)(ANYARGS), int argc, rb_method_flag_t noex)
static VALUE check_definition(VALUE mod, ID mid, rb_method_flag_t noex)
static void secure_visibility(VALUE self)
SSL_METHOD *(* func)(void)
VALUE rb_sprintf(const char *format,...)
static VALUE rb_mod_public(int argc, VALUE *argv, VALUE module)
int rb_is_local_id(ID id)
static VALUE rb_mod_protected_method_defined(VALUE mod, VALUE mid)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
rb_iseq_t * rb_proc_get_iseq(VALUE proc, int *is_proc)
static void vm_clear_global_method_cache(void)
static VALUE rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
const char * rb_class2name(VALUE)
static VALUE obj_respond_to_missing(VALUE obj, VALUE mid, VALUE priv)
rb_method_entry_t * rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_flag_t noex)
rb_method_entry_t * rb_method_entry(VALUE klass, ID id)
static VALUE rb_mod_undef_method(int argc, VALUE *argv, VALUE mod)
#define CALL_METHOD_HOOK(klass, hook, mid)
static void method_added(VALUE klass, ID mid)
static void set_method_visibility(VALUE self, int argc, VALUE *argv, rb_method_flag_t ex)
VALUE rb_f_notimplement(int argc, VALUE *argv, VALUE obj)
static VALUE rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
void rb_enable_super(VALUE klass, const char *name)
void rb_sweep_method_entry(void *pvm)
static void rb_clear_cache_for_undef(VALUE klass, ID id)
VALUE rb_equal(VALUE, VALUE)
ID rb_intern_str(VALUE str)
rb_method_definition_t * def
static ID respond_to_missing
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2)
void rb_compile_warning(const char *file, int line, const char *fmt,...)
void rb_free_method_entry(rb_method_entry_t *me)
void rb_define_alloc_func(VALUE klass, VALUE(*func)(VALUE))
static VALUE rb_mod_protected(int argc, VALUE *argv, VALUE module)
void rb_notimplement(void)
enum rb_method_definition_struct::@42::method_optimized_type optimize_type
void Init_eval_method(void)
static VALUE rb_mod_public_method_defined(VALUE mod, VALUE mid)
static VALUE rb_mod_private(int argc, VALUE *argv, VALUE module)
void rb_frozen_class_p(VALUE klass)
void rb_undef(VALUE klass, ID id)
const char * rb_id2name(ID id)
void rb_warning(const char *fmt,...)
#define rb_check_frozen(obj)
void rb_print_undef(VALUE klass, ID id, int scope)
struct iseq_insn_info_entry * insn_info_table
void rb_unlink_method_entry(rb_method_entry_t *me)
static void rb_define_notimplement_method_id(VALUE mod, ID id, rb_method_flag_t noex)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void rb_warn(const char *fmt,...)
static ID singleton_added