vm_method.c File Reference

Go to the source code of this file.

## Data Structures

struct | cache_entry

## Macros

#define | CACHE_SIZE 0x800
#define | CACHE_MASK 0x7ff
#define | EXPR1(c, m) ((((c)>>3)^(m))&CACHE_MASK)
#define | ruby_running (GET_VM()->running)
#define | CALL_METHOD_HOOK(klass, hook, mid)
#define | VISI_CHECK(x, f) (((x)&NOEX_MASK) == (f))
#define | rb_intern(str) rb_intern_const(str)

## Functions

static void | rb_vm_check_redefinition_opt_method (const rb_method_entry_t *me)
static void | vm_clear_global_method_cache (void)
void | rb_clear_cache (void)
static void | rb_clear_cache_for_undef (VALUE klass, ID id)
static void | rb_clear_cache_by_id (ID id)
void | rb_clear_cache_by_class (VALUE klass)
VALUE | rb_f_notimplement (int argc, VALUE *argv, VALUE obj)
static void | rb_define_notimplement_method_id (VALUE mod, ID id, rb_method_flag_t noex)
void | rb_add_method_cfunc (VALUE klass, ID mid, VALUE(*func)(ANYARGS), int argc, rb_method_flag_t noex)
void | rb_unlink_method_entry (rb_method_entry_t *me)
void | rb_gc_mark_unlinked_live_method_entries (void *pvm)
void | rb_sweep_method_entry (void *pvm)
void | rb_free_method_entry (rb_method_entry_t *me)
static int | rb_method_definition_eq (const rb_method_definition_t *d1, const rb_method_definition_t *d2)
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 void | method_added (VALUE klass, ID mid)
rb_method_entry_t * | rb_add_method (VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex)
rb_method_entry_t * | rb_method_entry_set (VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_flag_t noex)
void | rb_define_alloc_func (VALUE klass, VALUE(*func)(VALUE))
void | rb_undef_alloc_func (VALUE klass)
rb_alloc_func_t | rb_get_alloc_func (VALUE klass)
static rb_method_entry_t * | search_method (VALUE klass, ID id)
rb_method_entry_t * | rb_method_entry_get_without_cache (VALUE klass, ID id)
rb_method_entry_t * | rb_method_entry (VALUE klass, ID id)
static void | remove_method (VALUE klass, ID mid)
void | rb_remove_method_id (VALUE klass, ID mid)
void | rb_remove_method (VALUE klass, const char *name)
static VALUE | rb_mod_remove_method (int argc, VALUE *argv, VALUE mod)
void | rb_disable_super (VALUE klass, const char *name)
void | rb_enable_super (VALUE klass, const char *name)
static void | rb_export_method (VALUE klass, ID name, rb_method_flag_t noex)
int | rb_method_boundp (VALUE klass, ID id, int ex)
void | rb_attr (VALUE klass, ID id, int read, int write, int ex)
void | rb_undef (VALUE klass, ID id)
static VALUE | rb_mod_undef_method (int argc, VALUE *argv, VALUE mod)
static VALUE | rb_mod_method_defined (VALUE mod, VALUE mid)
static VALUE | check_definition (VALUE mod, ID mid, rb_method_flag_t noex)
static VALUE | rb_mod_public_method_defined (VALUE mod, VALUE mid)
static VALUE | rb_mod_private_method_defined (VALUE mod, VALUE mid)
static VALUE | rb_mod_protected_method_defined (VALUE mod, VALUE mid)
int | rb_method_entry_eq (const rb_method_entry_t *m1, const rb_method_entry_t *m2)
void | rb_alias (VALUE klass, ID name, ID def)
static VALUE | rb_mod_alias_method (VALUE mod, VALUE newname, VALUE oldname)
static void | secure_visibility (VALUE self)
static void | set_method_visibility (VALUE self, int argc, VALUE *argv, rb_method_flag_t ex)
static VALUE | rb_mod_public (int argc, VALUE *argv, VALUE module)
static VALUE | rb_mod_protected (int argc, VALUE *argv, VALUE module)
static VALUE | rb_mod_private (int argc, VALUE *argv, VALUE module)
static VALUE | rb_mod_public_method (int argc, VALUE *argv, VALUE obj)
static VALUE | rb_mod_private_method (int argc, VALUE *argv, VALUE obj)
static VALUE | top_public (int argc, VALUE *argv)
static VALUE | top_private (int argc, VALUE *argv)
static VALUE | rb_mod_modfunc (int argc, VALUE *argv, VALUE module)
int | rb_method_basic_definition_p (VALUE klass, ID id)
static int | basic_obj_respond_to (VALUE obj, ID id, int pub)
int | rb_obj_respond_to (VALUE obj, ID id, int priv)
int | rb_respond_to (VALUE obj, ID id)
static VALUE | obj_respond_to (int argc, VALUE *argv, VALUE obj)
static VALUE | obj_respond_to_missing (VALUE obj, VALUE mid, VALUE priv)
void | Init_eval_method (void)

## Variables

static ID | object_id
static ID | respond_to_missing
static ID | removed
static ID | singleton_removed
static ID | undefined
static ID | singleton_undefined
static ID | added
static ID | singleton_added
static ID | attached
static struct cache_entry | cache [CACHE_SIZE]

## Macro Definition Documentation

#define CACHE_MASK 0x7ff

Definition at line 6 of file vm_method.c.

#define CACHE_SIZE 0x800

Definition at line 5 of file vm_method.c.

Referenced by vm_clear_global_method_cache().

#define CALL_METHOD_HOOK | ( |  | klass,
|  |  | hook,
|  |  | mid
| ) |  |

Value:
do { \
const VALUE arg = ID2SYM(mid); \
VALUE recv_class = (klass); \
ID hook_id = (hook); \
if (FL_TEST((klass), FL_SINGLETON)) { \
recv_class = rb_ivar_get((klass), attached); \
hook_id = singleton_##hook; \
} \
rb_funcall2(recv_class, hook_id, 1, &arg); \
} while (0)

Definition at line 256 of file vm_method.c.

Referenced by method_added(), rb_undef(), and remove_method().

#define EXPR1 | ( |  | c,
|  |  | m
| ) |  | ((((c)>>3)^(m))&CACHE_MASK)

Definition at line 7 of file vm_method.c.

Referenced by rb_method_entry(), and rb_method_entry_get_without_cache().

#define rb_intern | ( |  | str | ) | rb_intern_const(str)

#define ruby_running (GET_VM()->running)

Definition at line 23 of file vm_method.c.

Referenced by method_added(), and rb_method_entry_get_without_cache().

#define VISI_CHECK | ( |  | x,
|  |  | f
| ) |  | (((x)&NOEX_MASK) == (f))

Definition at line 737 of file vm_method.c.

Referenced by check_definition().

## Function Documentation

static int basic_obj_respond_to | ( | VALUE | obj,
|  | ID | id,
|  | int | pub
| ) |  |

inline static

Definition at line 1203 of file vm_method.c.

References CLASS_OF, FALSE, ID2SYM, NOEX_RESPONDS, Qfalse, Qtrue, rb_funcall(), rb_method_boundp(), respond_to_missing, RTEST, and TRUE.

Referenced by obj_respond_to(), and rb_obj_respond_to().

static VALUE check_definition | ( | VALUE | mod,
|  | ID | mid,
|  | rb_method_flag_t | noex
| ) |  |

static

Definition at line 740 of file vm_method.c.

References rb_method_entry_struct::flag, cache_entry::me, Qfalse, Qtrue, rb_method_entry(), and VISI_CHECK.

Referenced by rb_mod_private_method_defined(), rb_mod_protected_method_defined(), and rb_mod_public_method_defined().

void Init_eval_method | ( | void |  | ) |

Definition at line 1282 of file vm_method.c.

References added, attached, obj_respond_to(), obj_respond_to_missing(), object_id, rb_cModule, rb_define_method(), rb_define_private_method(), rb_define_singleton_method(), rb_intern, rb_mKernel, rb_mod_alias_method(), rb_mod_method_defined(), rb_mod_modfunc(), rb_mod_private(), rb_mod_private_method(), rb_mod_private_method_defined(), rb_mod_protected(), rb_mod_protected_method_defined(), rb_mod_public(), rb_mod_public_method(), rb_mod_public_method_defined(), rb_mod_remove_method(), rb_mod_undef_method(), rb_vm_top_self(), removed, respond_to_missing, singleton_added, singleton_removed, singleton_undefined, top_private(), top_public(), and undefined.

Referenced by Init_eval().

static void method_added | ( | VALUE | klass,
|  | ID | mid
| ) |  |

