diff options
author | fche <fche> | 2005-06-05 16:35:28 +0000 |
---|---|---|
committer | fche <fche> | 2005-06-05 16:35:28 +0000 |
commit | f3c26ea55e2f2c1d222312bf75035359c439ed21 (patch) | |
tree | 1a58dfcdebe04941002e7e0203f765b619ca9c67 /staptree.cxx | |
parent | 8846477c222cdae649b02117cc96999b0be6ad40 (diff) | |
download | systemtap-steved-f3c26ea55e2f2c1d222312bf75035359c439ed21.tar.gz systemtap-steved-f3c26ea55e2f2c1d222312bf75035359c439ed21.tar.xz systemtap-steved-f3c26ea55e2f2c1d222312bf75035359c439ed21.zip |
2005-06-05 Frank Ch. Eigler <fche@elastic.org>
Implement for/next/continue/break/while statements.
* staptree.h: Declare new 0-arity statement types. Tweak for_loop.
* parse.cxx: Parse them all.
* translate.cxx (c_unparser): Maintain break/continue label stack.
(visit_for_loop, *_statement): New implementations.
* elaborate.*, staptree.cxx: Mechanical changes.
* testsuite/parseok/ten.stp, semko/twelve.stp, transko/two.stp,
transok/five.stp: New tests.
Diffstat (limited to 'staptree.cxx')
-rw-r--r-- | staptree.cxx | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/staptree.cxx b/staptree.cxx index 756fbc1e..3ee34950 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -161,6 +161,7 @@ void literal_string::print (ostream& o) o << '"' << value << '"'; } + void literal_number::print (ostream& o) { o << value; @@ -290,7 +291,14 @@ void block::print (ostream& o) void for_loop::print (ostream& o) { - o << "<for_loop>" << endl; + o << "for ("; + init->print (o); + o << "; "; + cond->print (o); + o << "; "; + incr->print (o); + o << ")" << endl; + block->print (o); } @@ -330,6 +338,20 @@ void delete_statement::print (ostream& o) o << "delete " << *value; } +void next_statement::print (ostream& o) +{ + o << "next"; +} + +void break_statement::print (ostream& o) +{ + o << "break"; +} + +void continue_statement::print (ostream& o) +{ + o << "continue"; +} void if_statement::print (ostream& o) { @@ -464,6 +486,24 @@ if_statement::visit (visitor* u) } void +next_statement::visit (visitor* u) +{ + u->visit_next_statement (this); +} + +void +break_statement::visit (visitor* u) +{ + u->visit_break_statement (this); +} + +void +continue_statement::visit (visitor* u) +{ + u->visit_continue_statement (this); +} + +void literal_string::visit(visitor* u) { u->visit_literal_string (this); @@ -625,6 +665,21 @@ traversing_visitor::visit_delete_statement (delete_statement* s) } void +traversing_visitor::visit_next_statement (next_statement* s) +{ +} + +void +traversing_visitor::visit_break_statement (break_statement* s) +{ +} + +void +traversing_visitor::visit_continue_statement (continue_statement* s) +{ +} + +void traversing_visitor::visit_literal_string (literal_string* e) { } @@ -798,6 +853,24 @@ throwing_visitor::visit_delete_statement (delete_statement* s) } void +throwing_visitor::visit_next_statement (next_statement* s) +{ + throwone (s->tok); +} + +void +throwing_visitor::visit_break_statement (break_statement* s) +{ + throwone (s->tok); +} + +void +throwing_visitor::visit_continue_statement (continue_statement* s) +{ + throwone (s->tok); +} + +void throwing_visitor::visit_literal_string (literal_string* e) { throwone (e->tok); |