summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--eval_jump.c2
-rw-r--r--include/ruby/intern.h2
-rw-r--r--include/ruby/ruby.h2
-rw-r--r--proc.c15
-rw-r--r--thread.c2
-rw-r--r--vm.c2
-rw-r--r--vm_core.h2
-rw-r--r--vm_insnhelper.c7
9 files changed, 41 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 4683a779cf..4575e4b0c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+Tue Jun 10 00:50:51 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * include/ruby/ruby.h, vm_core.h: add a type rb_blockptr.
+
+ * vm_insnhelper.c (vm_yield_with_cfunc): vm_yield_with_cfunc receives
+ blockptr and passes it to iterating block.
+
+ * proc.c (rb_proc_call), include/ruby/intern.h: rb_proc_call receives
+ blockptr. "rb_proc_call(self, args, blockptr)" in C corresponds to
+ "self.call(*args, &block)" in Ruby.
+
+ * proc.c (proc_call): pass blockptr to block that is written in C.
+
+ * proc.c (curry): receive blockptr and pass it to original proc.
+ [ruby-core:15551]
+
+ * vm.c (invoke_block_from_c): fix for change of vm_yield_with_cfunc.
+
+ * thread.c (call_trace_proc), eval_jump.c (rb_call_end_proc): fix for
+ change of rb_proc_call.
+
Tue Jun 10 00:10:49 2008 Tanaka Akira <akr@fsij.org>
* common.mk (test-knownbug): give $(OPTS) for bootstraptest/runner.rb.
diff --git a/eval_jump.c b/eval_jump.c
index f474844ba8..7d394f431d 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -10,7 +10,7 @@
void
rb_call_end_proc(VALUE data)
{
- rb_proc_call(data, rb_ary_new());
+ rb_proc_call(data, rb_ary_new(), 0);
}
/*
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 5c5cfd1b86..bbaa5acaa3 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -270,7 +270,7 @@ VALUE rb_class_new_instance(int, VALUE*, VALUE);
VALUE rb_block_proc(void);
VALUE rb_f_lambda(void);
VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
-VALUE rb_proc_call(VALUE, VALUE);
+VALUE rb_proc_call(VALUE, VALUE, rb_blockptr);
int rb_proc_arity(VALUE);
VALUE rb_binding_new(void);
VALUE rb_obj_method(VALUE, VALUE);
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 99321f1933..d51718023d 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -824,6 +824,8 @@ PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
+typedef struct rb_block_struct *rb_blockptr;
+
typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);
VALUE rb_each(VALUE);
diff --git a/proc.c b/proc.c
index 864e8df6ad..5446c82815 100644
--- a/proc.c
+++ b/proc.c
@@ -490,7 +490,7 @@ proc_call(int argc, VALUE *argv, VALUE procval)
rb_block_t *blockptr = 0;
GetProcPtr(procval, proc);
- if (BUILTIN_TYPE(proc->block.iseq) != T_NODE &&
+ if (BUILTIN_TYPE(proc->block.iseq) == T_NODE ||
proc->block.iseq->arg_block != -1) {
if (rb_block_given_p()) {
@@ -507,12 +507,12 @@ proc_call(int argc, VALUE *argv, VALUE procval)
}
VALUE
-rb_proc_call(VALUE self, VALUE args)
+rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr)
{
rb_proc_t *proc;
GetProcPtr(self, proc);
return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
- RARRAY_LEN(args), RARRAY_PTR(args), 0);
+ RARRAY_LEN(args), RARRAY_PTR(args), blockptr);
}
/*
@@ -1584,7 +1584,7 @@ proc_binding(VALUE self)
return bindval;
}
-static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv);
+static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr);
static VALUE
make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
@@ -1600,7 +1600,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
}
static VALUE
-curry(VALUE dummy, VALUE args, int argc, VALUE *argv)
+curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
{
VALUE proc, passed, arity;
proc = RARRAY_PTR(args)[0];
@@ -1610,10 +1610,13 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv)
passed = rb_ary_plus(passed, rb_ary_new4(argc, argv));
rb_ary_freeze(passed);
if(RARRAY_LEN(passed) < FIX2INT(arity)) {
+ if (blockptr) {
+ rb_warn("given block not used");
+ }
arity = make_curry_proc(proc, passed, arity);
return arity;
}
- arity = rb_proc_call(proc, passed);
+ arity = rb_proc_call(proc, passed, blockptr);
return arity;
}
diff --git a/thread.c b/thread.c
index 522c786c45..cd492df847 100644
--- a/thread.c
+++ b/thread.c
@@ -3105,7 +3105,7 @@ call_trace_proc(VALUE args, int tracing)
eventname, filename, INT2FIX(line),
id ? ID2SYM(id) : Qnil,
p->self ? rb_binding_new() : Qnil,
- klass ? klass : Qnil));
+ klass ? klass : Qnil), 0);
}
static void
diff --git a/vm.c b/vm.c
index 5ac1e6771b..545bf3a52b 100644
--- a/vm.c
+++ b/vm.c
@@ -448,7 +448,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
return vm_eval_body(th);
}
else {
- return vm_yield_with_cfunc(th, block, self, argc, argv);
+ return vm_yield_with_cfunc(th, block, self, argc, argv, blockptr);
}
}
diff --git a/vm_core.h b/vm_core.h
index 8d3ca8ab20..4e62bb5d8f 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -345,7 +345,7 @@ typedef struct {
VALUE prof_time_chld; /* cfp[13] */
} rb_control_frame_t;
-typedef struct {
+typedef struct rb_block_struct {
VALUE self; /* share with method frame if it's only block */
VALUE *lfp; /* share with method frame if it's only block */
VALUE *dfp; /* share with method frame if it's only block */
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 2b32a3c94a..b7dbbd2fe4 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -651,7 +651,8 @@ block_proc_is_lambda(const VALUE procval)
static inline VALUE
vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
- VALUE self, int argc, const VALUE *argv)
+ VALUE self, int argc, const VALUE *argv,
+ const rb_block_t *blockptr)
{
NODE *ifunc = (NODE *) block->iseq;
VALUE val;
@@ -672,7 +673,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
self, (VALUE)block->dfp,
0, th->cfp->sp, block->lfp, 1);
- val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv);
+ val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockptr);
th->cfp++;
return val;
@@ -831,7 +832,7 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t num, rb_n
return Qundef;
}
else {
- VALUE val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc));
+ VALUE val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc), 0);
POPN(argc); /* TODO: should put before C/yield? */
return val;
}