static

Definition at line 268 of file vm_method.c.

References added, CALL_METHOD_HOOK, ID_ALLOCATOR, and ruby_running.

Referenced by rb_add_method(), and rb_method_entry_set().

static VALUE obj_respond_to | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |

static

Definition at line 1254 of file vm_method.c.

References basic_obj_respond_to(), id, cache_entry::mid, Qfalse, Qtrue, rb_scan_args(), rb_to_id(), and RTEST.

Referenced by Init_eval_method().

static VALUE obj_respond_to_missing | ( | VALUE | obj,
|  | VALUE | mid,
|  | VALUE | priv
| ) |  |

static

Definition at line 1276 of file vm_method.c.

References Qfalse.

Referenced by Init_eval_method().

rb_method_entry_t* rb_add_method | ( | VALUE | klass,
|  | ID | mid,
|  | rb_method_type_t | type,
|  | void * | opts,
|  | rb_method_flag_t | noex
| ) |  |

Definition at line 276 of file vm_method.c.

References rb_method_definition_struct::alias_count, ALLOC, rb_method_cfunc_struct::argc, rb_method_definition_struct::attr, rb_method_definition_struct::body, rb_thread_struct::cfp, rb_method_definition_struct::cfunc, rb_method_entry_struct::def, rb_iseq_struct::filename, rb_method_cfunc_struct::func, GET_THREAD, rb_method_attr_struct::id, INT2FIX, rb_method_definition_struct::iseq, rb_control_frame_t::iseq, rb_method_attr_struct::location, unlinked_method_entry_list_entry::me, method_added(), rb_method_definition_struct::optimize_type, rb_method_definition_struct::original_id, rb_method_definition_struct::proc, Qfalse, rb_ary_freeze(), rb_ary_new3(), rb_bug(), rb_f_notimplement(), rb_method_entry_make(), rb_vm_get_ruby_level_next_cfp(), rb_vm_get_sourceline(), rb_method_definition_struct::type, type, VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_IVAR, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by clone_method(), Init_Proc(), Init_vm_eval(), rb_add_method_cfunc(), rb_attr(), rb_define_notimplement_method_id(), rb_export_method(), rb_mod_define_method(), rb_undef(), rb_undef_alloc_func(), rb_undef_method(), and vm_define_method().

void rb_add_method_cfunc | ( | VALUE | klass,
|  | ID | mid,
|  | VALUE(*)(ANYARGS) | func,
|  | int | argc,
|  | rb_method_flag_t | noex
| ) |  |

Definition at line 76 of file vm_method.c.

References rb_method_cfunc_struct::argc, argc, rb_method_cfunc_struct::func, func, rb_add_method(), rb_define_notimplement_method_id(), rb_f_notimplement(), and VM_METHOD_TYPE_CFUNC.

Referenced by rb_define_alloc_func(), rb_define_method(), rb_define_method_id(), rb_define_private_method(), and rb_define_protected_method().

void rb_alias | ( | VALUE | klass,
|  | ID | name,
|  | ID | def
| ) |  |

Definition at line 888 of file vm_method.c.

References rb_method_entry_struct::def, rb_method_entry_struct::flag, cache_entry::klass, NIL_P, NOEX_UNDEF, rb_method_definition_struct::original_id, rb_cObject, rb_eTypeError, rb_frozen_class_p(), rb_method_entry_set(), rb_print_undef(), rb_raise(), rb_secure(), RCLASS_SUPER, search_method(), T_MODULE, rb_method_definition_struct::type, TYPE, UNDEFINED_METHOD_ENTRY_P, and VM_METHOD_TYPE_ZSUPER.

Referenced by each_attr_def(), Init_signal(), Init_strscan(), m_core_set_method_alias(), rb_define_alias(), and rb_mod_alias_method().

void rb_attr | ( | VALUE | klass,
|  | ID | id,
|  | int | read,
|  | int | write,
|  | int | ex
| ) |  |

Definition at line 558 of file vm_method.c.

References name, NOEX_MODFUNC, NOEX_PRIVATE, NOEX_PROTECTED, NOEX_PUBLIC, rb_add_method(), rb_eArgError, rb_enc_copy(), rb_id2name(), rb_id2str(), rb_id_attrset(), rb_intern_str(), rb_is_const_id(), rb_is_local_id(), rb_name_error(), rb_raise(), rb_sprintf(), rb_warning(), SCOPE_CHECK, SCOPE_TEST, VM_METHOD_TYPE_ATTRSET, and VM_METHOD_TYPE_IVAR.

Referenced by cbsubst_table_setup(), Init_ossl_asn1(), Init_ossl_pkcs12(), Init_ossl_pkcs7(), Init_ossl_ssl(), Init_ossl_x509ext(), Init_ossl_x509store(), rb_define_attr(), rb_mod_attr(), rb_mod_attr_accessor(), rb_mod_attr_reader(), and rb_mod_attr_writer().

void rb_clear_cache | ( | void |  | ) |

Definition at line 40 of file vm_method.c.

References rb_vm_change_state().

Referenced by rb_include_module().

void rb_clear_cache_by_class | ( | VALUE | klass | ) |

Definition at line 58 of file vm_method.c.

References rb_vm_change_state().

Referenced by obj_free(), set_const_visibility(), and set_method_visibility().

static void rb_clear_cache_by_id | ( | ID | id | ) |

static

Definition at line 52 of file vm_method.c.

References rb_vm_change_state().

Referenced by rb_method_entry_make().

static void rb_clear_cache_for_undef | ( | VALUE | klass,
|  | ID | id
| ) |  |

static

Definition at line 46 of file vm_method.c.

References rb_vm_change_state().

Referenced by remove_method().

void rb_define_alloc_func | ( | VALUE | klass,
|  | VALUE(*)(VALUE) | func
| ) |  |

Definition at line 337 of file vm_method.c.

References Check_Type, func, ID_ALLOCATOR, NOEX_PRIVATE, rb_add_method_cfunc(), rb_singleton_class(), and T_CLASS.

static void rb_define_notimplement_method_id | ( | VALUE | mod,
|  | ID | id,
|  | rb_method_flag_t | noex
| ) |  |

static

Definition at line 70 of file vm_method.c.

References rb_add_method(), and VM_METHOD_TYPE_NOTIMPLEMENTED.

Referenced by rb_add_method_cfunc().

void rb_disable_super | ( | VALUE | klass,
|  | const char * | name
| ) |  |

Definition at line 497 of file vm_method.c.

void rb_enable_super | ( | VALUE | klass,
|  | const char * | name
| ) |  |

Definition at line 503 of file vm_method.c.

References rb_warning().

static void rb_export_method | ( | VALUE | klass,
|  | ID | name,
|  | rb_method_flag_t | noex
| ) |  |

static

Definition at line 509 of file vm_method.c.

References rb_method_entry_struct::flag, rb_method_entry_struct::klass, cache_entry::me, rb_add_method(), rb_cObject, rb_print_undef(), rb_secure(), rb_vm_check_redefinition_opt_method(), search_method(), T_MODULE, TYPE, UNDEFINED_METHOD_ENTRY_P, and VM_METHOD_TYPE_ZSUPER.

Referenced by set_method_visibility().

VALUE rb_f_notimplement | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |

Definition at line 64 of file vm_method.c.

References rb_notimplement().

Referenced by Init_bug(), rb_add_method(), and rb_add_method_cfunc().

void rb_free_method_entry | ( | rb_method_entry_t * | me | ) |

Definition at line 142 of file vm_method.c.

References rb_method_definition_struct::alias_count, rb_method_entry_struct::def, and xfree().

Referenced by free_method_entry_i(), and rb_sweep_method_entry().

void rb_gc_mark_unlinked_live_method_entries | ( | void * | pvm | ) |

Definition at line 99 of file vm_method.c.

References rb_method_entry_struct::mark, unlinked_method_entry_list_entry::me, unlinked_method_entry_list_entry::next, rb_mark_method_entry(), and rb_vm_struct::unlinked_method_entry_list.

Referenced by gc_marks().

rb_alloc_func_t rb_get_alloc_func | ( | VALUE | klass | ) |

Definition at line 352 of file vm_method.c.

References rb_method_definition_struct::body, rb_method_definition_struct::cfunc, Check_Type, CLASS_OF, rb_method_entry_struct::def, rb_method_cfunc_struct::func, ID_ALLOCATOR, unlinked_method_entry_list_entry::me, rb_method_entry(), T_CLASS, rb_method_definition_struct::type, and VM_METHOD_TYPE_CFUNC.

Referenced by obj_alloc_by_path(), r_leave(), rb_marshal_define_compat(), and w_object().

int rb_method_basic_definition_p | ( | VALUE | klass,
|  | ID | id
| ) |  |

Definition at line 1194 of file vm_method.c.

References rb_method_entry_struct::flag, cache_entry::me, NOEX_BASIC, and rb_method_entry().

Referenced by check_funcall(), method_missing(), mnew(), raise_method_missing(), rb_hash_aref(), rb_obj_respond_to(), and rb_p().

int rb_method_boundp | ( | VALUE | klass,
|  | ID | id,
|  | int | ex
| ) |  |

Definition at line 539 of file vm_method.c.

References rb_method_entry_struct::def, FALSE, rb_method_entry_struct::flag, cache_entry::me, NOEX_PRIVATE, NOEX_RESPONDS, rb_method_entry(), rb_method_definition_struct::type, and VM_METHOD_TYPE_NOTIMPLEMENTED.

Referenced by basic_obj_respond_to(), and rb_mod_method_defined().

static int rb_method_definition_eq | ( | const rb_method_definition_t * | d1,
|  | const rb_method_definition_t * | d2
| ) |  |

static

Definition at line 854 of file vm_method.c.

References rb_method_cfunc_struct::argc, rb_method_definition_struct::attr, rb_method_definition_struct::body, rb_method_definition_struct::cfunc, rb_method_cfunc_struct::func, rb_method_attr_struct::id, rb_method_definition_struct::iseq, rb_method_definition_struct::optimize_type, rb_method_definition_struct::original_id, rb_method_definition_struct::proc, rb_bug(), rb_equal(), RTEST, rb_method_definition_struct::type, VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_IVAR, VM_METHOD_TYPE_MISSING, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by rb_method_entry_eq(), and rb_method_entry_make().

rb_method_entry_t* rb_method_entry | ( | VALUE | klass,
|  | ID | id
| ) |  |

Definition at line 416 of file vm_method.c.

References cache, EXPR1, cache_entry::filled_version, GET_VM_STATE_VERSION, cache_entry::klass, cache_entry::me, cache_entry::mid, and rb_method_entry_get_without_cache().

Referenced by check_definition(), check_funcall(), mnew(), rb_get_alloc_func(), rb_method_basic_definition_p(), rb_method_boundp(), rb_mod_method_arity(), rb_obj_basic_to_s_p(), rb_search_method_entry(), vm_call0(), vm_call_method(), vm_call_super(), and vm_method_search().

int rb_method_entry_eq | ( | const rb_method_entry_t * | m1,
|  | const rb_method_entry_t * | m2
| ) |  |

Definition at line 848 of file vm_method.c.

References rb_method_entry_struct::def, and rb_method_definition_eq().

Referenced by method_eq().

rb_method_entry_t* rb_method_entry_get_without_cache | ( | VALUE | klass,
|  | ID | id
| ) |  |

Definition at line 391 of file vm_method.c.

References cache, EXPR1, cache_entry::filled_version, GET_VM_STATE_VERSION, id, cache_entry::klass, cache_entry::me, unlinked_method_entry_list_entry::me, cache_entry::mid, ruby_running, search_method(), and UNDEFINED_METHOD_ENTRY_P.

Referenced by rb_method_entry().

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

Definition at line 161 of file vm_method.c.

References rb_method_definition_struct::alias_count, ALLOC, attached, rb_method_definition_struct::body, rb_method_entry_struct::called_id, rb_method_entry_struct::def, rb_iseq_struct::filename, FL_SINGLETON, FL_TEST, rb_method_entry_struct::flag, ID_ALLOCATOR, rb_iseq_struct::insn_info_table, rb_method_definition_struct::iseq, rb_method_entry_struct::klass, rb_method_entry_struct::mark, unlinked_method_entry_list_entry::me, NIL_P, NOEX_PRIVATE, NOEX_WITH_SAFE, OBJ_UNTRUSTED, object_id, rb_method_definition_struct::original_id, rb_method_definition_struct::proc, rb_check_frozen, rb_class2name(), rb_clear_cache_by_id(), rb_cObject, rb_compile_warning(), rb_eSecurityError, rb_id2name(), rb_intern, rb_iseq_first_lineno(), rb_ivar_get(), rb_method_definition_eq(), rb_proc_get_iseq(), rb_raise(), rb_safe_level, rb_unlink_method_entry(), rb_vm_check_redefinition_opt_method(), rb_warn(), rb_warning(), RCLASS_M_TBL, RSTRING_PTR, RTEST, ruby_verbose, st_insert, st_lookup, rb_method_definition_struct::type, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by rb_add_method(), and rb_method_entry_set().

rb_method_entry_t* rb_method_entry_set | ( | VALUE | klass,
|  | ID | mid,
|  | const rb_method_entry_t * | me,
|  | rb_method_flag_t | noex
| ) |  |

Definition at line 328 of file vm_method.c.

References rb_method_entry_struct::def, method_added(), rb_method_entry_make(), rb_method_definition_struct::type, type, and VM_METHOD_TYPE_UNDEF.

Referenced by clone_method(), rb_alias(), rb_mod_define_method(), and rb_mod_modfunc().

static VALUE rb_mod_alias_method | ( | VALUE | mod,
|  | VALUE | newname,
|  | VALUE | oldname
| ) |  |

static

Definition at line 946 of file vm_method.c.

References mod, rb_alias(), and rb_to_id().

Referenced by Init_eval_method().

static VALUE rb_mod_method_defined | ( | VALUE | mod,
|  | VALUE | mid
| ) |  |

static

Definition at line 728 of file vm_method.c.

References Qfalse, Qtrue, rb_method_boundp(), and rb_to_id().

Referenced by Init_eval_method().

static VALUE rb_mod_modfunc | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | module
| ) |  |

static

Definition at line 1151 of file vm_method.c.

References argc, rb_method_entry_struct::def, i, id, cache_entry::me, NOEX_MODFUNC, NOEX_PRIVATE, NOEX_PUBLIC, rb_cObject, rb_eTypeError, rb_method_entry_set(), rb_print_undef(), rb_raise(), rb_singleton_class(), rb_to_id(), RCLASS_SUPER, SCOPE_SET, search_method(), secure_visibility(), set_method_visibility(), T_MODULE, rb_method_definition_struct::type, TYPE, UNDEFINED_METHOD_ENTRY_P, and VM_METHOD_TYPE_ZSUPER.

Referenced by Init_eval_method().

static VALUE rb_mod_private | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | module
| ) |  |

static

Definition at line 1043 of file vm_method.c.

References NOEX_PRIVATE, SCOPE_SET, secure_visibility(), and set_method_visibility().

Referenced by Init_eval_method(), and top_private().

static VALUE rb_mod_private_method | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |

static

Definition at line 1086 of file vm_method.c.

References CLASS_OF, NOEX_PRIVATE, and set_method_visibility().

Referenced by Init_eval_method().

static VALUE rb_mod_private_method_defined | ( | VALUE | mod,
|  | VALUE | mid
| ) |  |

static

Definition at line 810 of file vm_method.c.

References check_definition(), NOEX_PRIVATE, and rb_to_id().

Referenced by Init_eval_method().

static VALUE rb_mod_protected | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | module
| ) |  |

static

Definition at line 1011 of file vm_method.c.

References NOEX_PROTECTED, SCOPE_SET, secure_visibility(), and set_method_visibility().

Referenced by Init_eval_method().

static VALUE rb_mod_protected_method_defined | ( | VALUE | mod,
|  | VALUE | mid
| ) |  |

static

Definition at line 842 of file vm_method.c.

References check_definition(), NOEX_PROTECTED, and rb_to_id().

Referenced by Init_eval_method().

static VALUE rb_mod_public | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | module
| ) |  |

static

Definition at line 988 of file vm_method.c.

References NOEX_PUBLIC, SCOPE_SET, secure_visibility(), and set_method_visibility().

Referenced by Init_eval_method(), and top_public().

static VALUE rb_mod_public_method | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj
| ) |  |

static

Definition at line 1063 of file vm_method.c.

References CLASS_OF, NOEX_PUBLIC, and set_method_visibility().

Referenced by Init_eval_method().

static VALUE rb_mod_public_method_defined | ( | VALUE | mod,
|  | VALUE | mid
| ) |  |

static

Definition at line 778 of file vm_method.c.

References check_definition(), NOEX_PUBLIC, and rb_to_id().

Referenced by Init_eval_method().

static VALUE rb_mod_remove_method | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | mod
| ) |  |

static

Definition at line 483 of file vm_method.c.

References argc, i, mod, rb_to_id(), and remove_method().

Referenced by Init_eval_method().

static VALUE rb_mod_undef_method | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | mod
| ) |  |

static

Definition at line 692 of file vm_method.c.

References argc, i, mod, rb_to_id(), and rb_undef().

Referenced by Init_eval_method().

int rb_obj_respond_to | ( | VALUE | obj,
|  | ID | id,
|  | int | priv
| ) |  |

Definition at line 1218 of file vm_method.c.

References basic_obj_respond_to(), CLASS_OF, ID2SYM, idRespond_to, Qtrue, rb_funcall(), rb_method_basic_definition_p(), and RTEST.

Referenced by ary2list(), ary2list2(), get_eval_string_core(), and rb_respond_to().

void rb_remove_method | ( | VALUE | klass,
|  | const char * | name
| ) |  |

Definition at line 469 of file vm_method.c.

References rb_intern, and remove_method().

void rb_remove_method_id | ( | VALUE | klass,
|  | ID | mid
| ) |  |

Definition at line 463 of file vm_method.c.

References remove_method().

Referenced by num_sadded().

int rb_respond_to | ( | VALUE | obj,
|  | ID | id
| ) |  |

Definition at line 1231 of file vm_method.c.

References FALSE, and rb_obj_respond_to().

Referenced by check_funcall_failed(), copy_stream_body(), copy_stream_fallback_body(), define_final(), discrete_object_p(), gzfile_close(), gzfile_write_raw(), hash_equal(), marshal_dump(), marshal_load(), must_respond_to(), num_exact(), ole_search_handler_method(), ossl_to_der_if_possible(), parse(), r_object0(), range_values(), rb_ary_equal(), rb_econv_prepare_options(), rb_f_open(), rb_gzreader_initialize(), rb_gzwriter_flush(), rb_gzwriter_initialize(), rb_range_values(), rb_str_cmp_m(), rb_str_equal(), readline_s_set_completion_proc(), syck_emitter_reset(), syck_map_add_m(), syck_parser_assign_io(), syck_parser_bufsize_set(), syck_resolver_transfer(), syck_seq_add_m(), syserr_eqq(), TkStringValue(), and w_object().

void rb_sweep_method_entry | ( | void * | pvm | ) |

Definition at line 113 of file vm_method.c.

References rb_method_entry_struct::mark, unlinked_method_entry_list_entry::me, unlinked_method_entry_list_entry::next, rb_free_method_entry(), rb_vm_struct::unlinked_method_entry_list, and xfree().

Referenced by before_gc_sweep().

void rb_undef | ( | VALUE | klass,
|  | ID | id
| ) |  |

Definition at line 602 of file vm_method.c.

References attached, CALL_METHOD_HOOK, FL_SINGLETON, FL_TEST, cache_entry::klass, cache_entry::me, NIL_P, NOEX_PUBLIC, OBJ_UNTRUSTED, object_id, rb_add_method(), rb_class2name(), rb_cObject, rb_eSecurityError, rb_eTypeError, rb_frozen_class_p(), rb_id2name(), rb_ivar_get(), rb_name_error(), rb_raise(), rb_safe_level, rb_secure(), rb_vm_cbase(), rb_warn(), search_method(), T_CLASS, T_MODULE, TYPE, undefined, UNDEFINED_METHOD_ENTRY_P, and VM_METHOD_TYPE_UNDEF.

Referenced by Init_syck(), m_core_undef_method(), and rb_mod_undef_method().

void rb_undef_alloc_func | ( | VALUE | klass | ) |

Definition at line 345 of file vm_method.c.

References Check_Type, ID_ALLOCATOR, NOEX_UNDEF, rb_add_method(), rb_singleton_class(), T_CLASS, and VM_METHOD_TYPE_UNDEF.

Referenced by Init_Binding(), Init_Encoding(), Init_Numeric(), Init_Object(), Init_Proc(), Init_String(), Init_Struct(), Init_VM(), Init_zlib(), and ruby_Init_Continuation_body().

void rb_unlink_method_entry | ( | rb_method_entry_t * | me | ) |

Definition at line 90 of file vm_method.c.

References ALLOC, GET_VM, unlinked_method_entry_list_entry::me, and unlinked_method_entry_list_entry::next.

Referenced by rb_method_entry_make(), and remove_method().

