ruby-changes:32306
From: nobu <ko1@a...>
Date: Tue, 24 Dec 2013 23:04:37 +0900 (JST)
Subject: [ruby-changes:32306] nobu:r44385 (trunk): vm.c: check cbase
nobu 2013-12-24 23:04:31 +0900 (Tue, 24 Dec 2013) New Revision: 44385 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44385 Log: vm.c: check cbase * vm.c (rb_vm_cref_in_context): check also cbase, not only self. Modified files: trunk/proc.c trunk/vm.c Index: proc.c =================================================================== --- proc.c (revision 44384) +++ proc.c (revision 44385) @@ -14,7 +14,7 @@ https://github.com/ruby/ruby/blob/trunk/proc.c#L14 #include "gc.h" #include "iseq.h" -NODE *rb_vm_cref_in_context(VALUE self); +const NODE *rb_vm_cref_in_context(VALUE self, VALUE cbase); struct METHOD { VALUE recv; @@ -1622,9 +1622,9 @@ rb_mod_define_method(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/proc.c#L1622 ID id; VALUE body; int noex = NOEX_PUBLIC; - const NODE *cref = rb_vm_cref_in_context(mod); + const NODE *cref = rb_vm_cref_in_context(mod, mod); - if (cref && cref->nd_clss == mod) { + if (cref) { noex = (int)cref->nd_visi; } Index: vm.c =================================================================== --- vm.c (revision 44384) +++ vm.c (revision 44385) @@ -930,13 +930,16 @@ rb_vm_cref(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L930 return rb_vm_get_cref(cfp->iseq, cfp->ep); } -NODE * -rb_vm_cref_in_context(VALUE self) +const NODE * +rb_vm_cref_in_context(VALUE self, VALUE cbase) { rb_thread_t *th = GET_THREAD(); const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); + const NODE *cref; if (cfp->self != self) return NULL; - return rb_vm_get_cref(cfp->iseq, cfp->ep); + cref = rb_vm_get_cref(cfp->iseq, cfp->ep); + if (cref->nd_clss != cbase) return NULL; + return cref; } #if 0 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/