mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored to rb_method_definition_t::body.iseq_body.cref. * vm_insnhelper.c: modify SVAR usage. When calling ISEQ type method, push CREF information onto method frame, SVAR located place. Before this fix, SVAR is simply nil. After this patch, CREF (or NULL == Qfalse for not iseq methods) is stored at the method invocation. When SVAR is requierd, then put NODE_IF onto SVAR location, and NDOE_IF::nd_reserved points CREF itself. * vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added. * vm_insnhelper.c (vm_push_frame): accept CREF. * method.h, vm_method.c (rb_add_method_iseq): added. This function accepts iseq and CREF. * class.c (clone_method): use rb_add_method_iseq(). * gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref. * iseq.c: remove CREF related codes. * insns.def (getinlinecache/setinlinecache): CREF should be cache key because a different CREF has a different namespace. * node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR. * proc.c: catch up changes. * struct.c: ditto. * insns.def: ditto. * vm_args.c (raise_argument_error): ditto. * vm_eval.c: ditto. * test/ruby/test_class.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e0f5a6ab48
commit
d84f9b1694
16 changed files with 378 additions and 131 deletions
20
proc.c
20
proc.c
|
@ -1208,7 +1208,6 @@ mnew_internal(rb_method_entry_t *me, VALUE defined_class, VALUE klass,
|
|||
def->type = VM_METHOD_TYPE_MISSING;
|
||||
def->original_id = id;
|
||||
def->alias_count = 0;
|
||||
|
||||
}
|
||||
data->ume = ALLOC(struct unlinked_method_entry_list_entry);
|
||||
data->me->def->alias_count++;
|
||||
|
@ -2025,7 +2024,7 @@ rb_method_entry_min_max_arity(const rb_method_entry_t *me, int *max)
|
|||
case VM_METHOD_TYPE_BMETHOD:
|
||||
return rb_proc_min_max_arity(def->body.proc, max);
|
||||
case VM_METHOD_TYPE_ISEQ: {
|
||||
rb_iseq_t *iseq = def->body.iseq;
|
||||
rb_iseq_t *iseq = def->body.iseq_body.iseq;
|
||||
return rb_iseq_min_max_arity(iseq, max);
|
||||
}
|
||||
case VM_METHOD_TYPE_UNDEF:
|
||||
|
@ -2162,12 +2161,24 @@ method_get_iseq(rb_method_definition_t *def)
|
|||
case VM_METHOD_TYPE_BMETHOD:
|
||||
return get_proc_iseq(def->body.proc, 0);
|
||||
case VM_METHOD_TYPE_ISEQ:
|
||||
return def->body.iseq;
|
||||
return def->body.iseq_body.iseq;
|
||||
default:
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static NODE *
|
||||
method_get_cref(rb_method_definition_t *def)
|
||||
{
|
||||
switch (def->type) {
|
||||
case VM_METHOD_TYPE_ISEQ:
|
||||
return def->body.iseq_body.cref;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rb_iseq_t *
|
||||
rb_method_get_iseq(VALUE method)
|
||||
{
|
||||
|
@ -2376,6 +2387,7 @@ method_proc(VALUE method)
|
|||
env->block.self = meth->recv;
|
||||
env->block.klass = meth->defined_class;
|
||||
env->block.iseq = method_get_iseq(meth->me->def);
|
||||
env->block.ep[-1] = (VALUE)method_get_cref(meth->me->def);
|
||||
return procval;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue