Mercurial > octave
changeset 8844:c84a5b6377c4
better handling of end of script/function no-op command
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 23 Feb 2009 12:55:32 -0500 |
parents | b9ce57a309a3 |
children | 5a6db6bd1a02 |
files | src/ChangeLog src/pt-cmd.h src/pt-stmt.cc |
diffstat | 3 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Feb 23 12:44:57 2009 -0500 +++ b/src/ChangeLog Mon Feb 23 12:55:32 2009 -0500 @@ -1,5 +1,12 @@ 2009-02-23 John W. Eaton <jwe@octave.org> + * pt-cmd.h (tree_no_op_command::eof): New data member + (tree_no_op_command::tree_no_op_command): Initialize it. + (tree_no_op_command::is_end_of_fcn_or_script): New function. + * pt-stmt.cc (tree_statement::is_end_of_fcn_or_script): + Call is_end_of_fcn_or_script instead of looking at original text + of no-op command. + * pt-select.h, pt-select.cc (tree_if_command::set_breakpoint, tree_if_command::delete_breakpoint): New functions. (tree_switch_command::set_breakpoint,
--- a/src/pt-cmd.h Mon Feb 23 12:44:57 2009 -0500 +++ b/src/pt-cmd.h Mon Feb 23 12:55:32 2009 -0500 @@ -65,7 +65,8 @@ public: tree_no_op_command (const std::string& cmd = "no_op", int l = -1, int c = -1) - : tree_command (l, c), orig_cmd (cmd) { } + : tree_command (l, c), eof (cmd == "endfunction" || cmd == "endscript"), + orig_cmd (cmd) { } ~tree_no_op_command (void) { } @@ -74,10 +75,14 @@ void accept (tree_walker& tw); + bool is_end_of_fcn_or_script (void) const { return eof; } + std::string original_command (void) { return orig_cmd; } private: + bool eof; + std::string orig_cmd; // No copying!
--- a/src/pt-stmt.cc Mon Feb 23 12:44:57 2009 -0500 +++ b/src/pt-stmt.cc Mon Feb 23 12:55:32 2009 -0500 @@ -125,11 +125,7 @@ = dynamic_cast<tree_no_op_command *> (cmd); if (no_op_cmd) - { - std::string type = no_op_cmd->original_command (); - - retval = (type == "endfunction" || type == "endscript"); - } + retval = no_op_cmd->is_end_of_fcn_or_script (); } return retval;