diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-06 04:35:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-06 04:35:23 +0000 |
commit | 6eb76ba664a7ea1dc2b6804a0f2280e1f7531c53 (patch) | |
tree | 3a74a76375a9ec16d64e36f381459003268ee95c /proc.c | |
parent | fe072cef25054cce460c92408f3f8fe9cb2b5c0d (diff) | |
download | bundler-6eb76ba664a7ea1dc2b6804a0f2280e1f7531c53.tar.gz |
vm_method.c: show respond_to location
* proc.c (rb_method_entry_location, rb_{mod,obj}_method_location): new
functions to obtain source location of method definition.
* vm_method.c (rb_obj_respond_to): show the location of old style
respond_to? method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 38 |
1 files changed, 32 insertions, 6 deletions
@@ -1844,6 +1844,37 @@ rb_method_get_iseq(VALUE method) return method_get_iseq(method_get_def(method)); } +static VALUE +method_def_location(rb_method_definition_t *def) +{ + if (def->type == VM_METHOD_TYPE_ATTRSET || def->type == VM_METHOD_TYPE_IVAR) { + if (!def->body.attr.location) + return Qnil; + return rb_ary_dup(def->body.attr.location); + } + return iseq_location(method_get_iseq(def)); +} + +VALUE +rb_method_entry_location(rb_method_entry_t *me) +{ + if (!me || !me->def) return Qnil; + return method_def_location(me->def); +} + +VALUE +rb_mod_method_location(VALUE mod, ID id) +{ + rb_method_entry_t *me = original_method_entry(mod, id); + return rb_method_entry_location(me); +} + +VALUE +rb_obj_method_location(VALUE obj, ID id) +{ + return rb_mod_method_location(CLASS_OF(obj), id); +} + /* * call-seq: * meth.source_location -> [String, Fixnum] @@ -1856,12 +1887,7 @@ VALUE rb_method_location(VALUE method) { rb_method_definition_t *def = method_get_def(method); - if (def->type == VM_METHOD_TYPE_ATTRSET || def->type == VM_METHOD_TYPE_IVAR) { - if (!def->body.attr.location) - return Qnil; - return rb_ary_dup(def->body.attr.location); - } - return iseq_location(method_get_iseq(def)); + return method_def_location(def); } /* |