diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-06 12:24:58 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-06 12:24:58 +0000 |
commit | d84f9b16946bca06ce0557ebe99152d7d445c9ec (patch) | |
tree | 8141a5d835d1e5638231aced09a08c74ff8fadae /proc.c | |
parent | e0f5a6ab4850e2745d5cb6fb081eb81dc024d2d4 (diff) |
* 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
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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; } |