summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 11:58:10 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 11:58:10 +0000
commit956cc2934d9848fa4c5cc7bcf79edd76f1171053 (patch)
treebdcfcf6bbd3ab68b7797dd70208bd4efa6a322de /vm.c
parent5faf4cc77b6a223dc86fddc69e0f377d27f5585a (diff)
* 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
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/vm.c b/vm.c
index f4ecec4..5b2473f 100644
--- a/vm.c
+++ b/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) {