mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* vm.c (rb_vm_cref_replace_with_duplicated_cref): added.
CREFs should not be shared by methods between `using'. [Bug #11247] * vm_insnhelper.c (vm_cref_replace_with_duplicated_cref): ditto. * vm.c (vm_cref_dup): should copy refinements correctly. * eval.c: use rb_vm_cref_replace_with_duplicated_cref(). * eval_intern.h: add a decl. of rb_vm_cref_replace_with_duplicated_cref(). * vm_eval.c (eval_string_with_cref): do not need to pass scope's CREF because VM can find out CREF from stack frames. * test/ruby/test_refinement.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
895b44dcf6
commit
c267d24ef0
7 changed files with 167 additions and 8 deletions
20
vm.c
20
vm.c
|
@ -136,10 +136,17 @@ vm_cref_dup(const rb_cref_t *cref)
|
|||
{
|
||||
VALUE klass = CREF_CLASS(cref);
|
||||
const rb_scope_visibility_t *visi = CREF_SCOPE_VISI(cref);
|
||||
rb_cref_t *next_cref = CREF_NEXT(cref);
|
||||
rb_cref_t *next_cref = CREF_NEXT(cref), *new_cref;
|
||||
int pushed_by_eval = CREF_PUSHED_BY_EVAL(cref);
|
||||
|
||||
return vm_cref_new(klass, visi->method_visi, visi->module_func, next_cref, pushed_by_eval);
|
||||
new_cref = vm_cref_new(klass, visi->method_visi, visi->module_func, next_cref, pushed_by_eval);
|
||||
|
||||
if (!NIL_P(CREF_REFINEMENTS(cref))) {
|
||||
CREF_REFINEMENTS_SET(new_cref, rb_hash_dup(CREF_REFINEMENTS(cref)));
|
||||
CREF_OMOD_SHARED_UNSET(new_cref);
|
||||
}
|
||||
|
||||
return new_cref;
|
||||
}
|
||||
|
||||
static rb_cref_t *
|
||||
|
@ -1192,6 +1199,15 @@ rb_vm_cref(void)
|
|||
return rb_vm_get_cref(cfp->ep);
|
||||
}
|
||||
|
||||
rb_cref_t *
|
||||
rb_vm_cref_replace_with_duplicated_cref(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
|
||||
rb_cref_t *cref = vm_cref_replace_with_duplicated_cref(cfp->ep);
|
||||
return cref;
|
||||
}
|
||||
|
||||
const rb_cref_t *
|
||||
rb_vm_cref_in_context(VALUE self, VALUE cbase)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue