Created
August 9, 2012 15:44
-
-
Save wanabe/3305290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/proc.c b/proc.c | |
| index 6ccb888..3872e81 100644 | |
| --- a/proc.c | |
| +++ b/proc.c | |
| @@ -316,6 +316,10 @@ rb_binding_new(void) | |
| rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); | |
| VALUE bindval = binding_alloc(rb_cBinding); | |
| rb_binding_t *bind; | |
| + rb_block_t *block; | |
| + VALUE blockval, *ptr; | |
| + rb_proc_t *proc; | |
| + rb_env_t *env; | |
| if (cfp == 0) { | |
| rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber."); | |
| @@ -325,6 +329,18 @@ rb_binding_new(void) | |
| bind->env = rb_vm_make_env_object(th, cfp); | |
| bind->path = cfp->iseq->location.path; | |
| bind->first_lineno = rb_vm_get_sourceline(cfp); | |
| + | |
| + block = rb_vm_control_frame_block_ptr(cfp); | |
| + if(block && block->proc == 0) { | |
| + blockval = rb_vm_make_proc(th, block, rb_cProc); | |
| + GetProcPtr(blockval, proc); | |
| + GetEnvPtr(bind->env, env); | |
| + ptr = &env->env[env->local_size]; | |
| + while (GC_GUARDED_PTR_REF(*ptr) != block) { | |
| + ptr = GC_GUARDED_PTR_REF(*ptr); | |
| + } | |
| + *ptr = VM_ENVVAL_BLOCK_PTR(&proc->block); | |
| + } | |
| return bindval; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment