зеркало из https://github.com/github/ruby.git
vm_insnhelper.c: no recv
* vm_insnhelper.c (vm_search_normal_superclass): no longer needs receiver, klass is always unique in the ancestors now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e421410edc
Коммит
260d02d91d
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Aug 4 01:56:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_search_normal_superclass): no longer needs
|
||||||
|
receiver, klass is always unique in the ancestors now.
|
||||||
|
|
||||||
Sat Aug 4 01:27:40 2012 Shugo Maeda <shugo@ruby-lang.org>
|
Sat Aug 4 01:27:40 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* insns.def (invokesuper): reverted r36612 so that super in an
|
* insns.def (invokesuper): reverted r36612 so that super in an
|
||||||
|
|
|
@ -828,7 +828,7 @@ defined
|
||||||
case DEFINED_ZSUPER:{
|
case DEFINED_ZSUPER:{
|
||||||
const rb_method_entry_t *me = GET_CFP()->me;
|
const rb_method_entry_t *me = GET_CFP()->me;
|
||||||
if (me) {
|
if (me) {
|
||||||
VALUE klass = vm_search_normal_superclass(me->klass, GET_SELF());
|
VALUE klass = vm_search_normal_superclass(me->klass);
|
||||||
ID id = me->def ? me->def->original_id : me->called_id;
|
ID id = me->def ? me->def->original_id : me->called_id;
|
||||||
if (rb_method_boundp(klass, id, 0)) {
|
if (rb_method_boundp(klass, id, 0)) {
|
||||||
expr_type = "super";
|
expr_type = "super";
|
||||||
|
@ -1039,7 +1039,7 @@ invokesuper
|
||||||
flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
|
flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
|
||||||
|
|
||||||
recv = GET_SELF();
|
recv = GET_SELF();
|
||||||
vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
|
vm_search_superclass(GET_CFP(), GET_ISEQ(), TOPN(num), &id, &klass);
|
||||||
|
|
||||||
ip = GET_ISEQ();
|
ip = GET_ISEQ();
|
||||||
while (ip && !ip->klass) {
|
while (ip && !ip->klass) {
|
||||||
|
|
|
@ -164,7 +164,7 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
|
||||||
klass = RCLASS_SUPER(cfp->klass);
|
klass = RCLASS_SUPER(cfp->klass);
|
||||||
|
|
||||||
if (klass == 0) {
|
if (klass == 0) {
|
||||||
klass = vm_search_normal_superclass(cfp->me->klass, recv);
|
klass = vm_search_normal_superclass(cfp->me->klass);
|
||||||
}
|
}
|
||||||
id = cfp->me->def->original_id;
|
id = cfp->me->def->original_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1461,32 +1461,15 @@ vm_method_search(VALUE id, VALUE klass, IC ic, VALUE *defined_class_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
vm_search_normal_superclass(VALUE klass, VALUE recv)
|
vm_search_normal_superclass(VALUE klass)
|
||||||
{
|
{
|
||||||
if (BUILTIN_TYPE(klass) == T_CLASS || BUILTIN_TYPE(klass) == T_ICLASS) {
|
klass = RCLASS_ORIGIN(klass);
|
||||||
klass = RCLASS_ORIGIN(klass);
|
return RCLASS_SUPER(klass);
|
||||||
return RCLASS_SUPER(klass);
|
|
||||||
}
|
|
||||||
else if (BUILTIN_TYPE(klass) == T_MODULE) {
|
|
||||||
VALUE k = CLASS_OF(recv);
|
|
||||||
while (k) {
|
|
||||||
if (BUILTIN_TYPE(k) == T_ICLASS && RBASIC(k)->klass == klass) {
|
|
||||||
return RCLASS_SUPER(k);
|
|
||||||
}
|
|
||||||
k = RCLASS_SUPER(k);
|
|
||||||
}
|
|
||||||
return rb_cObject;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rb_bug("vm_search_normal_superclass: should not be reach here");
|
|
||||||
}
|
|
||||||
|
|
||||||
UNREACHABLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *iseq,
|
vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *iseq,
|
||||||
VALUE recv, VALUE sigval,
|
VALUE sigval,
|
||||||
ID *idp, VALUE *klassp)
|
ID *idp, VALUE *klassp)
|
||||||
{
|
{
|
||||||
ID id;
|
ID id;
|
||||||
|
@ -1532,10 +1515,10 @@ vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *iseq,
|
||||||
}
|
}
|
||||||
|
|
||||||
id = lcfp->me->def->original_id;
|
id = lcfp->me->def->original_id;
|
||||||
klass = vm_search_normal_superclass(lcfp->klass, recv);
|
klass = vm_search_normal_superclass(lcfp->klass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
klass = vm_search_normal_superclass(reg_cfp->klass, recv);
|
klass = vm_search_normal_superclass(reg_cfp->klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
*idp = id;
|
*idp = id;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче