summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-18 11:46:31 (GMT)
committerktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-18 11:46:31 (GMT)
commit231f45ad3626a1c4e9828524ed661771a6793af0 (patch)
tree271309b86b954299303947848835fc3ed690a046 /vm.c
parent108627d911260126ca144d2b4b74f3fda3acfabd (diff)
* vm_core.h, vm.c, proc.c: fix GC mark miss on bindings.
[ruby-dev:48616] [Bug #10368] * test/ruby/test_eval.rb: add a test code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index cc88926..34b2103 100644
--- a/vm.c
+++ b/vm.c
@@ -688,6 +688,39 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass)
return procval;
}
+/* Binding */
+
+VALUE
+rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp)
+{
+ rb_control_frame_t *cfp = rb_vm_get_binding_creatable_next_cfp(th, src_cfp);
+ rb_control_frame_t *ruby_level_cfp = rb_vm_get_ruby_level_next_cfp(th, src_cfp);
+ VALUE bindval, envval;
+ rb_binding_t *bind;
+ VALUE blockprocval = 0;
+
+ if (cfp == 0 || ruby_level_cfp == 0) {
+ rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber.");
+ }
+
+ while (1) {
+ envval = vm_make_env_object(th, cfp, &blockprocval);
+ if (cfp == ruby_level_cfp) {
+ break;
+ }
+ cfp = rb_vm_get_binding_creatable_next_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
+ }
+
+ bindval = rb_binding_alloc(rb_cBinding);
+ GetBindingPtr(bindval, bind);
+ bind->env = envval;
+ bind->path = ruby_level_cfp->iseq->location.path;
+ bind->blockprocval = blockprocval;
+ bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp);
+
+ return bindval;
+}
+
VALUE *
rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
{
@@ -699,6 +732,7 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
NODE *node = 0;
ID minibuf[4], *dyns = minibuf;
VALUE idtmp = 0;
+ VALUE blockprocval = 0;
if (dyncount < 0) return 0;
@@ -719,7 +753,8 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
ALLOCV_END(idtmp);
vm_set_eval_stack(th, iseqval, 0, base_block);
- bind->env = rb_vm_make_env_object(th, th->cfp);
+ bind->env = vm_make_env_object(th, th->cfp, &blockprocval);
+ bind->blockprocval = blockprocval;
vm_pop_frame(th);
GetEnvPtr(bind->env, env);