summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-30 18:45:28 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-30 18:45:28 +0000
commitf1d4e8b3b3be402621b043e858a8da5fc8797662 (patch)
tree114f7a8ecc4e280070eb50b6e477fdb76e28eda5 /proc.c
parent255c16b5989f218208a1d595e6a84f61a1e23204 (diff)
* method.h: add VM_METHOD_TYPE_ALIAS rb_method_definition_t::type
to fix [Bug #11173]. Now, inter class/method alias creates new method entry VM_METHOD_TYPE_ALIAS, which has an original method entry. * vm_insnhelper.c (find_defiend_class_by_owner): added. Search corresponding defined_class from owner class/module. * vm_method.c (rb_method_entry_get_without_cache): return me->klass directly for defined_class. Now, no need to check me->klass any more. * vm_method.c (method_entry_set0): separated from method_entry_set(). * vm_method.c (rb_alias): make method entry has VM_METHOD_TYPE_ALIAS. * vm_method.c (release_method_definition): support VM_METHOD_TYPE_ALIAS. * vm_method.c (rb_hash_method_definition): ditto. * vm_method.c (rb_method_definition_eq): ditto. * vm_method.c (release_method_definition): ditto. * vm_insnhelper.c (vm_call_method): ditto. * vm_insnhelper.c (vm_method_cfunc_entry): ditto. * vm_eval.c (vm_call0_body): ditto. * gc.c (mark_method_entry): ditto. * proc.c (method_def_iseq): ditto. * proc.c (method_cref): ditto. * proc.c (rb_method_entry_min_max_arity): ditto. * test/ruby/test_alias.rb: add tests. * test/ruby/test_module.rb: fix a test to catch up current behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index 5e1932b..1c6291e 100644
--- a/proc.c
+++ b/proc.c
@@ -2066,6 +2066,8 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
return *max = 1;
case VM_METHOD_TYPE_IVAR:
return *max = 0;
+ case VM_METHOD_TYPE_ALIAS:
+ return rb_method_entry_min_max_arity(def->body.alias.original_me, max);
case VM_METHOD_TYPE_BMETHOD:
return rb_proc_min_max_arity(def->body.proc, max);
case VM_METHOD_TYPE_ISEQ: {
@@ -2204,13 +2206,24 @@ static const rb_iseq_t *
method_def_iseq(const rb_method_definition_t *def)
{
switch (def->type) {
- case VM_METHOD_TYPE_BMETHOD:
- return get_proc_iseq(def->body.proc, 0);
case VM_METHOD_TYPE_ISEQ:
return def->body.iseq_body.iseq;
- default:
- return NULL;
+ case VM_METHOD_TYPE_BMETHOD:
+ return get_proc_iseq(def->body.proc, 0);
+ case VM_METHOD_TYPE_ALIAS:
+ return method_def_iseq(def->body.alias.original_me->def);
+ case VM_METHOD_TYPE_CFUNC:
+ case VM_METHOD_TYPE_ATTRSET:
+ case VM_METHOD_TYPE_IVAR:
+ case VM_METHOD_TYPE_ZSUPER:
+ case VM_METHOD_TYPE_UNDEF:
+ case VM_METHOD_TYPE_NOTIMPLEMENTED:
+ case VM_METHOD_TYPE_OPTIMIZED:
+ case VM_METHOD_TYPE_MISSING:
+ case VM_METHOD_TYPE_REFINED:
+ break;
}
+ return NULL;
}
const rb_iseq_t *
@@ -2224,9 +2237,13 @@ method_cref(VALUE method)
{
const rb_method_definition_t *def = method_def(method);
+ again:
switch (def->type) {
case VM_METHOD_TYPE_ISEQ:
return def->body.iseq_body.cref;
+ case VM_METHOD_TYPE_ALIAS:
+ def = def->body.alias.original_me->def;
+ goto again;
default:
return NULL;
}