5 #ifndef GLOBAL_METHOD_CACHE_SIZE
6 #define GLOBAL_METHOD_CACHE_SIZE 0x800
8 #ifndef GLOBAL_METHOD_CACHE_MASK
9 #define GLOBAL_METHOD_CACHE_MASK 0x7ff
12 #define GLOBAL_METHOD_CACHE_KEY(c,m) ((((c)>>3)^(m))&GLOBAL_METHOD_CACHE_MASK)
13 #define GLOBAL_METHOD_CACHE(c,m) (global_method_cache + GLOBAL_METHOD_CACHE_KEY(c,m))
16 #define NOEX_NOREDEF 0
18 #define NOEX_NOREDEF NOEX_RESPONDS
23 #define object_id idObject_id
24 #define added idMethod_added
25 #define singleton_added idSingleton_method_added
26 #define removed idMethod_removed
27 #define singleton_removed idSingleton_method_removed
28 #define undefined idMethod_undefined
29 #define singleton_undefined idSingleton_method_undefined
30 #define attached id__attached__
41 #define ruby_running (GET_VM()->running)
68 if (klass && klass !=
Qundef) {
118 ume->
next =
GET_VM()->unlinked_method_entry_list;
119 GET_VM()->unlinked_method_entry_list = ume;
145 prev_ume = &ume->
next;
245 int make_refined = 0;
253 (mid == idInitialize || mid == idInitialize_copy ||
254 mid == idInitialize_clone || mid == idInitialize_dup ||
264 VALUE refined_class =
303 switch (old_def->
type) {
316 "previous definition of %s was here",
353 if (klass ==
rb_cObject && mid == idInitialize) {
354 rb_warn(
"redefining Object#initialize may cause infinite loop");
357 if (mid ==
object_id || mid == id__send__) {
372 #define CALL_METHOD_HOOK(klass, hook, mid) do { \
373 const VALUE arg = ID2SYM(mid); \
374 VALUE recv_class = (klass); \
375 ID hook_id = (hook); \
376 if (FL_TEST((klass), FL_SINGLETON)) { \
377 recv_class = rb_ivar_get((klass), attached); \
378 hook_id = singleton_##hook; \
380 rb_funcall2(recv_class, hook_id, 1, &arg); \
414 rb_bug(
"call_cfunc_func: unsupported length: %d", argc);
483 rb_bug(
"rb_add_method: unsupported method type (%d)\n", type);
508 #define UNDEF_ALLOC_FUNC ((rb_alloc_func_t)-1)
531 if (allocator)
return allocator;
545 if (defined_class_ptr)
546 *defined_class_ptr = klass;
564 VALUE *defined_class_ptr)
569 if (me && me->
klass) {
575 defined_class = me->
klass;
596 if (defined_class_ptr)
601 #if VM_DEBUG_VERIFY_METHOD_CACHE
605 VALUE actual_defined_class;
609 if (me != actual_me || defined_class != actual_defined_class) {
610 rb_bug(
"method cache verification failed");
618 #if OPT_GLOBAL_METHOD_CACHE
624 if (defined_class_ptr)
626 #if VM_DEBUG_VERIFY_METHOD_CACHE
639 VALUE *defined_class_ptr)
655 VALUE *defined_class_ptr)
662 if (
NIL_P(refinement)) {
683 VALUE *defined_class_ptr)
690 VALUE refinements = cref ? cref->nd_refinements :
Qnil;
694 if (defined_class_ptr)
701 VALUE *defined_class_ptr)
709 if (defined_class_ptr)
728 if (mid ==
object_id || mid == id__send__ || mid == idInitialize) {
775 for (i = 0; i <
argc; i++) {
787 #undef rb_disable_super
788 #undef rb_enable_super
817 if (me->
flag != noex) {
820 if (klass == defined_class ||
846 if (!me->
def)
return 0;
848 if (ex & NOEX_RESPONDS)
return 2;
872 "attribute accessor as module_function" :
873 "private attribute?");
905 if (
id ==
object_id ||
id == id__send__ ||
id == idInitialize) {
914 const char *s0 =
" class";
986 for (i = 0; i <
argc; i++) {
1036 #define VISI_CHECK(x,f) (((x)&NOEX_MASK) == (f))
1167 if (d1 == d2)
return 1;
1168 if (!d1 || !d2)
return 0;
1193 rb_bug(
"rb_method_entry_eq: unsupported method type (%d)\n", d1->
type);
1203 switch (def->
type) {
1231 rb_bug(
"rb_hash_method_definition: unsupported method type (%d)\n", def->
type);
1245 VALUE target_klass = klass;
1269 flag = orig_me->
flag;
1274 if (real_class &&
RCLASS_ORIGIN(real_class) == defined_class)
1275 defined_class = real_class;
1326 for (i = 0; i <
argc; i++) {
1547 for (i = 0; i <
argc; i++) {
1619 " old fashion which takes only one parameter",
1623 if (!
NIL_P(location)) {
1628 "respond_to? is defined here");
1710 #define rb_intern(str) rb_intern_const(str)
1736 #define REPLICATE_METHOD(klass, id, noex) \
1737 rb_method_entry_set((klass), (id), \
1738 rb_method_entry((klass), (id), 0), \
1739 (rb_method_flag_t)(noex | NOEX_BASIC | NOEX_NOREDEF))