* insnhelper.ci (vm_yield_setup_args), vm.c, insns.def:

fix to pass nil as block parameter to yielded block.
  [ruby-dev:31147]
* bootstraptest/test_block.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-07-07 06:34:40 +00:00
Родитель 7756f1df18
Коммит 0afe6cb08f
6 изменённых файлов: 41 добавлений и 22 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Sat Jul 7 15:30:05 2007 Koichi Sasada <ko1@atdot.net>
* insnhelper.ci (vm_yield_setup_args), vm.c, insns.def:
fix to pass nil as block parameter to yielded block.
[ruby-dev:31147]
* bootstraptest/test_block.rb: add a test for above.
Fri Jul 6 19:55:10 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/irb.rb: typo. Thanks, Giles Bowkett.

Просмотреть файл

@ -335,3 +335,11 @@ assert_equal %q{[1, nil]}, %q{
[i, j]
}
}
# [ruby-dev:31147]
assert_equal 'nil', %q{
def m
yield
end
m{|&b| b}.inspect
}

Просмотреть файл

@ -605,7 +605,7 @@ vm_yield_with_cfunc(rb_thread_t *th, rb_block_t *block,
static inline int
vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
int argc, VALUE *argv, int lambda)
int argc, VALUE *argv, rb_block_t *blockptr, int lambda)
{
if (0) { /* for debug */
printf(" argc: %d\n", argc);
@ -620,20 +620,8 @@ vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
if (lambda) {
/* call as method */
if (iseq->arg_block != -1) {
volatile VALUE procval = Qnil;
if (rb_block_given_p()) {
rb_block_t *blockptr;
rb_proc_t *proc;
procval = rb_block_proc();
GetProcPtr(procval, proc);
blockptr = &proc->block;
return vm_callee_setup_arg(th, iseq, argc, argv, &blockptr);
}
}
return vm_callee_setup_arg(th, iseq, argc, argv, 0);
}
else {
int i;
const int m = iseq->argc;
@ -721,13 +709,13 @@ vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
/* {|&b|} */
if (iseq->arg_block != -1) {
VALUE proc = Qnil;
VALUE procval = Qnil;
if (rb_block_given_p()) {
proc = rb_block_proc();
if (blockptr) {
procval = blockptr->proc;
}
argv[iseq->arg_block] = proc;
argv[iseq->arg_block] = procval;
th->mark_stack_len = iseq->arg_block + 1;
}

Просмотреть файл

@ -1268,7 +1268,7 @@ invokeblock
CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max);
DEC_SP(argc);
opt_pc = vm_yield_setup_args(th, iseq, argc, GET_SP(),
opt_pc = vm_yield_setup_args(th, iseq, argc, GET_SP(), 0,
block_proc_is_lambda(block->proc));
argc = iseq->arg_size;
INC_SP(argc);

Просмотреть файл

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-07-06"
#define RUBY_RELEASE_DATE "2007-07-07"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070706
#define RUBY_RELEASE_CODE 20070707
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 7
#define RUBY_RELEASE_DAY 6
#define RUBY_RELEASE_DAY 7
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];

17
vm.c
Просмотреть файл

@ -559,7 +559,22 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
th->cfp->sp[i] = argv[i];
}
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp, type == FRAME_MAGIC_LAMBDA);
if (iseq->arg_block == -1) {
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp, 0,
type == FRAME_MAGIC_LAMBDA);
}
else {
rb_block_t *blockptr = 0;
if (rb_block_given_p()) {
rb_proc_t *proc;
VALUE procval;
procval = rb_block_proc();
GetProcPtr(procval, proc);
blockptr = &proc->block;
}
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp,
blockptr, type == FRAME_MAGIC_LAMBDA);
}
argc = iseq->arg_size;
th->cfp->sp += argc;