* eval.c (proc_to_proc): return self. [new]

* eval.c (block_pass): no need to convert if block is Proc.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-04-24 05:58:34 +00:00
parent 0efc6365aa
commit 565fec45b9
2 changed files with 21 additions and 5 deletions

View File

@ -1,3 +1,9 @@
Wed Apr 24 14:56:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (proc_to_proc): return self. [new]
* eval.c (block_pass): no need to convert if block is Proc.
Wed Apr 24 14:21:41 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in: set size of the initial stack from

20
eval.c
View File

@ -6584,6 +6584,13 @@ proc_to_s(self, other)
return str;
}
static VALUE
proc_to_proc(proc)
VALUE proc;
{
return proc;
}
static VALUE
block_pass(self, node)
VALUE self;
@ -6605,12 +6612,14 @@ block_pass(self, node)
POP_ITER();
return result;
}
b = rb_check_convert_type(block, T_DATA, "Proc", "to_proc");
if (!rb_obj_is_proc(b)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
rb_class2name(CLASS_OF(block)));
if (!rb_obj_is_proc(block)) {
b = rb_check_convert_type(block, T_DATA, "Proc", "to_proc");
if (!rb_obj_is_proc(b)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
rb_class2name(CLASS_OF(block)));
}
block = b;
}
block = b;
if (rb_safe_level() >= 1 && OBJ_TAINTED(block)) {
if (rb_safe_level() > proc_get_safe_level(block)) {
@ -7081,6 +7090,7 @@ Init_Proc()
rb_define_method(rb_cProc, "[]", proc_call, -2);
rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
rb_define_global_function("proc", rb_f_lambda, 0);
rb_define_global_function("lambda", rb_f_lambda, 0);
rb_define_global_function("binding", rb_f_binding, 0);