ruby-changes:5561
From: mame <ko1@a...>
Date: Tue, 10 Jun 2008 00:53:08 +0900 (JST)
Subject: [ruby-changes:5561] Ruby:r17065 (trunk): * include/ruby/ruby.h, vm_core.h: add a type rb_blockptr.
mame 2008-06-10 00:52:51 +0900 (Tue, 10 Jun 2008)
New Revision: 17065
Modified files:
trunk/ChangeLog
trunk/eval_jump.c
trunk/include/ruby/intern.h
trunk/include/ruby/ruby.h
trunk/proc.c
trunk/thread.c
trunk/vm.c
trunk/vm_core.h
trunk/vm_insnhelper.c
Log:
* 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.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/ruby.h?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_jump.c?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm_core.h?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm.c?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm_insnhelper.c?r1=17065&r2=17064&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=17065&r2=17064&diff_format=u
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h (revision 17064)
+++ include/ruby/intern.h (revision 17065)
@@ -270,7 +270,7 @@
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);
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h (revision 17064)
+++ include/ruby/ruby.h (revision 17065)
@@ -824,6 +824,8 @@
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);
Index: ChangeLog
===================================================================
--- ChangeLog (revision 17064)
+++ ChangeLog (revision 17065)
@@ -1,3 +1,24 @@
+Tue Jun 10 00:50:51 2008 Yusuke Endoh <mame@t...>
+
+ * 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@f...>
* common.mk (test-knownbug): give $(OPTS) for bootstraptest/runner.rb.
Index: vm_core.h
===================================================================
--- vm_core.h (revision 17064)
+++ vm_core.h (revision 17065)
@@ -345,7 +345,7 @@
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 */
Index: proc.c
===================================================================
--- proc.c (revision 17064)
+++ proc.c (revision 17065)
@@ -490,7 +490,7 @@
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 @@
}
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 @@
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 @@
}
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 @@
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;
}
Index: thread.c
===================================================================
--- thread.c (revision 17064)
+++ thread.c (revision 17065)
@@ -3105,7 +3105,7 @@
eventname, filename, INT2FIX(line),
id ? ID2SYM(id) : Qnil,
p->self ? rb_binding_new() : Qnil,
- klass ? klass : Qnil));
+ klass ? klass : Qnil), 0);
}
static void
Index: eval_jump.c
===================================================================
--- eval_jump.c (revision 17064)
+++ eval_jump.c (revision 17065)
@@ -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);
}
/*
Index: vm.c
===================================================================
--- vm.c (revision 17064)
+++ vm.c (revision 17065)
@@ -448,7 +448,7 @@
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);
}
}
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c (revision 17064)
+++ vm_insnhelper.c (revision 17065)
@@ -651,7 +651,8 @@
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 @@
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 @@
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;
}
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/