ruby-changes:13744
From: yugui <ko1@a...>
Date: Wed, 28 Oct 2009 23:15:45 +0900 (JST)
Subject: [ruby-changes:13744] Ruby:r25537 (ruby_1_9_1): merges r24579 and r24581 from trunk into ruby_1_9_1.
yugui 2009-10-28 23:15:24 +0900 (Wed, 28 Oct 2009) New Revision: 25537 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25537 Log: merges r24579 and r24581 from trunk into ruby_1_9_1. -- * compile.c (NODE_RETURN): fire return event at explicit return. [ruby-dev:38701] -- * test/ruby/test_settracefunc.rb (test_return, test_return2): add two tests for [ruby-dev:38701] and [ruby-core:24463]. -- * parse.y (reduce_nodes_gen): preserve NODE_FL_NEWLINE flag during node reducing. [ruby-core:24463] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/compile.c branches/ruby_1_9_1/parse.y branches/ruby_1_9_1/test/ruby/test_settracefunc.rb branches/ruby_1_9_1/version.h Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 25536) +++ ruby_1_9_1/ChangeLog (revision 25537) @@ -1,3 +1,18 @@ +Thu Aug 20 23:39:51 2009 Yusuke Endoh <mame@t...> + + * parse.y (reduce_nodes_gen): preserve NODE_FL_NEWLINE flag during + node reducing. [ruby-core:24463] + +Wed Aug 19 02:54:01 2009 Yusuke Endoh <mame@t...> + + * test/ruby/test_settracefunc.rb (test_return, test_return2): add two + tests for [ruby-dev:38701] and [ruby-core:24463]. + +Wed Aug 19 01:08:34 2009 Yusuke Endoh <mame@t...> + + * compile.c (NODE_RETURN): fire return event at explicit return. + [ruby-dev:38701] + Tue Aug 18 11:37:24 2009 wanabe <s.wanabe@g...> * vm_insnhelper.c (vm_call_cfunc): ensure hook c-return. Index: ruby_1_9_1/compile.c =================================================================== --- ruby_1_9_1/compile.c (revision 25536) +++ ruby_1_9_1/compile.c (revision 25537) @@ -4212,6 +4212,7 @@ if (is->type == ISEQ_TYPE_METHOD) { add_ensure_iseq(ret, iseq, 1); + ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN); ADD_INSN(ret, nd_line(node), leave); ADD_ADJUST_RESTORE(ret, splabel); Index: ruby_1_9_1/parse.y =================================================================== --- ruby_1_9_1/parse.y (revision 25536) +++ ruby_1_9_1/parse.y (revision 25537) @@ -8459,6 +8459,7 @@ (reduce_nodes(&node->n1), body = &node->n2, 1)) while (node) { + int newline = node->flags & NODE_FL_NEWLINE; switch (nd_type(node)) { end: case NODE_NIL: @@ -8466,9 +8467,11 @@ return; case NODE_RETURN: *body = node = node->nd_stts; + if (newline && node) node->flags |= NODE_FL_NEWLINE; continue; case NODE_BEGIN: *body = node = node->nd_body; + if (newline && node) node->flags |= NODE_FL_NEWLINE; continue; case NODE_BLOCK: body = &node->nd_end->nd_head; @@ -8492,6 +8495,7 @@ return; } node = *body; + if (newline && node) node->flags |= NODE_FL_NEWLINE; } #undef subnodes Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 25536) +++ ruby_1_9_1/version.h (revision 25537) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 296 +#define RUBY_PATCHLEVEL 297 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 Index: ruby_1_9_1/test/ruby/test_settracefunc.rb =================================================================== --- ruby_1_9_1/test/ruby/test_settracefunc.rb (revision 25536) +++ ruby_1_9_1/test/ruby/test_settracefunc.rb (revision 25537) @@ -129,6 +129,89 @@ assert_equal([], events) end + def test_return # [ruby-dev:38701] + events = [] + eval <<-EOF.gsub(/^.*?: /, "") + 1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass| + 2: events << [event, lineno, mid, klass] + 3: }) + 4: def foo(a) + 5: return if a + 6: return + 7: end + 8: foo(true) + 9: foo(false) + 10: set_trace_func(nil) + EOF + assert_equal(["c-return", 3, :set_trace_func, Kernel], + events.shift) + assert_equal(["line", 4, __method__, self.class], + events.shift) + assert_equal(["c-call", 4, :method_added, Module], + events.shift) + assert_equal(["c-return", 4, :method_added, Module], + events.shift) + assert_equal(["line", 8, __method__, self.class], + events.shift) + assert_equal(["call", 4, :foo, self.class], + events.shift) + assert_equal(["line", 5, :foo, self.class], + events.shift) + assert_equal(["return", 5, :foo, self.class], + events.shift) + assert_equal(["line", 9, :test_return, self.class], + events.shift) + assert_equal(["call", 4, :foo, self.class], + events.shift) + assert_equal(["line", 5, :foo, self.class], + events.shift) + assert_equal(["return", 7, :foo, self.class], + events.shift) + assert_equal(["line", 10, :test_return, self.class], + events.shift) + assert_equal(["c-call", 10, :set_trace_func, Kernel], + events.shift) + assert_equal([], events) + end + + def test_return2 # [ruby-core:24463] + events = [] + eval <<-EOF.gsub(/^.*?: /, "") + 1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass| + 2: events << [event, lineno, mid, klass] + 3: }) + 4: def foo + 5: a = 5 + 6: return a + 7: end + 8: foo + 9: set_trace_func(nil) + EOF + assert_equal(["c-return", 3, :set_trace_func, Kernel], + events.shift) + assert_equal(["line", 4, __method__, self.class], + events.shift) + assert_equal(["c-call", 4, :method_added, Module], + events.shift) + assert_equal(["c-return", 4, :method_added, Module], + events.shift) + assert_equal(["line", 8, __method__, self.class], + events.shift) + assert_equal(["call", 4, :foo, self.class], + events.shift) + assert_equal(["line", 5, :foo, self.class], + events.shift) + assert_equal(["line", 6, :foo, self.class], + events.shift) + assert_equal(["return", 7, :foo, self.class], + events.shift) + assert_equal(["line", 9, :test_return2, self.class], + events.shift) + assert_equal(["c-call", 9, :set_trace_func, Kernel], + events.shift) + assert_equal([], events) + end + def test_raise events = [] eval <<-EOF.gsub(/^.*?: /, "") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/