1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm.c (vm_exec): support :b_return event for "lambda{return}.call".

[Bug #8622]
* test/ruby/test_settracefunc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-10-10 08:31:48 +00:00
parent d63f9e933c
commit 4599d3efd7
3 changed files with 40 additions and 0 deletions

View file

@ -1,3 +1,10 @@
Thu Oct 10 17:25:28 2013 Koichi Sasada <ko1@atdot.net>
* vm.c (vm_exec): support :b_return event for "lambda{return}.call".
[Bug #8622]
* test/ruby/test_settracefunc.rb: add a test.
Thu Oct 10 13:52:37 2013 Koichi Sasada <ko1@atdot.net>
* vm_trace.c (postponed_job): use preallocated buffer.

View file

@ -966,4 +966,29 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal 4, n
end
def test_tracepoint_b_return_with_lambda
n = 0
TracePoint.new(:b_return){
n+=1
}.enable{
lambda{
return
}.call # n += 1 #=> 1
3.times{
lambda{
return # n += 3 #=> 4
}.call
} # n += 3 #=> 7
begin
lambda{
raise
}.call # n += 1 #=> 8
rescue
# ignore
end # n += 1 #=> 9
}
assert_equal 9, n
end
end

8
vm.c
View file

@ -1290,6 +1290,13 @@ vm_exec(rb_thread_t *th)
if (!catch_iseqval) {
result = GET_THROWOBJ_VAL(err);
th->errinfo = Qnil;
switch (VM_FRAME_TYPE(cfp)) {
case VM_FRAME_MAGIC_LAMBDA:
EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
break;
}
vm_pop_frame(th);
goto finish_vme;
}
@ -1435,6 +1442,7 @@ vm_exec(rb_thread_t *th)
EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil);
break;
case VM_FRAME_MAGIC_BLOCK:
case VM_FRAME_MAGIC_LAMBDA:
EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
break;
case VM_FRAME_MAGIC_CLASS: