mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_eval.c (eval_string_with_cref): propagative filename and line_no
of binding. [ruby-dev:38767] [ruby-core:28307] * vm_core.h (rb_binding_t), proc.c: add filename and line_no fields to preserve them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d49052b597
commit
b8571b4285
5 changed files with 22 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Mon May 10 03:36:56 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* vm_eval.c (eval_string_with_cref): propagative filename and line_no
|
||||||
|
of binding. [ruby-dev:38767] [ruby-core:28307]
|
||||||
|
|
||||||
|
* vm_core.h (rb_binding_t), proc.c: add filename and line_no fields to
|
||||||
|
preserve them.
|
||||||
|
|
||||||
Mon May 10 02:58:33 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
Mon May 10 02:58:33 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* compile.c (iseq_compile_each), vm_insnhelper.c (vm_invoke_block,
|
* compile.c (iseq_compile_each), vm_insnhelper.c (vm_invoke_block,
|
||||||
|
|
|
@ -287,7 +287,7 @@ assert_normal_exit %q{
|
||||||
eval("", method(:proc).call {}.binding)
|
eval("", method(:proc).call {}.binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_equal "(eval):1:in `block in <main>': ", %q{
|
assert_equal "", %q{
|
||||||
b = binding
|
b = binding
|
||||||
10.times{
|
10.times{
|
||||||
eval('', b)
|
eval('', b)
|
||||||
|
|
7
proc.c
7
proc.c
|
@ -255,6 +255,7 @@ binding_mark(void *ptr)
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
bind = ptr;
|
bind = ptr;
|
||||||
RUBY_MARK_UNLESS_NULL(bind->env);
|
RUBY_MARK_UNLESS_NULL(bind->env);
|
||||||
|
RUBY_MARK_UNLESS_NULL(bind->filename);
|
||||||
}
|
}
|
||||||
RUBY_MARK_LEAVE("binding");
|
RUBY_MARK_LEAVE("binding");
|
||||||
}
|
}
|
||||||
|
@ -290,6 +291,8 @@ binding_dup(VALUE self)
|
||||||
GetBindingPtr(self, src);
|
GetBindingPtr(self, src);
|
||||||
GetBindingPtr(bindval, dst);
|
GetBindingPtr(bindval, dst);
|
||||||
dst->env = src->env;
|
dst->env = src->env;
|
||||||
|
dst->filename = src->filename;
|
||||||
|
dst->line_no = src->line_no;
|
||||||
return bindval;
|
return bindval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +319,8 @@ rb_binding_new(void)
|
||||||
|
|
||||||
GetBindingPtr(bindval, bind);
|
GetBindingPtr(bindval, bind);
|
||||||
bind->env = rb_vm_make_env_object(th, cfp);
|
bind->env = rb_vm_make_env_object(th, cfp);
|
||||||
|
bind->filename = cfp->iseq->filename;
|
||||||
|
bind->line_no = rb_vm_get_sourceline(cfp);
|
||||||
return bindval;
|
return bindval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1892,6 +1897,8 @@ proc_binding(VALUE self)
|
||||||
bindval = binding_alloc(rb_cBinding);
|
bindval = binding_alloc(rb_cBinding);
|
||||||
GetBindingPtr(bindval, bind);
|
GetBindingPtr(bindval, bind);
|
||||||
bind->env = proc->envval;
|
bind->env = proc->envval;
|
||||||
|
bind->filename = proc->block.iseq->filename;
|
||||||
|
bind->line_no = rb_iseq_first_lineno(proc->block.iseq);
|
||||||
return bindval;
|
return bindval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -524,6 +524,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
VALUE env;
|
VALUE env;
|
||||||
|
VALUE filename;
|
||||||
|
unsigned short line_no;
|
||||||
} rb_binding_t;
|
} rb_binding_t;
|
||||||
|
|
||||||
/* used by compile time and send insn */
|
/* used by compile time and send insn */
|
||||||
|
|
|
@ -963,6 +963,10 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char
|
||||||
if (rb_obj_is_kind_of(scope, rb_cBinding)) {
|
if (rb_obj_is_kind_of(scope, rb_cBinding)) {
|
||||||
GetBindingPtr(scope, bind);
|
GetBindingPtr(scope, bind);
|
||||||
envval = bind->env;
|
envval = bind->env;
|
||||||
|
if (strcmp(file, "(eval)") == 0) {
|
||||||
|
file = RSTRING_PTR(bind->filename);
|
||||||
|
line = bind->line_no;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
|
|
Loading…
Add table
Reference in a new issue