Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Enumerations | Functions
method.h File Reference
#include "internal.h"
Include dependency graph for method.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rb_scope_visi_struct
 
struct  rb_cref_struct
 
struct  rb_method_entry_struct
 
struct  rb_callable_method_entry_struct
 
struct  rb_method_iseq_struct
 
struct  rb_method_cfunc_struct
 
struct  rb_method_attr_struct
 
struct  rb_method_alias_struct
 
struct  rb_method_refined_struct
 
struct  rb_method_definition_struct
 

Macros

#define END_OF_ENUMERATION(key)   END_OF_##key##_PLACEHOLDER = 0
 
#define METHOD_ENTRY_VISI(me)   (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
 
#define METHOD_ENTRY_BASIC(me)   (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
 
#define METHOD_ENTRY_COMPLEMENTED(me)   ((me)->flags & IMEMO_FL_USER3)
 
#define METHOD_ENTRY_COMPLEMENTED_SET(me)   ((me)->flags = (me)->flags | IMEMO_FL_USER3)
 
#define rb_iseq_t   rb_iseq_t
 
#define UNDEFINED_METHOD_ENTRY_P(me)   (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
 
#define UNDEFINED_REFINED_METHOD_P(def)
 

Typedefs

typedef struct rb_scope_visi_struct rb_scope_visibility_t
 
typedef struct rb_cref_struct rb_cref_t
 
typedef struct rb_method_entry_struct rb_method_entry_t
 
typedef struct rb_callable_method_entry_struct rb_callable_method_entry_t
 
typedef struct rb_iseq_struct rb_iseq_t
 
typedef struct rb_method_iseq_struct rb_method_iseq_t
 
typedef struct rb_method_cfunc_struct rb_method_cfunc_t
 
typedef struct rb_method_attr_struct rb_method_attr_t
 
typedef struct rb_method_alias_struct rb_method_alias_t
 
typedef struct rb_method_refined_struct rb_method_refined_t
 
typedef struct rb_method_definition_struct rb_method_definition_t
 

Enumerations

enum  rb_method_visibility_t {
  METHOD_VISI_UNDEF = 0x00, METHOD_VISI_PUBLIC = 0x01, METHOD_VISI_PRIVATE = 0x02, METHOD_VISI_PROTECTED = 0x03,
  METHOD_VISI_MASK = 0x03
}
 
enum  rb_method_type_t {
  VM_METHOD_TYPE_ISEQ, VM_METHOD_TYPE_CFUNC, VM_METHOD_TYPE_ATTRSET, VM_METHOD_TYPE_IVAR,
  VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_ZSUPER, VM_METHOD_TYPE_ALIAS, VM_METHOD_TYPE_UNDEF,
  VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, VM_METHOD_TYPE_MISSING, VM_METHOD_TYPE_REFINED
}
 

Functions

static void METHOD_ENTRY_VISI_SET (rb_method_entry_t *me, rb_method_visibility_t visi)
 
static void METHOD_ENTRY_BASIC_SET (rb_method_entry_t *me, unsigned int basic)
 
static void METHOD_ENTRY_FLAGS_SET (rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
 
static void METHOD_ENTRY_FLAGS_COPY (rb_method_entry_t *dst, const rb_method_entry_t *src)
 
void rb_add_method_cfunc (VALUE klass, ID mid, VALUE(*func)(ANYARGS), int argc, 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)
 
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 *option, rb_method_visibility_t visi)
 
rb_method_entry_trb_method_entry_set (VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex)
 
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_at (VALUE obj, ID id)
 
const rb_method_entry_trb_method_entry (VALUE klass, ID id)
 
const rb_method_entry_trb_method_entry_with_refinements (VALUE klass, ID id)
 
const rb_method_entry_trb_method_entry_without_refinements (VALUE klass, ID id)
 
const rb_method_entry_trb_resolve_refined_method (VALUE refinements, const rb_method_entry_t *me)
 
const rb_callable_method_entry_trb_callable_method_entry (VALUE klass, ID id)
 
const rb_callable_method_entry_trb_callable_method_entry_with_refinements (VALUE klass, ID id)
 
const rb_callable_method_entry_trb_callable_method_entry_without_refinements (VALUE klass, ID id)
 
const rb_callable_method_entry_trb_resolve_refined_method_callable (VALUE refinements, const rb_callable_method_entry_t *me)
 
int rb_method_entry_arity (const rb_method_entry_t *me)
 
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)
 
VALUE rb_method_entry_location (const rb_method_entry_t *me)
 
VALUE rb_mod_method_location (VALUE mod, ID id)
 
VALUE rb_obj_method_location (VALUE obj, ID id)
 
void rb_free_method_entry (const rb_method_entry_t *me)
 
void rb_sweep_method_entry (void *vm)
 
const rb_method_entry_trb_method_entry_clone (const rb_method_entry_t *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_scope_visibility_set (rb_method_visibility_t)
 

Macro Definition Documentation

◆ END_OF_ENUMERATION

#define END_OF_ENUMERATION (   key)    END_OF_##key##_PLACEHOLDER = 0

Definition at line 20 of file method.h.

◆ METHOD_ENTRY_BASIC

#define METHOD_ENTRY_BASIC (   me)    (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))

◆ METHOD_ENTRY_COMPLEMENTED

#define METHOD_ENTRY_COMPLEMENTED (   me)    ((me)->flags & IMEMO_FL_USER3)

Definition at line 68 of file method.h.

Referenced by rb_free_method_entry().

◆ METHOD_ENTRY_COMPLEMENTED_SET

#define METHOD_ENTRY_COMPLEMENTED_SET (   me)    ((me)->flags = (me)->flags | IMEMO_FL_USER3)

Definition at line 69 of file method.h.

Referenced by rb_method_entry_complement_defined_class().

◆ METHOD_ENTRY_VISI

#define METHOD_ENTRY_VISI (   me)    (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))

◆ rb_iseq_t

#define rb_iseq_t   rb_iseq_t

Definition at line 119 of file method.h.

◆ UNDEFINED_METHOD_ENTRY_P

#define UNDEFINED_METHOD_ENTRY_P (   me)    (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)

◆ UNDEFINED_REFINED_METHOD_P

#define UNDEFINED_REFINED_METHOD_P (   def)
Value:
((def)->type == VM_METHOD_TYPE_REFINED && \
UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
#define UNDEFINED_METHOD_ENTRY_P(me)
Definition: method.h:171

Definition at line 172 of file method.h.

Referenced by rb_alias(), rb_export_method(), rb_obj_singleton_method(), rb_undef(), and remove_method().

Typedef Documentation

◆ rb_callable_method_entry_t

◆ rb_cref_t

typedef struct rb_cref_struct rb_cref_t

◆ rb_iseq_t

typedef struct rb_iseq_struct rb_iseq_t

Definition at line 118 of file method.h.

◆ rb_method_alias_t

◆ rb_method_attr_t

◆ rb_method_cfunc_t

◆ rb_method_definition_t

◆ rb_method_entry_t

◆ rb_method_iseq_t

◆ rb_method_refined_t

◆ rb_scope_visibility_t

Enumeration Type Documentation

◆ rb_method_type_t

Enumerator
VM_METHOD_TYPE_ISEQ 
VM_METHOD_TYPE_CFUNC 
VM_METHOD_TYPE_ATTRSET 
VM_METHOD_TYPE_IVAR 
VM_METHOD_TYPE_BMETHOD 
VM_METHOD_TYPE_ZSUPER 
VM_METHOD_TYPE_ALIAS 
VM_METHOD_TYPE_UNDEF 
VM_METHOD_TYPE_NOTIMPLEMENTED 
VM_METHOD_TYPE_OPTIMIZED 
VM_METHOD_TYPE_MISSING 
VM_METHOD_TYPE_REFINED 

Definition at line 100 of file method.h.

◆ rb_method_visibility_t

Enumerator
METHOD_VISI_UNDEF 
METHOD_VISI_PUBLIC 
METHOD_VISI_PRIVATE 
METHOD_VISI_PROTECTED 
METHOD_VISI_MASK 

Definition at line 26 of file method.h.

Function Documentation

◆ METHOD_ENTRY_BASIC_SET()

static void METHOD_ENTRY_BASIC_SET ( rb_method_entry_t me,
unsigned int  basic 
)
inlinestatic

Definition at line 78 of file method.h.

References rb_method_entry_struct::flags, IMEMO_FL_USER2, IMEMO_FL_USHIFT, and VM_ASSERT.

◆ METHOD_ENTRY_FLAGS_COPY()

static void METHOD_ENTRY_FLAGS_COPY ( rb_method_entry_t dst,
const rb_method_entry_t src 
)
inlinestatic

◆ METHOD_ENTRY_FLAGS_SET()

static void METHOD_ENTRY_FLAGS_SET ( rb_method_entry_t me,
rb_method_visibility_t  visi,
unsigned int  basic 
)
inlinestatic

◆ METHOD_ENTRY_VISI_SET()

static void METHOD_ENTRY_VISI_SET ( rb_method_entry_t me,
rb_method_visibility_t  visi 
)
inlinestatic

◆ rb_add_method()

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

◆ 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 
)

◆ rb_add_refined_method_entry()

void rb_add_refined_method_entry ( VALUE  refined_class,
ID  mid 
)

◆ rb_callable_method_entry()

const rb_callable_method_entry_t* rb_callable_method_entry ( VALUE  klass,
ID  id 
)

◆ rb_callable_method_entry_with_refinements()

const rb_callable_method_entry_t* rb_callable_method_entry_with_refinements ( VALUE  klass,
ID  id 
)

◆ rb_callable_method_entry_without_refinements()

const rb_callable_method_entry_t* rb_callable_method_entry_without_refinements ( VALUE  klass,
ID  id 
)

◆ rb_free_method_entry()

void rb_free_method_entry ( const rb_method_entry_t me)

◆ rb_hash_method_entry()

st_index_t rb_hash_method_entry ( st_index_t  hash,
const rb_method_entry_t me 
)

Definition at line 1520 of file vm_method.c.

References rb_method_entry_struct::def, and rb_hash_method_definition().

Referenced by method_hash().

◆ rb_method_entry()

const rb_method_entry_t* rb_method_entry ( VALUE  klass,
ID  id 
)

◆ rb_method_entry_arity()

int rb_method_entry_arity ( const rb_method_entry_t me)

Definition at line 2341 of file proc.c.

References max(), and rb_method_entry_min_max_arity().

Referenced by method_arity(), rb_mod_method_arity(), and vm_respond_to().

◆ rb_method_entry_at()

const rb_method_entry_t* rb_method_entry_at ( VALUE  obj,
ID  id 
)

Definition at line 714 of file vm_method.c.

References lookup_method_table().

Referenced by add_opt_method(), and rb_obj_singleton_method().

◆ rb_method_entry_clone()

const rb_method_entry_t* rb_method_entry_clone ( const rb_method_entry_t me)

◆ 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 
)

◆ rb_method_entry_copy()

void rb_method_entry_copy ( rb_method_entry_t dst,
const rb_method_entry_t src 
)

◆ 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 
)

◆ rb_method_entry_eq()

int rb_method_entry_eq ( const rb_method_entry_t m1,
const rb_method_entry_t m2 
)

Definition at line 1421 of file vm_method.c.

References rb_method_entry_struct::def, and rb_method_definition_eq().

Referenced by method_eq().

◆ rb_method_entry_location()

VALUE rb_method_entry_location ( const rb_method_entry_t me)

Definition at line 2501 of file proc.c.

References rb_method_entry_struct::def, method_def_location(), and Qnil.

Referenced by rb_mod_method_location(), and vm_respond_to().

◆ rb_method_entry_set()

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

Definition at line 666 of file vm_method.c.

References method_entry_set().

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

◆ rb_method_entry_with_refinements()

const rb_method_entry_t* rb_method_entry_with_refinements ( VALUE  klass,
ID  id 
)

Definition at line 867 of file vm_method.c.

References method_entry_resolve_refinement(), NULL, and TRUE.

◆ rb_method_entry_without_refinements()

const rb_method_entry_t* rb_method_entry_without_refinements ( VALUE  klass,
ID  id 
)

Definition at line 881 of file vm_method.c.

References FALSE, method_entry_resolve_refinement(), and NULL.

Referenced by check_definition(), mnew(), mnew_internal(), and rb_method_boundp().

◆ rb_mod_method_location()

VALUE rb_mod_method_location ( VALUE  mod,
ID  id 
)

Definition at line 2508 of file proc.c.

References METHOD::me, original_method_entry(), and rb_method_entry_location().

Referenced by rb_obj_method_location().

◆ rb_obj_method_location()

VALUE rb_obj_method_location ( VALUE  obj,
ID  id 
)

Definition at line 2515 of file proc.c.

References CLASS_OF, and rb_mod_method_location().

◆ rb_resolve_refined_method()

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

Definition at line 941 of file vm_method.c.

References NULL, and resolve_refined_method().

Referenced by method_entry_i(), rb_alias(), and rb_undef().

◆ 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 
)

◆ rb_scope_visibility_set()

void rb_scope_visibility_set ( rb_method_visibility_t  )

Definition at line 1126 of file vm_method.c.

References FALSE, and vm_cref_set_visibility().

Referenced by load_ext(), and set_visibility().

◆ rb_sweep_method_entry()

void rb_sweep_method_entry ( void *  vm)