summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 12:24:58 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 12:24:58 +0000
commitd84f9b16946bca06ce0557ebe99152d7d445c9ec (patch)
tree8141a5d835d1e5638231aced09a08c74ff8fadae /iseq.c
parente0f5a6ab4850e2745d5cb6fb081eb81dc024d2d4 (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 'iseq.c')
-rw-r--r--iseq.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/iseq.c b/iseq.c
index de65dcbf33..1eac9309f3 100644
--- a/iseq.c
+++ b/iseq.c
@@ -121,7 +121,6 @@ iseq_mark(void *ptr)
RUBY_MARK_UNLESS_NULL(iseq->location.path);
RUBY_MARK_UNLESS_NULL(iseq->location.absolute_path);
- RUBY_MARK_UNLESS_NULL((VALUE)iseq->cref_stack);
RUBY_MARK_UNLESS_NULL(iseq->klass);
RUBY_MARK_UNLESS_NULL(iseq->coverage);
RUBY_MARK_UNLESS_NULL(iseq->orig);
@@ -213,38 +212,21 @@ iseq_location_setup(rb_iseq_t *iseq, VALUE path, VALUE absolute_path, VALUE name
return loc;
}
-#define ISEQ_SET_CREF(iseq, cref) RB_OBJ_WRITE((iseq)->self, &(iseq)->cref_stack, (cref))
-
static void
set_relation(rb_iseq_t *iseq, const VALUE parent)
{
const VALUE type = iseq->type;
- rb_thread_t *th = GET_THREAD();
rb_iseq_t *piseq;
/* set class nest stack */
if (type == ISEQ_TYPE_TOP) {
- /* toplevel is private */
- RB_OBJ_WRITE(iseq->self, &iseq->cref_stack, NEW_CREF(rb_cObject));
- iseq->cref_stack->nd_refinements = Qnil;
- iseq->cref_stack->nd_visi = NOEX_PRIVATE;
- if (th->top_wrapper) {
- NODE *cref = NEW_CREF(th->top_wrapper);
- cref->nd_refinements = Qnil;
- cref->nd_visi = NOEX_PRIVATE;
- RB_OBJ_WRITE(cref, &cref->nd_next, iseq->cref_stack);
- ISEQ_SET_CREF(iseq, cref);
- }
iseq->local_iseq = iseq;
}
else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
- ISEQ_SET_CREF(iseq, NEW_CREF(0)); /* place holder */
- iseq->cref_stack->nd_refinements = Qnil;
iseq->local_iseq = iseq;
}
else if (RTEST(parent)) {
GetISeqPtr(parent, piseq);
- ISEQ_SET_CREF(iseq, piseq->cref_stack);
iseq->local_iseq = piseq->local_iseq;
}
@@ -1973,13 +1955,8 @@ rb_iseq_clone(VALUE iseqval, VALUE newcbase)
if (iseq0->local_iseq == iseq0) {
iseq1->local_iseq = iseq1;
}
+
if (newcbase) {
- ISEQ_SET_CREF(iseq1, NEW_CREF(newcbase));
- RB_OBJ_WRITE(iseq1->cref_stack, &iseq1->cref_stack->nd_refinements, iseq0->cref_stack->nd_refinements);
- iseq1->cref_stack->nd_visi = iseq0->cref_stack->nd_visi;
- if (iseq0->cref_stack->nd_next) {
- RB_OBJ_WRITE(iseq1->cref_stack, &iseq1->cref_stack->nd_next, iseq0->cref_stack->nd_next);
- }
RB_OBJ_WRITE(iseq1->self, &iseq1->klass, newcbase);
}