Data Structures | Defines | Functions | Variables

vm_method.c File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cache_entry

Defines

#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)
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)
static void rb_unlink_method_entry (rb_method_entry_t *me)
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_trb_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_trb_add_method (VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex)
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)
static rb_method_entry_tsearch_method (VALUE klass, ID id)
rb_method_entry_trb_method_entry_get_without_cache (VALUE klass, ID id)
rb_method_entry_trb_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 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]

Define 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.

#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 285 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)
#define VISI_CHECK (   x,
  f 
)    (((x)&NOEX_MASK) == (f))

Definition at line 762 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]
static VALUE check_definition ( VALUE  mod,
ID  mid,
rb_method_flag_t  noex 
) [static]
void Init_eval_method ( void   ) 
static void method_added ( VALUE  klass,
ID  mid 
) [static]

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

References basic_obj_respond_to(), id, rb_scan_args(), rb_to_id(), and RTEST.

Referenced by Init_eval_method().

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

Definition at line 1296 of file vm_method.c.

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 
)
void rb_add_method_cfunc ( VALUE  klass,
ID  mid,
VALUE(*)(ANYARGS)  func,
int  argc,
rb_method_flag_t  noex 
)
void rb_alias ( VALUE  klass,
ID  name,
ID  def 
)
void rb_attr ( VALUE  klass,
ID  id,
int  read,
int  write,
int  ex 
)
void rb_clear_cache ( void   ) 

Definition at line 26 of file vm_method.c.

References cache, cache_entry::me, cache_entry::mid, rb_vm_change_state(), and ruby_running.

Referenced by rb_include_module().

void rb_clear_cache_by_class ( VALUE  klass  ) 
static void rb_clear_cache_by_id ( ID  id  )  [static]

Definition at line 64 of file vm_method.c.

References cache, cache_entry::me, cache_entry::mid, rb_vm_change_state(), and ruby_running.

Referenced by rb_method_entry_make().

static void rb_clear_cache_for_undef ( VALUE  klass,
ID  id 
) [static]
void rb_define_alloc_func ( VALUE  klass,
VALUE(*)(VALUE func 
)
static void rb_define_notimplement_method_id ( VALUE  mod,
ID  id,
rb_method_flag_t  noex 
) [static]

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

void rb_enable_super ( VALUE  klass,
const char *  name 
)

Definition at line 528 of file vm_method.c.

References rb_warning().

static void rb_export_method ( VALUE  klass,
ID  name,
rb_method_flag_t  noex 
) [static]
VALUE rb_f_notimplement ( int  argc,
VALUE argv,
VALUE  obj 
)

Definition at line 104 of file vm_method.c.

References rb_notimplement().

Referenced by Init_bug(), and rb_add_method_cfunc().

void rb_free_method_entry ( rb_method_entry_t me  ) 
rb_alloc_func_t rb_get_alloc_func ( VALUE  klass  ) 
int rb_method_basic_definition_p ( VALUE  klass,
ID  id 
)
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 
) [static]
rb_method_entry_t* rb_method_entry ( VALUE  klass,
ID  id 
)
int rb_method_entry_eq ( const rb_method_entry_t m1,
const rb_method_entry_t m2 
)

Definition at line 873 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 
)
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* rb_method_entry_set ( VALUE  klass,
ID  mid,
const rb_method_entry_t me,
rb_method_flag_t  noex 
)
static VALUE rb_mod_alias_method ( VALUE  mod,
VALUE  newname,
VALUE  oldname 
) [static]

Definition at line 971 of file vm_method.c.

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

References rb_method_boundp(), and rb_to_id().

Referenced by Init_eval_method().

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

Definition at line 1063 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 1106 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 835 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 1031 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 867 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 1008 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 1083 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 803 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 508 of file vm_method.c.

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

References rb_to_id(), and rb_undef().

Referenced by Init_eval_method().

int rb_obj_respond_to ( VALUE  obj,
ID  id,
int  priv 
)
void rb_remove_method ( VALUE  klass,
const char *  name 
)

Definition at line 494 of file vm_method.c.

References rb_intern, and remove_method().

void rb_remove_method_id ( VALUE  klass,
ID  mid 
)

Definition at line 488 of file vm_method.c.

References remove_method().

Referenced by num_sadded().

int rb_respond_to ( VALUE  obj,
ID  id 
)
void rb_sweep_method_entry ( void *  pvm  ) 
void rb_undef ( VALUE  klass,
ID  id 
)
void rb_undef_alloc_func ( VALUE  klass  ) 
static void rb_unlink_method_entry ( rb_method_entry_t me  )  [static]
static void rb_vm_check_redefinition_opt_method ( const rb_method_entry_t me  )  [static]
static void remove_method ( VALUE  klass,
ID  mid 
) [static]
static rb_method_entry_t* search_method ( VALUE  klass,
ID  id 
) [static]
static void secure_visibility ( VALUE  self  )  [static]
static void set_method_visibility ( VALUE  self,
int  argc,
VALUE argv,
rb_method_flag_t  ex 
) [static]
static VALUE top_private ( int  argc,
VALUE argv 
) [static]

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

References rb_cObject, and rb_mod_public().

Referenced by Init_eval_method().


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]
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 Init_eval_method(), and remove_method().

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().

Definition at line 12 of file vm_method.c.

Referenced by Init_eval_method().

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().