ruby-changes:18002
From: yugui <ko1@a...>
Date: Thu, 2 Dec 2010 17:05:42 +0900 (JST)
Subject: [ruby-changes:18002] Ruby:r30023 (ruby_1_9_2): merges r29335 from trunk into ruby_1_9_2.
yugui 2010-12-02 17:05:24 +0900 (Thu, 02 Dec 2010) New Revision: 30023 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30023 Log: merges r29335 from trunk into ruby_1_9_2. -- * string.c (sym_call), vm.c (invoke_block_from_c), vm_insnhelper.c (vm_yield_with_cfunc): pass given block. [ruby-core:32075] * vm_eval.c (rb_funcall_passing_block): new function to call method with passing given block. Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/string.c branches/ruby_1_9_2/test/ruby/test_proc.rb branches/ruby_1_9_2/version.h branches/ruby_1_9_2/vm.c branches/ruby_1_9_2/vm_eval.c branches/ruby_1_9_2/vm_insnhelper.c Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 30022) +++ ruby_1_9_2/ChangeLog (revision 30023) @@ -1,3 +1,12 @@ +Fri Sep 24 23:44:59 2010 Nobuyoshi Nakada <nobu@r...> + + * string.c (sym_call), vm.c (invoke_block_from_c), + vm_insnhelper.c (vm_yield_with_cfunc): pass given block. + [ruby-core:32075] + + * vm_eval.c (rb_funcall_passing_block): new function to call + method with passing given block. + Fri Sep 24 15:50:43 2010 NARUSE, Yui <naruse@r...> * string.c (rb_str_to_i): fix rdoc: String#to_i raises an Index: ruby_1_9_2/string.c =================================================================== --- ruby_1_9_2/string.c (revision 30022) +++ ruby_1_9_2/string.c (revision 30023) @@ -7171,6 +7171,8 @@ return sym; } +VALUE rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE *argv); + static VALUE sym_call(VALUE args, VALUE sym, int argc, VALUE *argv) { @@ -7180,7 +7182,7 @@ rb_raise(rb_eArgError, "no receiver given"); } obj = argv[0]; - return rb_funcall3(obj, (ID)sym, argc - 1, argv + 1); + return rb_funcall_passing_block(obj, (ID)sym, argc - 1, argv + 1); } /* Index: ruby_1_9_2/vm_eval.c =================================================================== --- ruby_1_9_2/vm_eval.c (revision 30022) +++ ruby_1_9_2/vm_eval.c (revision 30023) @@ -665,6 +665,14 @@ return rb_call(recv, mid, argc, argv, CALL_PUBLIC); } +VALUE +rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE *argv) +{ + PASS_PASSED_BLOCK_TH(GET_THREAD()); + + return rb_call(recv, mid, argc, argv, CALL_PUBLIC); +} + static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope) { Index: ruby_1_9_2/vm.c =================================================================== --- ruby_1_9_2/vm.c (revision 30022) +++ ruby_1_9_2/vm.c (revision 30023) @@ -549,6 +549,7 @@ iseq->local_size - arg_size); ncfp->me = th->passed_me; th->passed_me = 0; + th->passed_block = blockptr; if (cref) { th->cfp->dfp[-1] = (VALUE)cref; Index: ruby_1_9_2/version.h =================================================================== --- ruby_1_9_2/version.h (revision 30022) +++ ruby_1_9_2/version.h (revision 30023) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 53 +#define RUBY_PATCHLEVEL 54 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_2/vm_insnhelper.c =================================================================== --- ruby_1_9_2/vm_insnhelper.c (revision 30022) +++ ruby_1_9_2/vm_insnhelper.c (revision 30023) @@ -722,6 +722,9 @@ self, (VALUE)block->dfp, 0, th->cfp->sp, block->lfp, 1); + if (blockargptr) { + th->cfp->lfp[0] = GC_GUARDED_PTR((VALUE)blockargptr); + } val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg); th->cfp++; Index: ruby_1_9_2/test/ruby/test_proc.rb =================================================================== --- ruby_1_9_2/test/ruby/test_proc.rb (revision 30022) +++ ruby_1_9_2/test/ruby/test_proc.rb (revision 30023) @@ -792,4 +792,22 @@ assert_equal([obj, nil], [a, b], '[ruby-core:24139]') end end + + def test_block_propagation + bug3792 = '[ruby-core:32075]' + c = Class.new do + def foo + yield + end + end + + o = c.new + f = :foo.to_proc + assert_nothing_raised(LocalJumpError, bug3792) { + assert_equal('bar', f.(o) {'bar'}, bug3792) + } + assert_nothing_raised(LocalJumpError, bug3792) { + assert_equal('zot', o.method(:foo).to_proc.() {'zot'}, bug3792) + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/