mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm.c (eval_search_super_klass): rename to search_super_klass() and
use it by th_call_super(). * insns.def: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5078c85782
commit
ca46eab090
3 changed files with 2461 additions and 2445 deletions
|
@ -1,3 +1,10 @@
|
|||
Tue Jan 16 17:49:29 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm.c (eval_search_super_klass): rename to search_super_klass() and
|
||||
use it by th_call_super().
|
||||
|
||||
* insns.def: ditto.
|
||||
|
||||
Tue Jan 16 17:48:11 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* common.mk: fix ruby script path.
|
||||
|
|
51
vm.c
51
vm.c
|
@ -526,6 +526,25 @@ th_call0(yarv_thread_t *th, VALUE klass, VALUE recv,
|
|||
return val;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
search_super_klass(VALUE klass, VALUE recv)
|
||||
{
|
||||
if (BUILTIN_TYPE(klass) == T_CLASS) {
|
||||
klass = RCLASS(klass)->super;
|
||||
}
|
||||
else if (BUILTIN_TYPE(klass) == T_MODULE) {
|
||||
VALUE k = CLASS_OF(recv);
|
||||
while (k) {
|
||||
if (BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass) {
|
||||
klass = RCLASS(k)->super;
|
||||
break;
|
||||
}
|
||||
k = RCLASS(k)->super;
|
||||
}
|
||||
}
|
||||
return klass;
|
||||
}
|
||||
|
||||
VALUE
|
||||
th_call_super(yarv_thread_t *th, int argc, const VALUE *argv)
|
||||
{
|
||||
|
@ -535,9 +554,15 @@ th_call_super(yarv_thread_t *th, int argc, const VALUE *argv)
|
|||
NODE *body;
|
||||
int nosuper = 0;
|
||||
yarv_control_frame_t *cfp = th->cfp;
|
||||
|
||||
|
||||
if (!th->cfp->iseq) {
|
||||
klass = RCLASS(cfp->method_klass)->super;
|
||||
klass = cfp->method_klass;
|
||||
klass = RCLASS(klass)->super;
|
||||
|
||||
if (klass == 0) {
|
||||
klass = search_super_klass(cfp->method_klass, recv);
|
||||
}
|
||||
|
||||
id = cfp->method_id;
|
||||
}
|
||||
else {
|
||||
|
@ -545,14 +570,17 @@ th_call_super(yarv_thread_t *th, int argc, const VALUE *argv)
|
|||
}
|
||||
|
||||
body = rb_method_node(klass, id); /* this returns NODE_METHOD */
|
||||
|
||||
if (body) {
|
||||
body = body->nd_body;
|
||||
}
|
||||
else {
|
||||
dp(recv);
|
||||
dp(klass);
|
||||
dpi(id);
|
||||
rb_bug("th_call_super: not found");
|
||||
}
|
||||
|
||||
return th_call0(th, klass, recv, id, id, argc, argv, body, nosuper);
|
||||
}
|
||||
|
||||
|
@ -1174,25 +1202,6 @@ eval_define_method(yarv_thread_t *th, VALUE obj,
|
|||
INC_VM_STATE_VERSION();
|
||||
}
|
||||
|
||||
EVALBODY_HELPER_FUNCTION VALUE
|
||||
eval_search_super_klass(VALUE klass, VALUE recv)
|
||||
{
|
||||
if (BUILTIN_TYPE(klass) == T_CLASS) {
|
||||
klass = RCLASS(klass)->super;
|
||||
}
|
||||
else if (BUILTIN_TYPE(klass) == T_MODULE) {
|
||||
VALUE k = CLASS_OF(recv);
|
||||
while (k) {
|
||||
if (BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass) {
|
||||
klass = RCLASS(k)->super;
|
||||
break;
|
||||
}
|
||||
k = RCLASS(k)->super;
|
||||
}
|
||||
}
|
||||
return klass;
|
||||
}
|
||||
|
||||
EVALBODY_HELPER_FUNCTION VALUE
|
||||
eval_method_missing(yarv_thread_t *th, ID id, VALUE recv, int num,
|
||||
yarv_block_t *blockptr, int opt)
|
||||
|
|
Loading…
Reference in a new issue