mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* proc.c: support Binding#eval.
* yarvtest/test_eval.rb: add a test for above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0d70d88643
commit
a4a8101965
3 changed files with 234 additions and 216 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Feb 6 03:47:58 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* proc.c: support Binding#eval.
|
||||
|
||||
* yarvtest/test_eval.rb: add a test for above change.
|
||||
|
||||
Tue Feb 6 03:13:33 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* proc.c: refactoring (remove K&R style, move Binding stuffs from
|
||||
|
|
10
proc.c
10
proc.c
|
@ -282,10 +282,13 @@ rb_f_binding(VALUE self)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
bind_eval(int argc, VALUE *argv, VALUE bind)
|
||||
bind_eval(int argc, VALUE *argv, VALUE bindval)
|
||||
{
|
||||
UNSUPPORTED(bind_eval);
|
||||
return Qnil;
|
||||
VALUE args[4];
|
||||
|
||||
rb_scan_args(argc, argv, "12", &args[0], &args[2], &args[3]);
|
||||
args[1] = bindval;
|
||||
return rb_f_eval(argc+1, args, Qnil /* self will be searched in eval */);
|
||||
}
|
||||
|
||||
#define PROC_TSHIFT (FL_USHIFT+1)
|
||||
|
@ -1584,6 +1587,7 @@ Init_Binding(void)
|
|||
rb_undef_method(CLASS_OF(rb_cBinding), "new");
|
||||
rb_define_method(rb_cBinding, "clone", binding_clone, 0);
|
||||
rb_define_method(rb_cBinding, "dup", binding_dup, 0);
|
||||
rb_define_method(rb_cBinding, "eval", bind_eval, -1);
|
||||
rb_define_global_function("binding", rb_f_binding, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,14 @@ class TestEval < YarvTestBase
|
|||
a = :ng
|
||||
eval("a", b)
|
||||
}
|
||||
ae %q{
|
||||
class C
|
||||
def foo
|
||||
binding
|
||||
end
|
||||
end
|
||||
C.new.foo.eval("self.class.to_s")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue