From f1d4e8b3b3be402621b043e858a8da5fc8797662 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sat, 30 May 2015 18:45:28 +0000 Subject: * 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 --- method.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'method.h') diff --git a/method.h b/method.h index db5eafd8f4..1e83c76b96 100644 --- a/method.h +++ b/method.h @@ -51,6 +51,7 @@ typedef enum { VM_METHOD_TYPE_IVAR, VM_METHOD_TYPE_BMETHOD, VM_METHOD_TYPE_ZSUPER, + VM_METHOD_TYPE_ALIAS, VM_METHOD_TYPE_UNDEF, VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */ @@ -71,6 +72,10 @@ typedef struct rb_method_attr_struct { const VALUE location; } rb_method_attr_t; +typedef struct rb_method_alias_struct { + const struct rb_method_entry_struct *original_me; /* original_me->klass is original owner */ +} rb_method_alias_t; + typedef struct rb_iseq_struct rb_iseq_t; typedef struct rb_method_definition_struct { @@ -85,6 +90,7 @@ typedef struct rb_method_definition_struct { } iseq_body; rb_method_cfunc_t cfunc; rb_method_attr_t attr; + rb_method_alias_t alias; const VALUE proc; /* should be mark */ enum method_optimized_type { OPTIMIZED_METHOD_TYPE_SEND, -- cgit v1.2.3