summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-22 11:44:01 +0000
committerwanabe <wanabe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-22 11:44:01 +0000
commitc46f71399ae54967e7247ac4df0c26adeddbffd6 (patch)
tree829ebc2a778a5306f6c403029fe5b04713fd480c /proc.c
parent5d8f69503299ef719c5523546cf2745de136cea9 (diff)
downloadruby-c46f71399ae54967e7247ac4df0c26adeddbffd6.tar.gz
* proc.c (rb_method_location): return attr's location if it is setup.
[Feature #2084] * NEWS: follow above. * vm_method.c (rb_add_method): save attr's location. * gc.c (mark_method_entry): mark attr's location. * method.h (rb_method_definition_t): add member to save attr's location. * vm_eval.c (vm_call0): follow above. * vm_insnhelper.c (vm_call_method): ditto. * vm_method.c (rb_method_definition_eq): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/proc.c b/proc.c
index 543ee95923..eff7a0bbbc 100644
--- a/proc.c
+++ b/proc.c
@@ -1634,15 +1634,18 @@ rb_obj_method_arity(VALUE obj, ID id)
return rb_mod_method_arity(CLASS_OF(obj), id);
}
-rb_iseq_t *
-rb_method_get_iseq(VALUE method)
+static inline rb_method_definition_t *
+method_get_def(VALUE method)
{
struct METHOD *data;
- rb_method_definition_t *def;
TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
- def = data->me.def;
+ return data->me.def;
+}
+static rb_iseq_t *
+method_get_iseq(rb_method_definition_t *def)
+{
switch (def->type) {
case VM_METHOD_TYPE_BMETHOD:
return get_proc_iseq(def->body.proc, 0);
@@ -1653,6 +1656,12 @@ rb_method_get_iseq(VALUE method)
}
}
+rb_iseq_t *
+rb_method_get_iseq(VALUE method)
+{
+ return method_get_iseq(method_get_def(method));
+}
+
/*
* call-seq:
* meth.source_location => [String, Fixnum]
@@ -1664,7 +1673,13 @@ rb_method_get_iseq(VALUE method)
VALUE
rb_method_location(VALUE method)
{
- return iseq_location(rb_method_get_iseq(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));
}
/*