vm_method.c File Reference

#include "method.h"

Go to the source code of this file.

Data Structures

struct  cache_entry

Defines

#define GLOBAL_METHOD_CACHE_SIZE   0x800
#define GLOBAL_METHOD_CACHE_MASK   0x7ff
#define GLOBAL_METHOD_CACHE_KEY(c, m)   ((((c)>>3)^(m))&GLOBAL_METHOD_CACHE_MASK)
#define GLOBAL_METHOD_CACHE(c, m)   (global_method_cache + GLOBAL_METHOD_CACHE_KEY(c,m))
#define NOEX_NOREDEF   0
#define object_id   idObject_id
#define added   idMethod_added
#define singleton_added   idSingleton_method_added
#define removed   idMethod_removed
#define singleton_removed   idSingleton_method_removed
#define undefined   idMethod_undefined
#define singleton_undefined   idSingleton_method_undefined
#define attached   id__attached__
#define ruby_running   (GET_VM()->running)
#define CALL_METHOD_HOOK(klass, hook, mid)
#define UNDEF_ALLOC_FUNC   ((rb_alloc_func_t)-1)
#define VISI_CHECK(x, f)   (((x)&NOEX_MASK) == (f))
#define rb_intern(str)   rb_intern_const(str)
#define REPLICATE_METHOD(klass, id, noex)

Functions

static void rb_vm_check_redefinition_opt_method (const rb_method_entry_t *me, VALUE klass)
static void rb_class_clear_method_cache (VALUE klass)
void rb_clear_cache (void)
void rb_clear_constant_cache (void)
void rb_clear_method_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)
static void release_method_definition (rb_method_definition_t *def)
void rb_free_method_entry (rb_method_entry_t *me)
static rb_method_entry_tsearch_method (VALUE klass, ID id, VALUE *defined_class_ptr)
static int rb_method_definition_eq (const rb_method_definition_t *d1, const rb_method_definition_t *d2)
static rb_method_entry_tlookup_method_table (VALUE klass, ID id)
static void make_method_entry_refined (rb_method_entry_t *me)
void rb_add_refined_method_entry (VALUE refined_class, ID mid)
static rb_method_entry_trb_method_entry_make (VALUE klass, ID mid, rb_method_type_t type, rb_method_definition_t *def, rb_method_flag_t noex, VALUE defined_class)
static void method_added (VALUE klass, ID mid)
static VALUE(*)(VALUE(*func)(ANYARGS), VALUE recv, int
argc, const VALUE *) 
call_cfunc_invoker_func (int argc)
static void setup_method_cfunc_struct (rb_method_cfunc_t *cfunc, VALUE(*func)(), int argc)
rb_method_entry_trb_add_method (VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex)
static rb_method_entry_tmethod_entry_set (VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_flag_t noex, VALUE defined_class)
rb_method_entry_trb_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)
rb_method_entry_trb_method_entry_at (VALUE klass, ID id)
rb_method_entry_trb_method_entry_get_without_cache (VALUE klass, ID id, VALUE *defined_class_ptr)
rb_method_entry_trb_method_entry (VALUE klass, ID id, VALUE *defined_class_ptr)
static rb_method_entry_tget_original_method_entry (VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr)
rb_method_entry_trb_resolve_refined_method (VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr)
rb_method_entry_trb_method_entry_with_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
rb_method_entry_trb_method_entry_without_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
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)
ID rb_check_attr_id (ID id)
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, VALUE 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)
static st_index_t rb_hash_method_definition (st_index_t hash, const rb_method_definition_t *def)
st_index_t rb_hash_method_entry (st_index_t hash, const rb_method_entry_t *me)
void rb_alias (VALUE klass, ID name, ID def)
static VALUE rb_mod_alias_method (VALUE mod, VALUE newname, VALUE oldname)
static void set_method_visibility (VALUE self, int argc, VALUE *argv, rb_method_flag_t ex)
static VALUE set_visibility (int argc, VALUE *argv, VALUE module, 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 struct cache_entry global_method_cache [GLOBAL_METHOD_CACHE_SIZE]


Define Documentation

#define added   idMethod_added

Definition at line 24 of file vm_method.c.

Referenced by getifaddrs(), and method_added().

#define attached   id__attached__

Definition at line 30 of file vm_method.c.

#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 373 of file vm_method.c.

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

#define GLOBAL_METHOD_CACHE ( c,
 )     (global_method_cache + GLOBAL_METHOD_CACHE_KEY(c,m))

Definition at line 13 of file vm_method.c.

Referenced by rb_method_entry(), and rb_method_entry_get_without_cache().

#define GLOBAL_METHOD_CACHE_KEY ( c,
 )     ((((c)>>3)^(m))&GLOBAL_METHOD_CACHE_MASK)

Definition at line 12 of file vm_method.c.

#define GLOBAL_METHOD_CACHE_MASK   0x7ff

Definition at line 9 of file vm_method.c.

#define GLOBAL_METHOD_CACHE_SIZE   0x800

Definition at line 6 of file vm_method.c.

#define NOEX_NOREDEF   0

Definition at line 16 of file vm_method.c.

Referenced by rb_method_entry_make().

#define object_id   idObject_id

Definition at line 23 of file vm_method.c.

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

#define rb_intern ( str   )     rb_intern_const(str)

#define removed   idMethod_removed

Definition at line 26 of file vm_method.c.

Referenced by remove_method().

#define REPLICATE_METHOD ( klass,
id,
noex   ) 

Value:

Referenced by Init_eval_method().

#define ruby_running   (GET_VM()->running)

Definition at line 41 of file vm_method.c.

Referenced by method_added(), and rb_method_entry_get_without_cache().

#define singleton_added   idSingleton_method_added

Definition at line 25 of file vm_method.c.

#define singleton_removed   idSingleton_method_removed

Definition at line 27 of file vm_method.c.

#define singleton_undefined   idSingleton_method_undefined

Definition at line 29 of file vm_method.c.

#define UNDEF_ALLOC_FUNC   ((rb_alloc_func_t)-1)

Definition at line 509 of file vm_method.c.

Referenced by rb_get_alloc_func(), and rb_undef_alloc_func().

#define undefined   idMethod_undefined

Definition at line 28 of file vm_method.c.

Referenced by bind_local_variable_get(), and rb_undef().

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

Definition at line 1037 of file vm_method.c.


Function Documentation

static int basic_obj_respond_to ( VALUE  obj,
ID  id,
int  pub 
) [inline, static]

Definition at line 1582 of file vm_method.c.

References args, CLASS_OF, FALSE, ID2SYM, idRespond_to_missing, NOEX_RESPONDS, Qfalse, Qtrue, rb_funcall2, rb_method_boundp(), RTEST, TRUE, and VALUE.

Referenced by obj_respond_to(), and rb_obj_respond_to().

static VALUE(*)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *) call_cfunc_invoker_func (  )  [static]

Definition at line 393 of file vm_method.c.

References call_cfunc_0(), call_cfunc_1(), call_cfunc_10(), call_cfunc_11(), call_cfunc_12(), call_cfunc_13(), call_cfunc_14(), call_cfunc_15(), call_cfunc_2(), call_cfunc_3(), call_cfunc_4(), call_cfunc_5(), call_cfunc_6(), call_cfunc_7(), call_cfunc_8(), call_cfunc_9(), call_cfunc_m1(), call_cfunc_m2(), and rb_bug().

Referenced by setup_method_cfunc_struct().

static VALUE check_definition ( VALUE  mod,
VALUE  mid,
rb_method_flag_t  noex 
) [static]

Definition at line 1040 of file vm_method.c.

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

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

static rb_method_entry_t* get_original_method_entry ( VALUE  refinements,
const rb_method_entry_t me,
VALUE *  defined_class_ptr 
) [static]

Definition at line 638 of file vm_method.c.

References rb_method_definition_struct::body, rb_method_entry_struct::called_id, rb_method_entry_struct::def, rb_method_entry_struct::klass, cache_entry::me, rb_method_definition_struct::orig_me, rb_method_entry(), rb_resolve_refined_method(), and RCLASS_SUPER.

Referenced by rb_resolve_refined_method().

void Init_eval_method ( void   ) 

Definition at line 1708 of file vm_method.c.

References idRespond_to, idRespond_to_missing, NOEX_PRIVATE, NOEX_PUBLIC, obj_respond_to(), obj_respond_to_missing(), rb_cModule, rb_define_method(), rb_define_private_method(), rb_eException, 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_singleton_class(), rb_vm_top_self(), REPLICATE_METHOD, top_private(), and top_public().

Referenced by Init_eval().

static rb_method_entry_t* lookup_method_table ( VALUE  klass,
ID  id 
) [inline, static]

Definition at line 188 of file vm_method.c.

References RCLASS_M_TBL, st_data_t, and st_lookup().

Referenced by rb_add_refined_method_entry(), rb_method_entry_at(), rb_method_entry_make(), and search_method().

static void make_method_entry_refined ( rb_method_entry_t me  )  [static]

Definition at line 201 of file vm_method.c.

References rb_method_definition_struct::alias_count, ALLOC, rb_method_definition_struct::body, rb_method_entry_struct::called_id, rb_method_entry_struct::def, rb_method_entry_struct::flag, rb_method_entry_struct::klass, unlinked_method_entry_list_entry::me, NOEX_PUBLIC, NOEX_WITH_SAFE, rb_method_definition_struct::orig_me, rb_method_definition_struct::original_id, rb_vm_check_redefinition_opt_method(), rb_method_definition_struct::type, and VM_METHOD_TYPE_REFINED.

Referenced by rb_add_refined_method_entry(), and rb_method_entry_make().

static void method_added ( VALUE  klass,
ID  mid 
) [static]

Definition at line 385 of file vm_method.c.

References added, CALL_METHOD_HOOK, and ruby_running.

Referenced by method_entry_set(), and rb_add_method().

static rb_method_entry_t* method_entry_set ( VALUE  klass,
ID  mid,
const rb_method_entry_t me,
rb_method_flag_t  noex,
VALUE  defined_class 
) [static]

Definition at line 493 of file vm_method.c.

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

Referenced by rb_alias(), and rb_method_entry_set().

static VALUE obj_respond_to ( int  argc,
VALUE *  argv,
VALUE  obj 
) [static]

Definition at line 1666 of file vm_method.c.

References args, basic_obj_respond_to(), CLASS_OF, id, ID2SYM, idRespond_to_missing, Qfalse, Qtrue, rb_check_id(), rb_funcall2, rb_method_basic_definition_p(), rb_scan_args(), rb_to_id(), RTEST, and VALUE.

Referenced by Init_eval_method().

static VALUE obj_respond_to_missing ( VALUE  obj,
VALUE  mid,
VALUE  priv 
) [static]

Definition at line 1702 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 428 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_method_cfunc_struct::func, GET_THREAD(), rb_method_attr_struct::id, INT2FIX, rb_control_frame_struct::iseq, rb_method_definition_struct::iseq, rb_iseq_struct::location, rb_method_attr_struct::location, unlinked_method_entry_list_entry::me, method_added(), rb_method_definition_struct::optimize_type, rb_method_definition_struct::orig_me, rb_method_definition_struct::original_id, rb_iseq_location_struct::path, rb_method_definition_struct::proc, Qfalse, Qundef, rb_ary_freeze(), rb_ary_new3, rb_bug(), rb_f_notimplement(), rb_method_entry_make(), RB_OBJ_WRITE, RB_OBJ_WRITTEN, rb_vm_get_ruby_level_next_cfp(), rb_vm_get_sourceline(), rb_iseq_struct::self, setup_method_cfunc_struct(), rb_method_definition_struct::type, VALUE, 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_REFINED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by clone_method(), Init_Proc(), Init_vm_eval(), rb_add_method_cfunc(), rb_add_refined_method_entry(), rb_attr(), rb_define_notimplement_method_id(), rb_export_method(), rb_mod_define_method(), rb_undef(), 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 99 of file vm_method.c.

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

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

void rb_add_refined_method_entry ( VALUE  refined_class,
ID  mid 
)

Definition at line 221 of file vm_method.c.

References lookup_method_table(), make_method_entry_refined(), unlinked_method_entry_list_entry::me, NOEX_PUBLIC, rb_add_method(), rb_clear_method_cache_by_class(), and VM_METHOD_TYPE_REFINED.

Referenced by add_refined_method_entry_i(), and rb_method_entry_make().

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

Definition at line 1244 of file vm_method.c.

References rb_method_entry_struct::def, rb_method_entry_struct::flag, method_entry_set(), NIL_P, NOEX_UNDEF, rb_method_definition_struct::original_id, rb_cObject, rb_eTypeError, rb_frozen_class_p(), rb_print_undef(), rb_raise(), RB_TYPE_P, RBASIC_CLASS, RCLASS_ORIGIN, RCLASS_SUPER, search_method(), T_ICLASS, T_MODULE, rb_method_definition_struct::type, UNDEFINED_METHOD_ENTRY_P, VALUE, 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 860 of file vm_method.c.

References NIL_P, NOEX_MODFUNC, NOEX_PRIVATE, NOEX_PROTECTED, NOEX_PUBLIC, PRIsVALUE, rb_add_method(), rb_check_attr_id(), rb_eArgError, rb_id2str(), rb_id_attrset(), rb_intern_str, rb_raise(), rb_sprintf(), rb_warning(), SCOPE_CHECK, SCOPE_TEST, VALUE, VM_METHOD_TYPE_ATTRSET, and VM_METHOD_TYPE_IVAR.

Referenced by cbsubst_table_setup(), Init_Exception(), 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().

ID rb_check_attr_id ( ID  id  ) 

Definition at line 1956 of file object.c.

References QUOTE_ID, rb_is_attr_id(), and rb_name_error_str().

Referenced by rb_attr().

static void rb_class_clear_method_cache ( VALUE  klass  )  [static]

Definition at line 45 of file vm_method.c.

References rb_class_foreach_subclass(), rb_next_class_serial(), and RCLASS_SERIAL.

Referenced by rb_clear_method_cache_by_class().

void rb_clear_cache ( void   ) 

Definition at line 52 of file vm_method.c.

References INC_GLOBAL_CONSTANT_STATE, INC_GLOBAL_METHOD_STATE, and rb_warning().

void rb_clear_constant_cache ( void   ) 

Definition at line 60 of file vm_method.c.

References INC_GLOBAL_CONSTANT_STATE.

Referenced by include_modules_at(), rb_const_remove(), rb_const_set(), and set_const_visibility().

void rb_clear_method_cache_by_class ( VALUE  klass  ) 

Definition at line 66 of file vm_method.c.

References INC_GLOBAL_METHOD_STATE, Qundef, rb_cBasicObject, rb_class2name(), rb_class_clear_method_cache(), rb_cObject, rb_mKernel, rb_sourcefile, rb_sourceline(), RUBY_DTRACE_METHOD_CACHE_CLEAR, and RUBY_DTRACE_METHOD_CACHE_CLEAR_ENABLED.

Referenced by include_modules_at(), m_core_undef_method(), rb_add_refined_method_entry(), rb_export_method(), rb_method_entry_make(), rb_using_module(), and remove_method().

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

Definition at line 512 of file vm_method.c.

References Check_Type, RCLASS_EXT, and T_CLASS.

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

Definition at line 93 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 792 of file vm_method.c.

void rb_enable_super ( VALUE  klass,
const char *  name 
)

Definition at line 798 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 804 of file vm_method.c.

References rb_method_entry_struct::flag, cache_entry::me, rb_add_method(), rb_clear_method_cache_by_class(), rb_cObject, rb_print_undef(), RB_TYPE_P, rb_vm_check_redefinition_opt_method(), RCLASS_ORIGIN, search_method(), T_MODULE, UNDEFINED_METHOD_ENTRY_P, VALUE, VM_METHOD_TYPE_REFINED, and VM_METHOD_TYPE_ZSUPER.

Referenced by set_method_visibility().

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

Definition at line 85 of file vm_method.c.

References rb_notimplement(), and UNREACHABLE.

Referenced by rb_add_method(), and rb_add_method_cfunc().

void rb_free_method_entry ( rb_method_entry_t me  ) 

Definition at line 178 of file vm_method.c.

References rb_method_entry_struct::def, unlinked_method_entry_list_entry::me, release_method_definition(), 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 123 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_mark_roots().

rb_alloc_func_t rb_get_alloc_func ( VALUE  klass  ) 

Definition at line 525 of file vm_method.c.

References Check_Type, RCLASS_EXT, RCLASS_SUPER, T_CLASS, and UNDEF_ALLOC_FUNC.

Referenced by obj_alloc_by_klass(), r_fixup_compat(), rb_marshal_define_compat(), rb_obj_alloc(), and w_object().

static st_index_t rb_hash_method_definition ( st_index_t  hash,
const rb_method_definition_t def 
) [static]

Definition at line 1200 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_entry_struct::def, 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::orig_me, rb_method_definition_struct::original_id, rb_method_definition_struct::proc, rb_bug(), rb_hash_proc(), rb_hash_uint, 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_REFINED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by rb_hash_method_entry().

st_index_t rb_hash_method_entry ( st_index_t  hash,
const rb_method_entry_t me 
)

Definition at line 1238 of file vm_method.c.

References rb_method_entry_struct::def, cache_entry::me, and rb_hash_method_definition().

Referenced by method_hash().

int rb_method_basic_definition_p ( VALUE  klass,
ID  id 
)

Definition at line 1573 of file vm_method.c.

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

Referenced by check_funcall_missing(), hash_default_value(), make_no_method_exception(), method_missing(), mnew_from_me(), obj_respond_to(), rb_mod_const_get(), rb_obj_respond_to(), rb_p(), send_internal(), set_backtrace(), and vm_call_opt_send().

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

Definition at line 836 of file vm_method.c.

References rb_method_entry_struct::def, rb_method_entry_struct::flag, cache_entry::me, NOEX_PRIVATE, NOEX_PROTECTED, NOEX_RESPONDS, rb_method_entry_without_refinements(), 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 1162 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_entry_struct::def, 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::orig_me, 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_REFINED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

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

Definition at line 617 of file vm_method.c.

References cache_entry::class_serial, cache_entry::defined_class, GET_GLOBAL_METHOD_STATE, GLOBAL_METHOD_CACHE, cache_entry::me, cache_entry::method_state, cache_entry::mid, rb_method_entry_get_without_cache(), and RCLASS_EXT.

Referenced by check_definition(), check_funcall_respond_to(), check_redefined_method(), get_original_method_entry(), original_method_entry(), rb_method_basic_definition_p(), rb_method_entry_with_refinements(), rb_method_entry_without_refinements(), rb_obj_basic_to_s_p(), rb_resolve_refined_method(), rb_search_method_entry(), vm_call0_body(), vm_call_method(), vm_call_method_missing(), vm_call_super(), vm_search_method(), and vm_search_super_method().

rb_method_entry_t* rb_method_entry_at ( VALUE  klass,
ID  id 
)

Definition at line 552 of file vm_method.c.

References lookup_method_table().

Referenced by rb_obj_singleton_method().

int rb_method_entry_eq ( const rb_method_entry_t m1,
const rb_method_entry_t m2 
)

Definition at line 1156 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,
VALUE *  defined_class_ptr 
)

Definition at line 564 of file vm_method.c.

References BUILTIN_TYPE, cache_entry::class_serial, cache_entry::defined_class, FL_SINGLETON, GET_GLOBAL_METHOD_STATE, GLOBAL_METHOD_CACHE, rb_method_entry_struct::klass, cache_entry::me, unlinked_method_entry_list_entry::me, cache_entry::method_state, cache_entry::mid, RBASIC, RCLASS_EXT, ruby_running, search_method(), T_CLASS, T_ICLASS, UNDEFINED_METHOD_ENTRY_P, and VALUE.

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,
VALUE  defined_class 
) [static]

Definition at line 236 of file vm_method.c.

