mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3b6e807a01
commit
2f3fa385db
5 changed files with 104 additions and 1 deletions
15
ChangeLog
15
ChangeLog
|
|
@ -1,3 +1,18 @@
|
|||
Thu Aug 20 23:39:51 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* 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@tsg.ne.jp>
|
||||
|
||||
* 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@tsg.ne.jp>
|
||||
|
||||
* compile.c (NODE_RETURN): fire return event at explicit return.
|
||||
[ruby-dev:38701]
|
||||
|
||||
Tue Aug 18 11:37:24 2009 wanabe <s.wanabe@gmail.com>
|
||||
|
||||
* vm_insnhelper.c (vm_call_cfunc): ensure hook c-return.
|
||||
|
|
|
|||
|
|
@ -4212,6 +4212,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
|||
4
parse.y
4
parse.y
|
|
@ -8459,6 +8459,7 @@ reduce_nodes_gen(struct parser_params *parser, NODE **body)
|
|||
(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 @@ reduce_nodes_gen(struct parser_params *parser, NODE **body)
|
|||
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 @@ reduce_nodes_gen(struct parser_params *parser, NODE **body)
|
|||
return;
|
||||
}
|
||||
node = *body;
|
||||
if (newline && node) node->flags |= NODE_FL_NEWLINE;
|
||||
}
|
||||
|
||||
#undef subnodes
|
||||
|
|
|
|||
|
|
@ -129,6 +129,89 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
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(/^.*?: /, "")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue