Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Functions
vm_method.c File Reference
#include "id_table.h"

Go to the source code of this file.

Data Structures

struct  cache_entry
 

Macros

#define METHOD_DEBUG   0
 
#define GLOBAL_METHOD_CACHE(c, m)   (rb_bug("global method cache disabled improperly"), NULL)
 
#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 BOUND_PRIVATE   0x01
 
#define BOUND_RESPONDS   0x02
 
#define rb_intern(str)   rb_intern_const(str)
 
#define REPLICATE_METHOD(klass, id)
 

Functions

void rb_clear_constant_cache (void)
 
void rb_clear_method_cache_by_class (VALUE klass)
 
VALUE rb_f_notimplement (int argc, const VALUE *argv, VALUE obj)
 
void rb_add_method_cfunc (VALUE klass, ID mid, VALUE(*func)(ANYARGS), int argc, rb_method_visibility_t visi)
 
void rb_free_method_entry (const rb_method_entry_t *me)
 
rb_method_entry_trb_method_entry_create (ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def)
 
const rb_method_entry_trb_method_entry_clone (const rb_method_entry_t *src_me)
 
const rb_callable_method_entry_trb_method_entry_complement_defined_class (const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
 
void rb_method_entry_copy (rb_method_entry_t *dst, const rb_method_entry_t *src)
 
void rb_add_refined_method_entry (VALUE refined_class, ID mid)
 
rb_method_entry_trb_add_method (VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_visibility_t visi)
 
void rb_add_method_iseq (VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi)
 
rb_method_entry_trb_method_entry_set (VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_visibility_t visi)
 
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)
 
const rb_method_entry_trb_method_entry_at (VALUE klass, ID id)
 
const rb_method_entry_trb_method_entry (VALUE klass, ID id)
 
const rb_callable_method_entry_trb_callable_method_entry (VALUE klass, ID id)
 
const rb_method_entry_trb_method_entry_with_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const rb_callable_method_entry_trb_callable_method_entry_with_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const rb_method_entry_trb_method_entry_without_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const rb_callable_method_entry_trb_callable_method_entry_without_refinements (VALUE klass, ID id, VALUE *defined_class_ptr)
 
const rb_method_entry_trb_resolve_refined_method (VALUE refinements, const rb_method_entry_t *me)
 
const rb_callable_method_entry_trb_resolve_refined_method_callable (VALUE refinements, const rb_callable_method_entry_t *me)
 
void rb_remove_method_id (VALUE klass, ID mid)
 
void rb_remove_method (VALUE klass, const char *name)
 
int rb_method_boundp (VALUE klass, ID id, int ex)
 
void rb_scope_visibility_set (rb_method_visibility_t visi)
 
void rb_attr (VALUE klass, ID id, int read, int write, int ex)
 
void rb_undef (VALUE klass, ID id)
 
int rb_method_entry_eq (const rb_method_entry_t *m1, const rb_method_entry_t *m2)
 
st_index_t rb_hash_method_entry (st_index_t hash, const rb_method_entry_t *me)
 
void rb_alias (VALUE klass, ID alias_name, ID original_name)
 
int rb_method_basic_definition_p (VALUE klass, ID id)
 
int rb_obj_respond_to (VALUE obj, ID id, int priv)
 
int rb_respond_to (VALUE obj, ID id)
 
void Init_Method (void)
 
void Init_eval_method (void)
 

Macro Definition Documentation

◆ added

#define added   idMethod_added

Definition at line 32 of file vm_method.c.

◆ attached

#define attached   id__attached__

Definition at line 38 of file vm_method.c.

◆ BOUND_PRIVATE

#define BOUND_PRIVATE   0x01

Definition at line 1064 of file vm_method.c.

◆ BOUND_RESPONDS

#define BOUND_RESPONDS   0x02

Definition at line 1065 of file vm_method.c.

Referenced by rb_method_boundp().

◆ CALL_METHOD_HOOK

#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_funcallv(recv_class, hook_id, 1, &arg); \
} while (0)
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1210
#define FL_TEST(x, f)
Definition: ruby.h:1282
#define FL_SINGLETON
Definition: ruby.h:1208
unsigned long VALUE
Definition: ruby.h:85
#define attached
Definition: vm_method.c:38
#define ID2SYM(x)
Definition: ruby.h:383

Definition at line 605 of file vm_method.c.

◆ GLOBAL_METHOD_CACHE

#define GLOBAL_METHOD_CACHE (   c,
 
)    (rb_bug("global method cache disabled improperly"), NULL)

Definition at line 25 of file vm_method.c.

◆ METHOD_DEBUG

#define METHOD_DEBUG   0

Definition at line 7 of file vm_method.c.

◆ object_id

#define object_id   idObject_id

Definition at line 31 of file vm_method.c.

Referenced by rb_undef().

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ removed

#define removed   idMethod_removed

Definition at line 34 of file vm_method.c.

◆ REPLICATE_METHOD

#define REPLICATE_METHOD (   klass,
  id 
)
Value:
do { \
const rb_method_entry_t *me = rb_method_entry((klass), (id)); \
rb_method_entry_set((klass), (id), me, METHOD_ENTRY_VISI(me)); \
} while (0)
const rb_method_entry_t * rb_method_entry(VALUE klass, ID id)
Definition: vm_method.c:793
Definition: method.h:51
#define METHOD_ENTRY_VISI(me)
Definition: method.h:67

◆ ruby_running

#define ruby_running   (GET_VM()->running)

Definition at line 59 of file vm_method.c.

◆ singleton_added

#define singleton_added   idSingleton_method_added

Definition at line 33 of file vm_method.c.

◆ singleton_removed

#define singleton_removed   idSingleton_method_removed

Definition at line 35 of file vm_method.c.

◆ singleton_undefined

#define singleton_undefined   idSingleton_method_undefined

Definition at line 37 of file vm_method.c.

◆ UNDEF_ALLOC_FUNC

#define UNDEF_ALLOC_FUNC   ((rb_alloc_func_t)-1)

Definition at line 665 of file vm_method.c.

Referenced by rb_get_alloc_func(), and rb_undef_alloc_func().

◆ undefined

#define undefined   idMethod_undefined

Definition at line 36 of file vm_method.c.

Function Documentation

◆ Init_eval_method()

void Init_eval_method ( void  )

Definition at line 2086 of file vm_method.c.

References rb_define_method(), and rb_mKernel.

◆ Init_Method()

void Init_Method ( void  )

Definition at line 2061 of file vm_method.c.

References calloc, EXIT_FAILURE, getenv, NULL, and val.

◆ rb_add_method()

rb_method_entry_t* rb_add_method ( VALUE  klass,
ID  mid,
rb_method_type_t  type,
void *  opts,
rb_method_visibility_t  visi 
)

Definition at line 625 of file vm_method.c.

Referenced by rb_add_method_cfunc(), rb_add_method_iseq(), and rb_undef_method().

◆ rb_add_method_cfunc()

void rb_add_method_cfunc ( VALUE  klass,
ID  mid,
VALUE(*)(ANYARGS func,
int  argc,
rb_method_visibility_t  visi 
)

◆ rb_add_method_iseq()

void rb_add_method_iseq ( VALUE  klass,
ID  mid,
const rb_iseq_t iseq,
rb_cref_t cref,
rb_method_visibility_t  visi 
)

Definition at line 637 of file vm_method.c.

References rb_add_method(), and VM_METHOD_TYPE_ISEQ.

◆ rb_add_refined_method_entry()

void rb_add_refined_method_entry ( VALUE  refined_class,
ID  mid 
)

Definition at line 456 of file vm_method.c.

◆ rb_alias()

void rb_alias ( VALUE  klass,
ID  alias_name,
ID  original_name 
)

◆ rb_attr()

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

Definition at line 1137 of file vm_method.c.

References METHOD_VISI_PUBLIC.

Referenced by rb_define_attr().

◆ rb_callable_method_entry()

const rb_callable_method_entry_t* rb_callable_method_entry ( VALUE  klass,
ID  id 
)

Definition at line 833 of file vm_method.c.

References cache_entry::defined_class.

◆ rb_callable_method_entry_with_refinements()

const rb_callable_method_entry_t* rb_callable_method_entry_with_refinements ( VALUE  klass,
ID  id,
VALUE defined_class_ptr 
)

Definition at line 872 of file vm_method.c.

References cache_entry::defined_class.

◆ rb_callable_method_entry_without_refinements()

const rb_callable_method_entry_t* rb_callable_method_entry_without_refinements ( VALUE  klass,
ID  id,
VALUE defined_class_ptr 
)

Definition at line 886 of file vm_method.c.

References cache_entry::defined_class.

◆ rb_clear_constant_cache()

void rb_clear_constant_cache ( void  )

Definition at line 84 of file vm_method.c.

References INC_GLOBAL_CONSTANT_STATE.

Referenced by rb_const_remove().

◆ rb_clear_method_cache_by_class()

void rb_clear_method_cache_by_class ( VALUE  klass)

◆ rb_define_alloc_func()

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

Definition at line 668 of file vm_method.c.

References Check_Type, RCLASS_EXT, and T_CLASS.

Referenced by rb_undef_alloc_func().

◆ rb_f_notimplement()

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

Definition at line 116 of file vm_method.c.

References rb_notimplement(), and UNREACHABLE.

Referenced by rb_add_method_cfunc().

◆ rb_free_method_entry()

void rb_free_method_entry ( const rb_method_entry_t me)

Definition at line 168 of file vm_method.c.

◆ rb_get_alloc_func()

rb_alloc_func_t rb_get_alloc_func ( VALUE  klass)

Definition at line 681 of file vm_method.c.

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

Referenced by rb_marshal_define_compat().

◆ rb_hash_method_entry()

st_index_t rb_hash_method_entry ( st_index_t  hash,
const rb_method_entry_t me 
)

Definition at line 1519 of file vm_method.c.

◆ rb_method_basic_definition_p()

int rb_method_basic_definition_p ( VALUE  klass,
ID  id 
)

Definition at line 1879 of file vm_method.c.

References FALSE, cache_entry::me, METHOD_ENTRY_BASIC, rb_method_entry(), and TRUE.

Referenced by rb_hash_default_value(), and rb_p().

◆ rb_method_boundp()

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

◆ rb_method_entry()

const rb_method_entry_t* rb_method_entry ( VALUE  klass,
ID  id 
)

Definition at line 793 of file vm_method.c.

Referenced by rb_method_basic_definition_p().

◆ rb_method_entry_at()

const rb_method_entry_t* rb_method_entry_at ( VALUE  klass,
ID  id 
)

Definition at line 709 of file vm_method.c.

◆ rb_method_entry_clone()

const rb_method_entry_t* rb_method_entry_clone ( const rb_method_entry_t src_me)

Definition at line 396 of file vm_method.c.

◆ rb_method_entry_complement_defined_class()

const rb_callable_method_entry_t* rb_method_entry_complement_defined_class ( const rb_method_entry_t src_me,
ID  called_id,
VALUE  defined_class 
)

Definition at line 405 of file vm_method.c.

◆ rb_method_entry_copy()

void rb_method_entry_copy ( rb_method_entry_t dst,
const rb_method_entry_t src 
)

Definition at line 418 of file vm_method.c.

References rb_method_entry_struct::def.

◆ rb_method_entry_create()

rb_method_entry_t* rb_method_entry_create ( ID  called_id,
VALUE  klass,
rb_method_visibility_t  visi,
const rb_method_definition_t def 
)

Definition at line 387 of file vm_method.c.

◆ rb_method_entry_eq()

int rb_method_entry_eq ( const rb_method_entry_t m1,
const rb_method_entry_t m2 
)

Definition at line 1420 of file vm_method.c.

◆ rb_method_entry_set()

rb_method_entry_t* rb_method_entry_set ( VALUE  klass,
ID  mid,
const rb_method_entry_t me,
rb_method_visibility_t  visi 
)

Definition at line 660 of file vm_method.c.

◆ rb_method_entry_with_refinements()

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

Definition at line 866 of file vm_method.c.

◆ rb_method_entry_without_refinements()

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

Definition at line 880 of file vm_method.c.

Referenced by rb_method_boundp().

◆ rb_obj_respond_to()

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

Definition at line 1984 of file vm_method.c.

References CLASS_OF, and GET_THREAD.

Referenced by rb_respond_to().

◆ rb_remove_method()

void rb_remove_method ( VALUE  klass,
const char *  name 
)

Definition at line 999 of file vm_method.c.

◆ rb_remove_method_id()

void rb_remove_method_id ( VALUE  klass,
ID  mid 
)

Definition at line 993 of file vm_method.c.

◆ rb_resolve_refined_method()

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

Definition at line 940 of file vm_method.c.

◆ rb_resolve_refined_method_callable()

const rb_callable_method_entry_t* rb_resolve_refined_method_callable ( VALUE  refinements,
const rb_callable_method_entry_t me 
)

Definition at line 946 of file vm_method.c.

References rb_callable_method_entry_struct::defined_class.

◆ rb_respond_to()

int rb_respond_to ( VALUE  obj,
ID  id 
)

Definition at line 1994 of file vm_method.c.

References FALSE, and rb_obj_respond_to().

Referenced by ossl_to_der_if_possible(), rb_range_values(), and rb_str_equal().

◆ rb_scope_visibility_set()

void rb_scope_visibility_set ( rb_method_visibility_t  visi)

Definition at line 1125 of file vm_method.c.

◆ rb_undef()

void rb_undef ( VALUE  klass,
ID  id 
)

◆ rb_undef_alloc_func()

void rb_undef_alloc_func ( VALUE  klass)