static void rb_vm_check_redefinition_opt_method | ( | const rb_method_entry_t * | me | ) |

static

Referenced by rb_export_method(), rb_method_entry_make(), and remove_method().

static void remove_method | ( | VALUE | klass,
|  | ID | mid
| ) |  |

static

Definition at line 430 of file vm_method.c.

References CALL_METHOD_HOOK, rb_method_entry_struct::def, cache_entry::me, OBJ_UNTRUSTED, object_id, rb_check_frozen, rb_class2name(), rb_clear_cache_for_undef(), rb_cObject, rb_eSecurityError, rb_id2name(), rb_name_error(), rb_raise(), rb_safe_level, rb_secure(), rb_unlink_method_entry(), rb_vm_check_redefinition_opt_method(), rb_warn(), RCLASS_M_TBL, removed, st_delete, st_lookup, rb_method_definition_struct::type, and VM_METHOD_TYPE_UNDEF.

Referenced by rb_mod_remove_method(), rb_remove_method(), and rb_remove_method_id().

static rb_method_entry_t* search_method | ( | VALUE | klass,
|  | ID | id
| ) |  |

static

Definition at line 367 of file vm_method.c.

References RCLASS_M_TBL, RCLASS_SUPER, and st_lookup.

Referenced by rb_alias(), rb_export_method(), rb_method_entry_get_without_cache(), rb_mod_modfunc(), and rb_undef().

static void secure_visibility | ( | VALUE | self | ) |

static

Definition at line 953 of file vm_method.c.

References OBJ_UNTRUSTED, rb_eSecurityError, rb_raise(), and rb_safe_level.

Referenced by rb_mod_modfunc(), rb_mod_private(), rb_mod_protected(), rb_mod_public(), and set_method_visibility().

static void set_method_visibility | ( | VALUE | self,
|  | int | argc,
|  | VALUE * | argv,
|  | rb_method_flag_t | ex
| ) |  |

static

Definition at line 962 of file vm_method.c.

References argc, i, rb_clear_cache_by_class(), rb_export_method(), rb_frame_callee(), rb_id2name(), rb_to_id(), rb_warning(), and secure_visibility().

Referenced by rb_mod_modfunc(), rb_mod_private(), rb_mod_private_method(), rb_mod_protected(), rb_mod_public(), and rb_mod_public_method().

static VALUE top_private | ( | int | argc,
|  | VALUE * | argv
| ) |  |

static

Definition at line 1109 of file vm_method.c.

References rb_cObject, and rb_mod_private().

Referenced by Init_eval_method().

static VALUE top_public | ( | int | argc,
|  | VALUE * | argv
| ) |  |

static

Definition at line 1103 of file vm_method.c.

References rb_cObject, and rb_mod_public().

Referenced by Init_eval_method().

static void vm_clear_global_method_cache | ( | void |  | ) |

static

Definition at line 27 of file vm_method.c.

References cache, CACHE_SIZE, and cache_entry::filled_version.

## Variable Documentation

ID added

static

Definition at line 13 of file vm_method.c.

Referenced by Init_eval_method(), and method_added().

ID attached

static

Definition at line 13 of file vm_method.c.

Referenced by Init_eval_method(), rb_method_entry_make(), and rb_undef().

struct cache_entry cache[CACHE_SIZE]

static

Definition at line 22 of file vm_method.c.

Referenced by rb_method_entry(), rb_method_entry_get_without_cache(), and vm_clear_global_method_cache().

ID object_id

static

Definition at line 11 of file vm_method.c.

Referenced by Init_eval_method(), rb_method_entry_make(), rb_undef(), and remove_method().

ID removed

static

Definition at line 12 of file vm_method.c.

Referenced by exec_event_hooks(), Init_eval_method(), remove_method(), and thread_exec_event_hooks().

ID respond_to_missing

static

Definition at line 11 of file vm_method.c.

Referenced by basic_obj_respond_to(), and Init_eval_method().

ID singleton_added

static

Definition at line 13 of file vm_method.c.

Referenced by Init_eval_method().

ID singleton_removed

static

Definition at line 12 of file vm_method.c.

Referenced by Init_eval_method().

ID singleton_undefined

static

Definition at line 12 of file vm_method.c.

Referenced by Init_eval_method().

ID undefined

static

Definition at line 12 of file vm_method.c.

Referenced by Init_eval_method(), and rb_undef().