summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-04 18:29:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-04 18:29:55 +0000
commita58e3d763b6429df710c2f3a6dd38e7339ec581e (patch)
tree818b12fe58c2e072fd79c3d6ca057e4f88d25518 /vm_method.c
parente3707541890c1d679b8bc8e319980667e6ed2bd6 (diff)
* array.c (rb_ary_sort_bang): respect overridden <=> for String and
Fixnum. [ruby-core:17708] * include/ruby/node.h (NOEX_BASIC): basic definition method flag. * include/ruby/intern.h, vm_method.c (rb_method_basic_definition_p): new function to check if the method is not redefined after the initialization. * vm_method.c (rb_obj_respond_to): use rb_method_basic_definition_p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/vm_method.c b/vm_method.c
index ec9634fcda..b9940a7230 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1044,6 +1044,15 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
return module;
}
+int
+rb_method_basic_definition_p(VALUE klass, ID id)
+{
+ NODE *node = rb_method_node(klass, id);
+ if (node && (node->nd_noex & NOEX_BASIC))
+ return 1;
+ return 0;
+}
+
/*
* call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false
@@ -1053,14 +1062,12 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
* optional second parameter evaluates to +true+.
*/
-static NODE *basic_respond_to = 0;
-
int
rb_obj_respond_to(VALUE obj, ID id, int priv)
{
VALUE klass = CLASS_OF(obj);
- if (rb_method_node(klass, idRespond_to) == basic_respond_to) {
+ if (rb_method_basic_definition_p(klass, idRespond_to)) {
return rb_method_boundp(klass, id, !priv);
}
else {
@@ -1108,8 +1115,6 @@ Init_eval_method(void)
#undef rb_intern
rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
- basic_respond_to = rb_method_node(rb_cObject, idRespond_to);
- rb_register_mark_object((VALUE)basic_respond_to);
rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1);
rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1);