References rb_method_definition_struct::alias_count, ALLOC, rb_method_definition_struct::attr, rb_method_definition_struct::body, rb_method_entry_struct::called_id, rb_method_entry_struct::def, FIX2INT, FL_SINGLETON, FL_TEST, rb_method_entry_struct::flag, idRespond_to_missing, rb_method_definition_struct::iseq, rb_method_entry_struct::klass, rb_iseq_struct::line_info_table, rb_method_attr_struct::location, rb_iseq_struct::location, lookup_method_table(), make_method_entry_refined(), rb_method_entry_struct::mark, unlinked_method_entry_list_entry::me, NIL_P, NOEX_NOREDEF, NOEX_PRIVATE, NOEX_WITH_SAFE, object_id, rb_method_definition_struct::original_id, rb_iseq_location_struct::path, PRIsVALUE, rb_method_definition_struct::proc, Qundef, rb_add_refined_method_entry(), rb_check_frozen, rb_class_name(), rb_clear_method_cache_by_class(), rb_cObject, rb_compile_warning(), rb_eTypeError, rb_id2name(), rb_id2str(), rb_iseq_first_lineno(), rb_method_definition_eq(), RB_OBJ_WRITE, RB_OBJ_WRITTEN, rb_proc_get_iseq(), rb_raise(), rb_refinement_module_get_refined_class(), rb_unlink_method_entry(), rb_vm_check_redefinition_opt_method(), rb_warn(), rb_warning(), RCLASS_M_TBL, RCLASS_ORIGIN, RMODULE_IS_REFINEMENT, RSTRING_PTR, RTEST, ruby_verbose, search_method(), rb_iseq_struct::self, st_data_t, st_insert(), st_lookup(), rb_method_definition_struct::type, VALUE, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_IVAR, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_REFINED, VM_METHOD_TYPE_UNDEF, and VM_METHOD_TYPE_ZSUPER.

Referenced by method_entry_set(), and rb_add_method().

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 504 of file vm_method.c.

References unlinked_method_entry_list_entry::me, and method_entry_set().

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

rb_method_entry_t* rb_method_entry_with_refinements ( VALUE  klass,
ID  id,
VALUE *  defined_class_ptr 
)

Definition at line 683 of file vm_method.c.

References rb_method_entry_struct::def, cache_entry::me, Qnil, rb_method_entry(), rb_resolve_refined_method(), rb_vm_cref(), rb_method_definition_struct::type, VALUE, and VM_METHOD_TYPE_REFINED.

Referenced by check_match().

rb_method_entry_t* rb_method_entry_without_refinements ( VALUE  klass,
ID  id,
VALUE *  defined_class_ptr 
)

Definition at line 701 of file vm_method.c.

References rb_method_entry_struct::def, cache_entry::me, Qnil, rb_method_entry(), rb_resolve_refined_method(), rb_method_definition_struct::type, UNDEFINED_METHOD_ENTRY_P, VALUE, and VM_METHOD_TYPE_REFINED.

Referenced by mnew(), mnew_from_me(), rb_method_boundp(), and vm_call_opt_send().

static VALUE rb_mod_alias_method ( VALUE  mod,
VALUE  newname,
VALUE  oldname 
) [static]

Definition at line 1306 of file vm_method.c.

References rb_alias(), rb_check_id(), rb_print_undef_str(), and rb_to_id().

Referenced by Init_eval_method().

static VALUE rb_mod_method_defined ( VALUE  mod,
VALUE  mid 
) [static]

Definition at line 1027 of file vm_method.c.

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

Referenced by Init_eval_method().

static VALUE rb_mod_modfunc ( int  argc,
VALUE *  argv,
VALUE  module 
) [static]

Definition at line 1531 of file vm_method.c.

References rb_method_entry_struct::def, 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(), RB_TYPE_P, RCLASS_SUPER, SCOPE_SET, search_method(), set_method_visibility(), T_MODULE, rb_method_definition_struct::type, UNDEFINED_METHOD_ENTRY_P, VALUE, 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 1407 of file vm_method.c.

References NOEX_PRIVATE, and set_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 1449 of file vm_method.c.

References NOEX_PRIVATE, rb_singleton_class(), and set_method_visibility().

Referenced by Init_eval_method().

static VALUE rb_mod_private_method_defined ( VALUE  mod,
VALUE  mid 
) [static]

