summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--insnhelper.ci44
-rw-r--r--proc.c9
3 files changed, 38 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 66b253a7e6..0879053a4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun 26 04:03:50 2007 Koichi Sasada <ko1@atdot.net>
+
+ * insnhelper.ci (vm_yield_with_cfunc), proc.c: fix Method#to_proc
+ to return lamba Proc ([ruby-dev:31021], [ruby-dev:31037]).
+
Tue Jun 26 03:46:08 2007 Koichi Sasada <ko1@atdot.net>
* cont.c (rb_fiber_s_new): fix to clear rb_thread_t#tag.
diff --git a/insnhelper.ci b/insnhelper.ci
index 5c25a0e0bf..eb228b4295 100644
--- a/insnhelper.ci
+++ b/insnhelper.ci
@@ -562,6 +562,20 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
/* yield */
+static inline int
+block_proc_is_lambda(VALUE procval)
+{
+ rb_proc_t *proc;
+
+ if (procval) {
+ GetProcPtr(procval, proc);
+ return proc->is_lambda;
+ }
+ else {
+ return 0;
+ }
+}
+
static inline VALUE
vm_yield_with_cfunc(rb_thread_t *th, rb_block_t *block,
VALUE self, int argc, VALUE *argv)
@@ -569,15 +583,21 @@ vm_yield_with_cfunc(rb_thread_t *th, rb_block_t *block,
NODE *ifunc = (NODE *) block->iseq;
VALUE val;
VALUE arg;
+ int lambda = block_proc_is_lambda(block->proc);
- if (argc == 1) {
- arg = *argv;
- }
- else if (argc > 1) {
+ if (lambda) {
arg = rb_ary_new4(argc, argv);
}
else {
- arg = rb_ary_new();
+ if (argc == 1) {
+ arg = *argv;
+ }
+ else if (argc > 1) {
+ arg = rb_ary_new4(argc, argv);
+ }
+ else {
+ arg = rb_ary_new();
+ }
}
vm_push_frame(th, 0, FRAME_MAGIC_IFUNC,
@@ -970,20 +990,6 @@ vm_search_super_klass(VALUE klass, VALUE recv)
return klass;
}
-static inline int
-block_proc_is_lambda(VALUE procval)
-{
- rb_proc_t *proc;
-
- if (procval) {
- GetProcPtr(procval, proc);
- return proc->is_lambda;
- }
- else {
- return 0;
- }
-}
-
static void
call_yarv_end_proc(VALUE data)
{
diff --git a/proc.c b/proc.c
index 8d6ec0e8cd..59de71dd61 100644
--- a/proc.c
+++ b/proc.c
@@ -1313,9 +1313,16 @@ mproc(VALUE method)
}
static VALUE
+mlambda(VALUE method)
+{
+ return rb_funcall(Qnil, rb_intern("lambda"), 0);
+}
+
+static VALUE
bmcall(VALUE args, VALUE method)
{
volatile VALUE a;
+
if (CLASS_OF(args) != rb_cArray) {
args = rb_ary_new3(1, args);
}
@@ -1356,7 +1363,7 @@ method_proc(VALUE method)
* end
* end
*/
- proc = rb_iterate((VALUE (*)(VALUE))mproc, 0, bmcall, method);
+ proc = rb_iterate((VALUE (*)(VALUE))mlambda, 0, bmcall, method);
return proc;
}