Mercurial > hg > octave-avbm
changeset 3708:9b9efdcbdfd3
[project @ 2000-07-28 20:50:58 by jwe]
author | jwe |
---|---|
date | Fri, 28 Jul 2000 20:53:40 +0000 |
parents | 58140935c812 |
children | c73bea82af94 |
files | src/ChangeLog src/error.cc src/pt-pr-code.cc src/pt-pr-code.h src/pt-stmt.cc |
diffstat | 5 files changed, 47 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2000-07-28 John W. Eaton <jwe@bevo.che.wisc.edu> + * pt-pr-code.h (tree_print_code::curr_print_indent_level, + (tree_print_code::beginning_of_line): No longer static. + (tree_print_code::tree_print_code): Initialize them here. + * pt-pr-code.cc: Not here. + + * pt-stmt.cc (tree_statement::eval): Set curr_statement here. + (tree_statement_list::eval): Not here. + Debug-on-error stuff based on a patch submitted by Paul Kienzle <pkienzle@kienzle.powernet.co.uk> for 2.0.x.
--- a/src/error.cc +++ b/src/error.cc @@ -220,31 +220,43 @@ } static void -pr_where (void) +pr_where (const char *name) { if (curr_statement) { - std::string fcn_name = curr_function->function_name (); - std::string file_name = curr_function->fcn_file_name (); + const char *f_nm = 0; - const char *nm - = file_name.empty () ? fcn_name.c_str () : file_name.c_str (); + if (curr_function) + { + std::string fcn_name = curr_function->function_name (); + std::string file_name = curr_function->fcn_file_name (); + + f_nm = file_name.empty () ? fcn_name.c_str () : file_name.c_str (); + } int l = curr_statement->line (); int c = curr_statement->column (); - pr_where_1 ("error: in %s near line %d, column %d:", nm, l, c); + if (f_nm) + pr_where_1 ("%s: in %s near line %d, column %d:", name, f_nm, l, c); + else + pr_where_1 ("%s: near line %d, column %d:", name, l, c); - // Oops, note that the column number may not be correct - // since the code is being reproduced from the parse tree. + // XXX FIXME XXX -- Note that the column number is probably not + // going to mean much here since the code is being reproduced + // from the parse tree, and we are only showing one statement + // even if there were multiple statements on the original source + // line. std::ostrstream output_buf; - tree_print_code tpc (output_buf, " "); + output_buf << "\n"; + + tree_print_code tpc (output_buf, ">>> "); curr_statement->accept (tpc); - output_buf << ends; + output_buf << "\n" << ends; char *msg = output_buf.str (); @@ -263,14 +275,14 @@ vwarning ("warning", fmt, args); va_end (args); + pr_where ("warning"); + if ((interactive || forced_interactive) && Vdebug_on_warning && curr_function) { unwind_protect_bool (Vdebug_on_warning); Vdebug_on_warning = false; - pr_where (); - do_keyboard (octave_value_list ()); unwind_protect::run (); @@ -293,7 +305,7 @@ unwind_protect_bool (Vdebug_on_error); Vdebug_on_error = false; - pr_where (); + pr_where ("error"); error_state = 0;
--- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -1218,12 +1218,6 @@ newline (); } -// Current indentation. -int tree_print_code::curr_print_indent_level = 0; - -// TRUE means we are at the beginning of a line. -bool tree_print_code::beginning_of_line = true; - // Each print_code() function should call this before printing // anything. //
--- a/src/pt-pr-code.h +++ b/src/pt-pr-code.h @@ -41,9 +41,11 @@ { public: - tree_print_code (std::ostream& os_arg, const std::string& pfx = std::string (), + tree_print_code (std::ostream& os_arg, + const std::string& pfx = std::string (), bool pr_orig_txt = true) - : os (os_arg), prefix (pfx), print_original_text (pr_orig_txt) { } + : os (os_arg), prefix (pfx), print_original_text (pr_orig_txt), + curr_print_indent_level (0), beginning_of_line (true) { } ~tree_print_code (void) { } @@ -149,8 +151,11 @@ bool print_original_text; - static int curr_print_indent_level; - static bool beginning_of_line; + // Current indentation. + int curr_print_indent_level; + + // TRUE means we are at the beginning of a line. + bool beginning_of_line; void reset_indent_level (void) { curr_print_indent_level = 0; }
--- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -96,6 +96,9 @@ if (cmd || expr) { + unwind_protect_ptr (curr_statement); + curr_statement = this; + maybe_echo_code (in_function_body); if (cmd) @@ -130,6 +133,8 @@ if (do_bind_ans && ! (error_state || retval.empty ())) bind_ans (retval(0), pf); } + + unwind_protect::run (); } return retval; @@ -158,13 +163,8 @@ bool silent_flag = silent ? true : (function_body ? Vsilent_functions : false); - unwind_protect_ptr (curr_statement); - curr_statement = elt; - retval = elt->eval (silent_flag, nargout, function_body); - unwind_protect::run (); - if (error_state) break;