@@ -262,6 +262,7 @@ binding_mark(void *ptr)
262262 bind = ptr ;
263263 RUBY_MARK_UNLESS_NULL (bind -> env );
264264 RUBY_MARK_UNLESS_NULL (bind -> path );
265+ RUBY_MARK_UNLESS_NULL (bind -> blockprocval );
265266 }
266267 RUBY_MARK_LEAVE ("binding" );
267268}
@@ -282,8 +283,8 @@ const rb_data_type_t ruby_binding_data_type = {
282283 NULL , NULL , RUBY_TYPED_FREE_IMMEDIATELY
283284};
284285
285- static VALUE
286- binding_alloc (VALUE klass )
286+ VALUE
287+ rb_binding_alloc (VALUE klass )
287288{
288289 VALUE obj ;
289290 rb_binding_t * bind ;
@@ -295,12 +296,13 @@ binding_alloc(VALUE klass)
295296static VALUE
296297binding_dup (VALUE self )
297298{
298- VALUE bindval = binding_alloc (rb_cBinding );
299+ VALUE bindval = rb_binding_alloc (rb_cBinding );
299300 rb_binding_t * src , * dst ;
300301 GetBindingPtr (self , src );
301302 GetBindingPtr (bindval , dst );
302303 dst -> env = src -> env ;
303304 dst -> path = src -> path ;
305+ dst -> blockprocval = src -> blockprocval ;
304306 dst -> first_lineno = src -> first_lineno ;
305307 return bindval ;
306308}
@@ -317,30 +319,7 @@ binding_clone(VALUE self)
317319VALUE
318320rb_binding_new_with_cfp (rb_thread_t * th , const rb_control_frame_t * src_cfp )
319321{
320- rb_control_frame_t * cfp = rb_vm_get_binding_creatable_next_cfp (th , src_cfp );
321- rb_control_frame_t * ruby_level_cfp = rb_vm_get_ruby_level_next_cfp (th , src_cfp );
322- VALUE bindval , envval ;
323- rb_binding_t * bind ;
324-
325- if (cfp == 0 || ruby_level_cfp == 0 ) {
326- rb_raise (rb_eRuntimeError , "Can't create Binding Object on top of Fiber." );
327- }
328-
329- while (1 ) {
330- envval = rb_vm_make_env_object (th , cfp );
331- if (cfp == ruby_level_cfp ) {
332- break ;
333- }
334- cfp = rb_vm_get_binding_creatable_next_cfp (th , RUBY_VM_PREVIOUS_CONTROL_FRAME (cfp ));
335- }
336-
337- bindval = binding_alloc (rb_cBinding );
338- GetBindingPtr (bindval , bind );
339- bind -> env = envval ;
340- bind -> path = ruby_level_cfp -> iseq -> location .path ;
341- bind -> first_lineno = rb_vm_get_sourceline (ruby_level_cfp );
342-
343- return bindval ;
322+ return rb_vm_make_binding (th , src_cfp );
344323}
345324
346325VALUE
@@ -2409,9 +2388,10 @@ proc_binding(VALUE self)
24092388 }
24102389 }
24112390
2412- bindval = binding_alloc (rb_cBinding );
2391+ bindval = rb_binding_alloc (rb_cBinding );
24132392 GetBindingPtr (bindval , bind );
24142393 bind -> env = proc -> envval ;
2394+ bind -> blockprocval = proc -> blockprocval ;
24152395 if (RUBY_VM_NORMAL_ISEQ_P (proc -> block .iseq )) {
24162396 bind -> path = proc -> block .iseq -> location .path ;
24172397 bind -> first_lineno = FIX2INT (rb_iseq_first_lineno (proc -> block .iseq -> self ));
0 commit comments