3 * This file is included by vm_eval.c
6 #define CACHE_SIZE 0x800
7 #define CACHE_MASK 0x7ff
8 #define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
10 static void rb_vm_check_redefinition_opt_method(const NODE
*node
);
12 static ID __send__
, object_id
;
13 static ID removed
, singleton_removed
, undefined
, singleton_undefined
;
14 static ID eqq
, each
, aref
, aset
, match
, missing
;
15 static ID added
, singleton_added
;
17 struct cache_entry
{ /* method hash table. */
18 ID mid
; /* method's id */
19 ID mid0
; /* method's original id */
20 VALUE klass
; /* receiver's class */
21 VALUE oklass
; /* original's class */
25 static struct cache_entry cache
[CACHE_SIZE
];
26 #define ruby_running (GET_VM()->running)
27 /* int ruby_running = 0; */
32 struct cache_entry
*ent
, *end
;
39 end
= ent
+ CACHE_SIZE
;
47 rb_clear_cache_for_undef(VALUE klass
, ID id
)
49 struct cache_entry
*ent
, *end
;
56 end
= ent
+ CACHE_SIZE
;
58 if (ent
->oklass
== klass
&& ent
->mid
== id
) {
66 rb_clear_cache_by_id(ID id
)
68 struct cache_entry
*ent
, *end
;
75 end
= ent
+ CACHE_SIZE
;
85 rb_clear_cache_by_class(VALUE klass
)
87 struct cache_entry
*ent
, *end
;
94 end
= ent
+ CACHE_SIZE
;
96 if (ent
->klass
== klass
|| ent
->oklass
== klass
) {
104 rb_add_method(VALUE klass
, ID mid
, NODE
* node
, int noex
)
111 if (rb_safe_level() >= 4 &&
112 (klass
== rb_cObject
|| !OBJ_UNTRUSTED(klass
))) {
113 rb_raise(rb_eSecurityError
, "Insecure: can't define method");
115 if (!FL_TEST(klass
, FL_SINGLETON
) &&
116 node
&& nd_type(node
) != NODE_ZSUPER
&&
117 (mid
== rb_intern("initialize") || mid
== rb_intern("initialize_copy"))) {
118 noex
= NOEX_PRIVATE
| noex
;
120 else if (FL_TEST(klass
, FL_SINGLETON
) && node
121 && nd_type(node
) == NODE_CFUNC
&& mid
== rb_intern("allocate")) {
123 ("defining %s.allocate is deprecated; use rb_define_alloc_func()",
124 rb_class2name(rb_iv_get(klass
, "__attached__")));
127 if (OBJ_FROZEN(klass
)) {
128 rb_error_frozen("class/module");
130 rb_clear_cache_by_id(mid
);
133 * NODE_METHOD (NEW_METHOD(body, klass, vis)):
134 * nd_body : method body // (2) // mark
135 * nd_clss : klass // (1) // mark
136 * nd_noex : visibility // (3)
138 * NODE_FBODY (NEW_FBODY(method, alias)):
139 * nd_body : method (NODE_METHOD) // (2) // mark
140 * nd_oid : original id // (1)
141 * nd_cnt : alias count // (3)
144 body
= NEW_FBODY(NEW_METHOD(node
, klass
, NOEX_WITH_SAFE(noex
)), 0);
151 /* check re-definition */
155 if (st_lookup(RCLASS_M_TBL(klass
), mid
, &data
)) {
156 old_node
= (NODE
*)data
;
158 if (nd_type(old_node
->nd_body
->nd_body
) == NODE_CFUNC
) {
159 rb_vm_check_redefinition_opt_method(old_node
);
161 if (RTEST(ruby_verbose
) && node
&& old_node
->nd_cnt
== 0 && old_node
->nd_body
) {
162 rb_warning("method redefined; discarding old %s", rb_id2name(mid
));
166 if (klass
== rb_cObject
&& node
&& mid
== idInitialize
) {
167 rb_warn("redefining Object#initialize may cause infinite loop");
170 if (mid
== object_id
|| mid
== __send__
) {
171 if (node
&& nd_type(node
) == RUBY_VM_METHOD_NODE
) {
172 rb_warn("redefining `%s' may cause serious problem",
178 st_insert(RCLASS_M_TBL(klass
), mid
, (st_data_t
) body
);
180 if (node
&& mid
!= ID_ALLOCATOR
&& ruby_running
) {
181 if (FL_TEST(klass
, FL_SINGLETON
)) {
182 rb_funcall(rb_iv_get(klass
, "__attached__"), singleton_added
, 1,
186 rb_funcall(klass
, added
, 1, ID2SYM(mid
));
192 rb_define_alloc_func(VALUE klass
, VALUE (*func
)(VALUE
))
194 Check_Type(klass
, T_CLASS
);
195 rb_add_method(rb_singleton_class(klass
), ID_ALLOCATOR
, NEW_CFUNC(func
, 0),
200 rb_undef_alloc_func(VALUE klass
)
202 Check_Type(klass
, T_CLASS
);
203 rb_add_method(rb_singleton_class(klass
), ID_ALLOCATOR
, 0, NOEX_UNDEF
);
207 rb_get_alloc_func(VALUE klass
)
210 Check_Type(klass
, T_CLASS
);
211 n
= rb_method_node(CLASS_OF(klass
), ID_ALLOCATOR
);
213 if (nd_type(n
) != NODE_METHOD
) return 0;
215 if (nd_type(n
) != NODE_CFUNC
) return 0;
216 return (rb_alloc_func_t
)n
->nd_cfnc
;
220 search_method(VALUE klass
, ID id
, VALUE
*klassp
)
228 while (!st_lookup(RCLASS_M_TBL(klass
), id
, &body
)) {
229 klass
= RCLASS_SUPER(klass
);
242 * search method body (NODE_METHOD)
243 * with : klass and id
244 * without : method cache
246 * if you need method node with method cache, use
250 rb_get_method_body(VALUE klass
, ID id
, ID
*idp
)
252 NODE
*volatile fbody
, *body
;
255 if ((fbody
= search_method(klass
, id
, 0)) == 0 || !fbody
->nd_body
) {
256 /* store empty info in cache */
257 struct cache_entry
*ent
;
258 ent
= cache
+ EXPR1(klass
, id
);
260 ent
->mid
= ent
->mid0
= id
;
266 method
= fbody
->nd_body
;
270 struct cache_entry
*ent
;
271 ent
= cache
+ EXPR1(klass
, id
);
274 ent
->mid0
= fbody
->nd_oid
;
275 ent
->method
= body
= method
;
276 ent
->oklass
= method
->nd_clss
;
283 *idp
= fbody
->nd_oid
;
290 rb_method_node(VALUE klass
, ID id
)
292 struct cache_entry
*ent
;
294 ent
= cache
+ EXPR1(klass
, id
);
295 if (ent
->mid
== id
&& ent
->klass
== klass
&& ent
->method
) {
299 return rb_get_method_body(klass
, id
, 0);
303 remove_method(VALUE klass
, ID mid
)
308 if (klass
== rb_cObject
) {
311 if (rb_safe_level() >= 4 && !OBJ_UNTRUSTED(klass
)) {
312 rb_raise(rb_eSecurityError
, "Insecure: can't remove method");
314 if (OBJ_FROZEN(klass
))
315 rb_error_frozen("class/module");
316 if (mid
== object_id
|| mid
== __send__
|| mid
== idInitialize
) {
317 rb_warn("removing `%s' may cause serious problem", rb_id2name(mid
));
319 if (st_lookup(RCLASS_M_TBL(klass
), mid
, &data
)) {
321 if (!body
|| !body
->nd_body
) body
= 0;
323 st_delete(RCLASS_M_TBL(klass
), &mid
, &data
);
327 rb_name_error(mid
, "method `%s' not defined in %s",
328 rb_id2name(mid
), rb_class2name(klass
));
331 if (nd_type(body
->nd_body
->nd_body
) == NODE_CFUNC
) {
332 rb_vm_check_redefinition_opt_method(body
);
335 rb_clear_cache_for_undef(klass
, mid
);
336 if (FL_TEST(klass
, FL_SINGLETON
)) {
337 rb_funcall(rb_iv_get(klass
, "__attached__"), singleton_removed
, 1,
341 rb_funcall(klass
, removed
, 1, ID2SYM(mid
));
346 rb_remove_method(VALUE klass
, const char *name
)
348 remove_method(klass
, rb_intern(name
));
353 * remove_method(symbol) => self
355 * Removes the method identified by _symbol_ from the current
356 * class. For an example, see <code>Module.undef_method</code>.
360 rb_mod_remove_method(int argc
, VALUE
*argv
, VALUE mod
)
364 for (i
= 0; i
< argc
; i
++) {
365 remove_method(mod
, rb_to_id(argv
[i
]));
370 #undef rb_disable_super
371 #undef rb_enable_super
374 rb_disable_super(VALUE klass
, const char *name
)
376 /* obsolete - no use */
380 rb_enable_super(VALUE klass
, const char *name
)
382 rb_warning("rb_enable_super() is obsolete");
386 rb_export_method(VALUE klass
, ID name
, ID noex
)
391 if (klass
== rb_cObject
) {
394 fbody
= search_method(klass
, name
, &origin
);
395 if (!fbody
&& TYPE(klass
) == T_MODULE
) {
396 fbody
= search_method(rb_cObject
, name
, &origin
);
398 if (!fbody
|| !fbody
->nd_body
) {
399 rb_print_undef(klass
, name
, 0);
401 if (fbody
->nd_body
->nd_noex
!= noex
) {
402 if (nd_type(fbody
->nd_body
->nd_body
) == NODE_CFUNC
) {
403 rb_vm_check_redefinition_opt_method(fbody
);
405 if (klass
== origin
) {
406 fbody
->nd_body
->nd_noex
= noex
;
409 rb_add_method(klass
, name
, NEW_ZSUPER(), noex
);
415 rb_method_boundp(VALUE klass
, ID id
, int ex
)
419 if ((method
= rb_method_node(klass
, id
)) != 0) {
420 if (ex
&& (method
->nd_noex
& NOEX_PRIVATE
)) {
429 rb_attr(VALUE klass
, ID id
, int read
, int write
, int ex
)
439 if (SCOPE_TEST(NOEX_PRIVATE
)) {
441 rb_warning((SCOPE_CHECK(NOEX_MODFUNC
)) ?
442 "attribute accessor as module_function" :
443 "private attribute?");
445 else if (SCOPE_TEST(NOEX_PROTECTED
)) {
446 noex
= NOEX_PROTECTED
;
453 if (!rb_is_local_id(id
) && !rb_is_const_id(id
)) {
454 rb_name_error(id
, "invalid attribute name `%s'", rb_id2name(id
));
456 name
= rb_id2name(id
);
458 rb_raise(rb_eArgError
, "argument needs to be symbol or string");
460 attriv
= rb_intern_str(rb_sprintf("@%s", name
));
462 rb_add_method(klass
, id
, NEW_IVAR(attriv
), noex
);
465 rb_add_method(klass
, rb_id_attrset(id
), NEW_ATTRSET(attriv
), noex
);
470 rb_undef(VALUE klass
, ID id
)
475 if (rb_vm_cbase() == rb_cObject
&& klass
== rb_cObject
) {
478 if (rb_safe_level() >= 4 && !OBJ_UNTRUSTED(klass
)) {
479 rb_raise(rb_eSecurityError
, "Insecure: can't undef `%s'",
482 rb_frozen_class_p(klass
);
483 if (id
== object_id
|| id
== __send__
|| id
== idInitialize
) {
484 rb_warn("undefining `%s' may cause serious problem", rb_id2name(id
));
486 body
= search_method(klass
, id
, &origin
);
487 if (!body
|| !body
->nd_body
) {
488 const char *s0
= " class";
491 if (FL_TEST(c
, FL_SINGLETON
)) {
492 VALUE obj
= rb_iv_get(klass
, "__attached__");
501 else if (TYPE(c
) == T_MODULE
) {
504 rb_name_error(id
, "undefined method `%s' for%s `%s'",
505 rb_id2name(id
), s0
, rb_class2name(c
));
508 rb_add_method(klass
, id
, 0, NOEX_PUBLIC
);
510 if (FL_TEST(klass
, FL_SINGLETON
)) {
511 rb_funcall(rb_iv_get(klass
, "__attached__"),
512 singleton_undefined
, 1, ID2SYM(id
));
515 rb_funcall(klass
, undefined
, 1, ID2SYM(id
));
521 * undef_method(symbol) => self
523 * Prevents the current class from responding to calls to the named
524 * method. Contrast this with <code>remove_method</code>, which deletes
525 * the method from the particular class; Ruby will still search
526 * superclasses and mixed-in modules for a possible receiver.
533 * class Child < Parent
545 * remove_method :hello # remove from child, still in parent
551 * undef_method :hello # prevent any calls to 'hello'
559 * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
563 rb_mod_undef_method(int argc
, VALUE
*argv
, VALUE mod
)
566 for (i
= 0; i
< argc
; i
++) {
567 rb_undef(mod
, rb_to_id(argv
[i
]));
574 * mod.method_defined?(symbol) => true or false
576 * Returns +true+ if the named method is defined by
577 * _mod_ (or its included modules and, if _mod_ is a class,
578 * its ancestors). Public and protected methods are matched.
591 * A.method_defined? :method1 #=> true
592 * C.method_defined? "method1" #=> true
593 * C.method_defined? "method2" #=> true
594 * C.method_defined? "method3" #=> true
595 * C.method_defined? "method4" #=> false
599 rb_mod_method_defined(VALUE mod
, VALUE mid
)
601 return rb_method_boundp(mod
, rb_to_id(mid
), 1);
604 #define VISI_CHECK(x,f) (((x)&NOEX_MASK) == (f))
608 * mod.public_method_defined?(symbol) => true or false
610 * Returns +true+ if the named public method is defined by
611 * _mod_ (or its included modules and, if _mod_ is a class,
626 * A.method_defined? :method1 #=> true
627 * C.public_method_defined? "method1" #=> true
628 * C.public_method_defined? "method2" #=> false
629 * C.method_defined? "method2" #=> true
633 rb_mod_public_method_defined(VALUE mod
, VALUE mid
)
635 ID id
= rb_to_id(mid
);
638 method
= rb_method_node(mod
, id
);
640 if (VISI_CHECK(method
->nd_noex
, NOEX_PUBLIC
))
648 * mod.private_method_defined?(symbol) => true or false
650 * Returns +true+ if the named private method is defined by
651 * _ mod_ (or its included modules and, if _mod_ is a class,
666 * A.method_defined? :method1 #=> true
667 * C.private_method_defined? "method1" #=> false
668 * C.private_method_defined? "method2" #=> true
669 * C.method_defined? "method2" #=> false
673 rb_mod_private_method_defined(VALUE mod
, VALUE mid
)
675 ID id
= rb_to_id(mid
);
678 method
= rb_method_node(mod
, id
);
680 if (VISI_CHECK(method
->nd_noex
, NOEX_PRIVATE
))
688 * mod.protected_method_defined?(symbol) => true or false
690 * Returns +true+ if the named protected method is defined
691 * by _mod_ (or its included modules and, if _mod_ is a
692 * class, its ancestors).
706 * A.method_defined? :method1 #=> true
707 * C.protected_method_defined? "method1" #=> false
708 * C.protected_method_defined? "method2" #=> true
709 * C.method_defined? "method2" #=> true
713 rb_mod_protected_method_defined(VALUE mod
, VALUE mid
)
715 ID id
= rb_to_id(mid
);
718 method
= rb_method_node(mod
, id
);
720 if (VISI_CHECK(method
->nd_noex
, NOEX_PROTECTED
))
727 rb_alias(VALUE klass
, ID name
, ID def
)
729 NODE
*orig_fbody
, *node
;
733 rb_frozen_class_p(klass
);
734 if (klass
== rb_cObject
) {
737 orig_fbody
= search_method(klass
, def
, 0);
738 if (!orig_fbody
|| !orig_fbody
->nd_body
) {
739 if (TYPE(klass
) == T_MODULE
) {
740 orig_fbody
= search_method(rb_cObject
, def
, 0);
743 if (!orig_fbody
|| !orig_fbody
->nd_body
) {
744 rb_print_undef(klass
, def
, 0);
746 if (FL_TEST(klass
, FL_SINGLETON
)) {
747 singleton
= rb_iv_get(klass
, "__attached__");
750 orig_fbody
->nd_cnt
++;
752 if (st_lookup(RCLASS_M_TBL(klass
), name
, &data
)) {
755 if (RTEST(ruby_verbose
) && node
->nd_cnt
== 0 && node
->nd_body
) {
756 rb_warning("discarding old %s", rb_id2name(name
));
758 if (nd_type(node
->nd_body
->nd_body
) == NODE_CFUNC
) {
759 rb_vm_check_redefinition_opt_method(node
);
764 st_insert(RCLASS_M_TBL(klass
), name
,
765 (st_data_t
) NEW_FBODY(
766 NEW_METHOD(orig_fbody
->nd_body
->nd_body
,
767 orig_fbody
->nd_body
->nd_clss
,
768 NOEX_WITH_SAFE(orig_fbody
->nd_body
->nd_noex
)), def
));
770 rb_clear_cache_by_id(name
);
772 if (!ruby_running
) return;
775 rb_funcall(singleton
, singleton_added
, 1, ID2SYM(name
));
778 rb_funcall(klass
, added
, 1, ID2SYM(name
));
784 * alias_method(new_name, old_name) => self
786 * Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
787 * be used to retain access to methods that are overridden.
790 * alias_method :orig_exit, :exit
792 * puts "Exiting with code #{code}"
801 * Exiting with code 99
805 rb_mod_alias_method(VALUE mod
, VALUE newname
, VALUE oldname
)
807 rb_alias(mod
, rb_to_id(newname
), rb_to_id(oldname
));
812 secure_visibility(VALUE self
)
814 if (rb_safe_level() >= 4 && !OBJ_UNTRUSTED(self
)) {
815 rb_raise(rb_eSecurityError
,
816 "Insecure: can't change method visibility");
821 set_method_visibility(VALUE self
, int argc
, VALUE
*argv
, ID ex
)
824 secure_visibility(self
);
825 for (i
= 0; i
< argc
; i
++) {
826 rb_export_method(self
, rb_to_id(argv
[i
]), ex
);
828 rb_clear_cache_by_class(self
);
834 * public(symbol, ...) => self
836 * With no arguments, sets the default visibility for subsequently
837 * defined methods to public. With arguments, sets the named methods to
838 * have public visibility.
842 rb_mod_public(int argc
, VALUE
*argv
, VALUE module
)
844 secure_visibility(module
);
846 SCOPE_SET(NOEX_PUBLIC
);
849 set_method_visibility(module
, argc
, argv
, NOEX_PUBLIC
);
857 * protected(symbol, ...) => self
859 * With no arguments, sets the default visibility for subsequently
860 * defined methods to protected. With arguments, sets the named methods
861 * to have protected visibility.
865 rb_mod_protected(int argc
, VALUE
*argv
, VALUE module
)
867 secure_visibility(module
);
869 SCOPE_SET(NOEX_PROTECTED
);
872 set_method_visibility(module
, argc
, argv
, NOEX_PROTECTED
);
880 * private(symbol, ...) => self
882 * With no arguments, sets the default visibility for subsequently
883 * defined methods to private. With arguments, sets the named methods
884 * to have private visibility.
893 * Mod.private_instance_methods #=> [:a, :c]
897 rb_mod_private(int argc
, VALUE
*argv
, VALUE module
)
899 secure_visibility(module
);
901 SCOPE_SET(NOEX_PRIVATE
);
904 set_method_visibility(module
, argc
, argv
, NOEX_PRIVATE
);
911 * mod.public_class_method(symbol, ...) => mod
913 * Makes a list of existing class methods public.
917 rb_mod_public_method(int argc
, VALUE
*argv
, VALUE obj
)
919 set_method_visibility(CLASS_OF(obj
), argc
, argv
, NOEX_PUBLIC
);
925 * mod.private_class_method(symbol, ...) => mod
927 * Makes existing class methods private. Often used to hide the default
928 * constructor <code>new</code>.
930 * class SimpleSingleton # Not thread safe
931 * private_class_method :new
932 * def SimpleSingleton.create(*args, &block)
933 * @me = new(*args, &block) if ! @me
940 rb_mod_private_method(int argc
, VALUE
*argv
, VALUE obj
)
942 set_method_visibility(CLASS_OF(obj
), argc
, argv
, NOEX_PRIVATE
);
949 * public(symbol, ...)
951 * With no arguments, sets the default visibility for subsequently
952 * defined methods to public. With arguments, sets the named methods to
953 * have public visibility.
957 top_public(int argc
, VALUE
*argv
)
959 return rb_mod_public(argc
, argv
, rb_cObject
);
963 top_private(int argc
, VALUE
*argv
)
965 return rb_mod_private(argc
, argv
, rb_cObject
);
970 * module_function(symbol, ...) => self
972 * Creates module functions for the named methods. These functions may
973 * be called with the module as a receiver, and also become available
974 * as instance methods to classes that mix in the module. Module
975 * functions are copies of the original, and so may be changed
976 * independently. The instance-method versions are made private. If
977 * used with no arguments, subsequently defined methods become module
984 * module_function :one
992 * Mod.one #=> "This is one"
994 * c.callOne #=> "This is one"
997 * "This is the new one"
1000 * Mod.one #=> "This is one"
1001 * c.callOne #=> "This is the new one"
1005 rb_mod_modfunc(int argc
, VALUE
*argv
, VALUE module
)
1011 if (TYPE(module
) != T_MODULE
) {
1012 rb_raise(rb_eTypeError
, "module_function must be called for modules");
1015 secure_visibility(module
);
1017 SCOPE_SET(NOEX_MODFUNC
);
1021 set_method_visibility(module
, argc
, argv
, NOEX_PRIVATE
);
1023 for (i
= 0; i
< argc
; i
++) {
1026 id
= rb_to_id(argv
[i
]);
1028 fbody
= search_method(m
, id
, &m
);
1030 fbody
= search_method(rb_cObject
, id
, &m
);
1032 if (fbody
== 0 || fbody
->nd_body
== 0) {
1033 rb_bug("undefined method `%s'; can't happen", rb_id2name(id
));
1035 if (nd_type(fbody
->nd_body
->nd_body
) != NODE_ZSUPER
) {
1036 break; /* normal case: need not to follow 'super' link */
1038 m
= RCLASS_SUPER(m
);
1042 rb_add_method(rb_singleton_class(module
), id
, fbody
->nd_body
->nd_body
,
1049 rb_method_basic_definition_p(VALUE klass
, ID id
)
1051 NODE
*node
= rb_method_node(klass
, id
);
1052 if (node
&& (node
->nd_noex
& NOEX_BASIC
))
1059 * obj.respond_to?(symbol, include_private=false) => true or false
1061 * Returns +true+> if _obj_ responds to the given
1062 * method. Private methods are included in the search only if the
1063 * optional second parameter evaluates to +true+.
1067 rb_obj_respond_to(VALUE obj
, ID id
, int priv
)
1069 VALUE klass
= CLASS_OF(obj
);
1071 if (rb_method_basic_definition_p(klass
, idRespond_to
)) {
1072 return rb_method_boundp(klass
, id
, !priv
);
1077 args
[n
++] = ID2SYM(id
);
1080 return RTEST(rb_funcall2(obj
, idRespond_to
, n
, args
));
1085 rb_respond_to(VALUE obj
, ID id
)
1087 return rb_obj_respond_to(obj
, id
, Qfalse
);
1092 * obj.respond_to?(symbol, include_private=false) => true or false
1094 * Returns +true+> if _obj_ responds to the given
1095 * method. Private methods are included in the search only if the
1096 * optional second parameter evaluates to +true+.
1100 obj_respond_to(int argc
, VALUE
*argv
, VALUE obj
)
1105 rb_scan_args(argc
, argv
, "11", &mid
, &priv
);
1107 if (rb_method_boundp(CLASS_OF(obj
), id
, !RTEST(priv
))) {
1114 Init_eval_method(void)
1117 #define rb_intern(str) rb_intern_const(str)
1119 rb_define_method(rb_mKernel
, "respond_to?", obj_respond_to
, -1);
1121 rb_define_private_method(rb_cModule
, "remove_method", rb_mod_remove_method
, -1);
1122 rb_define_private_method(rb_cModule
, "undef_method", rb_mod_undef_method
, -1);
1123 rb_define_private_method(rb_cModule
, "alias_method", rb_mod_alias_method
, 2);
1124 rb_define_private_method(rb_cModule
, "public", rb_mod_public
, -1);
1125 rb_define_private_method(rb_cModule
, "protected", rb_mod_protected
, -1);
1126 rb_define_private_method(rb_cModule
, "private", rb_mod_private
, -1);
1127 rb_define_private_method(rb_cModule
, "module_function", rb_mod_modfunc
, -1);
1129 rb_define_method(rb_cModule
, "method_defined?", rb_mod_method_defined
, 1);
1130 rb_define_method(rb_cModule
, "public_method_defined?", rb_mod_public_method_defined
, 1);
1131 rb_define_method(rb_cModule
, "private_method_defined?", rb_mod_private_method_defined
, 1);
1132 rb_define_method(rb_cModule
, "protected_method_defined?", rb_mod_protected_method_defined
, 1);
1133 rb_define_method(rb_cModule
, "public_class_method", rb_mod_public_method
, -1);
1134 rb_define_method(rb_cModule
, "private_class_method", rb_mod_private_method
, -1);
1136 rb_define_singleton_method(rb_vm_top_self(), "public", top_public
, -1);
1137 rb_define_singleton_method(rb_vm_top_self(), "private", top_private
, -1);
1139 object_id
= rb_intern("object_id");
1140 __send__
= rb_intern("__send__");
1141 eqq
= rb_intern("===");
1142 each
= rb_intern("each");
1143 aref
= rb_intern("[]");
1144 aset
= rb_intern("[]=");
1145 match
= rb_intern("=~");
1146 missing
= rb_intern("method_missing");
1147 added
= rb_intern("method_added");
1148 singleton_added
= rb_intern("singleton_method_added");
1149 removed
= rb_intern("method_removed");
1150 singleton_removed
= rb_intern("singleton_method_removed");
1151 undefined
= rb_intern("method_undefined");
1152 singleton_undefined
= rb_intern("singleton_method_undefined");