Definition at line 1116 of file vm_method.c.

References check_definition(), and NOEX_PRIVATE.

Referenced by Init_eval_method().

static VALUE rb_mod_protected ( int  argc,
VALUE *  argv,
VALUE  module 
) [static]

Definition at line 1380 of file vm_method.c.

References NOEX_PROTECTED, and set_visibility().

Referenced by Init_eval_method().

static VALUE rb_mod_protected_method_defined ( VALUE  mod,
VALUE  mid 
) [static]

Definition at line 1150 of file vm_method.c.

References check_definition(), and NOEX_PROTECTED.

Referenced by Init_eval_method().

static VALUE rb_mod_public ( int  argc,
VALUE *  argv,
VALUE  module 
) [static]

Definition at line 1362 of file vm_method.c.

References NOEX_PUBLIC, and set_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 1423 of file vm_method.c.

References NOEX_PUBLIC, rb_singleton_class(), and set_method_visibility().

Referenced by Init_eval_method().

static VALUE rb_mod_public_method_defined ( VALUE  mod,
VALUE  mid 
) [static]

Definition at line 1082 of file vm_method.c.

References check_definition(), and NOEX_PUBLIC.

Referenced by Init_eval_method().

static VALUE rb_mod_remove_method ( int  argc,
VALUE *  argv,
VALUE  mod 
) [static]

Definition at line 772 of file vm_method.c.

References rb_check_id(), rb_class2name(), rb_name_error_str(), remove_method(), RSTRING_PTR, and VALUE.

Referenced by Init_eval_method().

static VALUE rb_mod_undef_method ( int  argc,
VALUE *  argv,
VALUE  mod 
) [static]

Definition at line 984 of file vm_method.c.

References rb_check_id(), rb_method_name_error(), rb_undef(), and VALUE.

Referenced by Init_eval_method().

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

Definition at line 1600 of file vm_method.c.

References args, basic_obj_respond_to(), CLASS_OF, FL_SINGLETON, FL_TEST, ID2SYM, idRespond_to, NIL_P, NUM2INT, PRIsVALUE, Qtrue, QUOTE_ID, RARRAY_AREF, rb_compile_warn(), rb_funcall2, rb_method_basic_definition_p(), rb_mod_method_location(), rb_obj_method_arity(), rb_warn(), RSTRING_PTR, RTEST, ruby_verbose, and VALUE.

Referenced by ary2list(), ary2list2(), get_eval_string_core(), r_object0(), rb_respond_to(), should_be_callable(), and w_object().

void rb_remove_method ( VALUE  klass,
const char *  name 
)

Definition at line 756 of file vm_method.c.

References rb_intern, and remove_method().

void rb_remove_method_id ( VALUE  klass,
ID  mid 
)

Definition at line 750 of file vm_method.c.

References remove_method().

Referenced by num_sadded().

rb_method_entry_t* rb_resolve_refined_method ( VALUE  refinements,
const rb_method_entry_t me,
VALUE *  defined_class_ptr 
)

Definition at line 655 of file vm_method.c.

References rb_method_entry_struct::called_id, rb_method_entry_struct::def, find_refinement(), get_original_method_entry(), rb_method_entry_struct::klass, cache_entry::me, NIL_P, rb_method_entry(), rb_method_definition_struct::type, VALUE, and VM_METHOD_TYPE_REFINED.

Referenced by get_original_method_entry(), method_entry_i(), rb_method_entry_with_refinements(), and rb_method_entry_without_refinements().

int rb_respond_to ( VALUE  obj,
ID  id 
)

Definition at line 1639 of file vm_method.c.

References FALSE, and rb_obj_respond_to().

Referenced by check_funcall_failed(), copy_stream_body(), copy_stream_fallback_body(), discrete_object_p(), do_coerce(), encoding_table_get_name_core(), enum_zip(), enumerator_initialize(), generate_json(), gzfile_close(), gzfile_write_raw(), hash_equal(), lazy_flat_map_func(), lazy_zip(), marshal_dump(), marshal_load(), must_respond_to(), num_exact(), ole_search_handler_method(), ossl_to_der_if_possible(), parse(), 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_equal(), readline_s_set_completion_proc(), syserr_eqq(), and TkStringValue().

void rb_sweep_method_entry ( void *  pvm  ) 

Definition at line 137 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 gc_before_sweep().

void rb_undef ( VALUE  klass,
ID  id 
)

Definition at line 898 of file vm_method.c.

References attached, rb_method_definition_struct::body, CALL_METHOD_HOOK, rb_method_entry_struct::def, FL_SINGLETON, FL_TEST, cache_entry::me, NIL_P, NOEX_PUBLIC, object_id, rb_method_definition_struct::orig_me, PRIsVALUE, QUOTE_ID, rb_add_method(), rb_class_name(), rb_eTypeError, rb_frozen_class_p(), rb_id2name(), rb_ivar_get(), rb_name_error(), rb_raise(), RB_TYPE_P, rb_warn(), search_method(), T_CLASS, T_MODULE, rb_method_definition_struct::type, undefined, UNDEFINED_METHOD_ENTRY_P, VALUE, VM_METHOD_TYPE_REFINED, and VM_METHOD_TYPE_UNDEF.

Referenced by m_core_undef_method(), and rb_mod_undef_method().

void rb_undef_alloc_func ( VALUE  klass  ) 

Definition at line 519 of file vm_method.c.

References rb_define_alloc_func(), and UNDEF_ALLOC_FUNC.

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

void rb_unlink_method_entry ( rb_method_entry_t me  ) 

Definition at line 114 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,
VALUE  klass 
) [static]

static void release_method_definition ( rb_method_definition_t def  )  [static]

Definition at line 160 of file vm_method.c.

References rb_method_definition_struct::alias_count, rb_method_definition_struct::body, rb_method_entry_struct::def, rb_method_definition_struct::orig_me, rb_method_definition_struct::type, VM_METHOD_TYPE_REFINED, and xfree.

Referenced by rb_free_method_entry().

static void remove_method ( VALUE  klass,
ID  mid 
) [static]

Definition at line 721 of file vm_method.c.

References CALL_METHOD_HOOK, rb_method_entry_struct::def, key, cache_entry::me, object_id, rb_check_frozen, rb_class2name(), rb_clear_method_cache_by_class(), rb_id2name(), rb_name_error(), rb_unlink_method_entry(), rb_vm_check_redefinition_opt_method(), rb_warn(), RCLASS_M_TBL, RCLASS_ORIGIN, removed, st_data_t, st_delete(), st_lookup(), rb_method_definition_struct::type, VALUE, 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,
VALUE *  defined_class_ptr 
) [inline, static]

Definition at line 538 of file vm_method.c.

References lookup_method_table(), unlinked_method_entry_list_entry::me, and RCLASS_SUPER.

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

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

Definition at line 1317 of file vm_method.c.

References PRIsVALUE, QUOTE_ID, rb_check_id(), rb_export_method(), rb_frame_callee(), rb_print_undef_str(), rb_warning(), and VALUE.

Referenced by rb_mod_modfunc(), rb_mod_private_method(), rb_mod_public_method(), and set_visibility().

static VALUE set_visibility ( int  argc,
VALUE *  argv,
VALUE  module,
rb_method_flag_t  ex 
) [static]

Definition at line 1338 of file vm_method.c.

References SCOPE_SET, and set_method_visibility().

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

static void setup_method_cfunc_struct ( rb_method_cfunc_t cfunc,
VALUE(*)()  func,
int  argc 
) [static]

Definition at line 420 of file vm_method.c.

References rb_method_cfunc_struct::argc, call_cfunc_invoker_func(), rb_method_cfunc_struct::func, and rb_method_cfunc_struct::invoker.

Referenced by rb_add_method().

static VALUE top_private ( int  argc,
VALUE *  argv 
) [static]

Definition at line 1487 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 1469 of file vm_method.c.

References rb_cObject, and rb_mod_public().

Referenced by Init_eval_method().


Variable Documentation

struct cache_entry global_method_cache[GLOBAL_METHOD_CACHE_SIZE] [static]

Definition at line 40 of file vm_method.c.


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7