зеркало из https://github.com/github/ruby.git
* vm.c (rb_vm_make_env_object): make Proc object if Env is possible
to point block. [ruby-core:41038] [ruby-trunk - Bug #5634] * vm.c (rb_vm_make_proc): No need to make Proc object here. * bootstraptest/test_proc.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5faf4cc77b
Коммит
956cc2934d
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Tue Nov 27 19:56:43 2012 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm.c (rb_vm_make_env_object): make Proc object if Env is possible
|
||||
to point block.
|
||||
[ruby-core:41038] [ruby-trunk - Bug #5634]
|
||||
|
||||
* vm.c (rb_vm_make_proc): No need to make Proc object here.
|
||||
|
||||
* bootstraptest/test_proc.rb: add tests.
|
||||
|
||||
Tue Nov 27 18:51:06 2012 Naohisa Goto <ngotogenome@gmail.com>
|
||||
|
||||
* ruby_atomic.h (ATOMIC_CAS): added for Solaris and other platforms.
|
||||
|
|
|
@ -456,3 +456,28 @@ assert_equal 'ok', %q{
|
|||
end
|
||||
}
|
||||
|
||||
assert_equal 'ok', %q{
|
||||
def x
|
||||
binding
|
||||
end
|
||||
b = x{|a| a }
|
||||
b.eval('yield("ok")')
|
||||
}, '[Bug #5634]'
|
||||
|
||||
assert_equal 'ok', %q{
|
||||
def x
|
||||
binding
|
||||
end
|
||||
eval("x { 'ok' }").eval "yield"
|
||||
}, '[Bug #5634]'
|
||||
|
||||
assert_equal 'ok', %q{
|
||||
def x
|
||||
binding
|
||||
end
|
||||
def m
|
||||
x{ 'ok' }
|
||||
end
|
||||
eval('yield', m)
|
||||
}, '[Bug #5634]'
|
||||
|
||||
|
|
22
vm.c
22
vm.c
|
@ -476,13 +476,23 @@ vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *ep, VALUE ary)
|
|||
}
|
||||
|
||||
static void vm_rewrite_ep_in_errinfo(rb_thread_t *th);
|
||||
static VALUE vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block);
|
||||
|
||||
VALUE
|
||||
rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
|
||||
{
|
||||
VALUE envval;
|
||||
VALUE *lep = VM_CF_LEP(cfp);
|
||||
rb_block_t *blockptr = VM_EP_BLOCK_PTR(lep);
|
||||
|
||||
envval = vm_make_env_each(th, cfp, cfp->ep, VM_CF_LEP(cfp));
|
||||
if (blockptr) {
|
||||
VALUE blockprocval = vm_make_proc_from_block(th, blockptr);
|
||||
rb_proc_t *p;
|
||||
GetProcPtr(blockprocval, p);
|
||||
lep[0] = VM_ENVVAL_BLOCK_PTR(&p->block);
|
||||
}
|
||||
|
||||
envval = vm_make_env_each(th, cfp, cfp->ep, lep);
|
||||
vm_rewrite_ep_in_errinfo(th);
|
||||
|
||||
if (PROCDEBUG) {
|
||||
|
@ -545,21 +555,11 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass)
|
|||
VALUE procval, envval, blockprocval = 0;
|
||||
rb_proc_t *proc;
|
||||
rb_control_frame_t *cfp = RUBY_VM_GET_CFP_FROM_BLOCK_PTR(block);
|
||||
rb_block_t *block2;
|
||||
|
||||
if (block->proc) {
|
||||
rb_bug("rb_vm_make_proc: Proc value is already created.");
|
||||
}
|
||||
|
||||
if ((block2 = VM_CF_BLOCK_PTR(cfp)) != 0) {
|
||||
rb_proc_t *p;
|
||||
|
||||
blockprocval = vm_make_proc_from_block(th, block2);
|
||||
|
||||
GetProcPtr(blockprocval, p);
|
||||
*VM_CF_LEP(cfp) = VM_ENVVAL_BLOCK_PTR(&p->block);
|
||||
}
|
||||
|
||||
envval = rb_vm_make_env_object(th, cfp);
|
||||
|
||||
if (PROCDEBUG) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче