diff src/pt-eval.cc @ 8669:33783e94fb16

line number fixes and other evaluator tweaks
author John W. Eaton <jwe@octave.org>
date Wed, 04 Feb 2009 13:28:06 -0500
parents af72c8137d64
children 095ae5e0a831
line wrap: on
line diff
--- a/src/pt-eval.cc
+++ b/src/pt-eval.cc
@@ -53,6 +53,10 @@
 
 bool tree_evaluator::debug_mode = false;
 
+bool tree_evaluator::in_fcn_or_script_body = false;
+
+bool tree_evaluator::in_loop_command = false;
+
 int tree_evaluator::db_line = -1;
 int tree_evaluator::db_column = -1;
 
@@ -266,9 +270,9 @@
 
   unwind_protect::begin_frame ("tree_evaluator::visit_simple_for_command");
 
-  unwind_protect_bool (evaluating_looping_command);
+  unwind_protect_bool (in_loop_command);
 
-  evaluating_looping_command = true;
+  in_loop_command = true;
 
   tree_expression *expr = cmd.control_expr ();
 
@@ -395,9 +399,9 @@
 
   unwind_protect::begin_frame ("tree_evaluator::visit_complex_for_command");
 
-  unwind_protect_bool (evaluating_looping_command);
+  unwind_protect_bool (in_loop_command);
 
-  evaluating_looping_command = true;
+  in_loop_command = true;
 
   tree_expression *expr = cmd.control_expr ();
 
@@ -638,10 +642,13 @@
 
   if (cmd || expr)
     {
-      if (in_function_or_script_body)
-	octave_call_stack::set_statement (&stmt);
+      if (in_fcn_or_script_body)
+	{
+	  octave_call_stack::set_statement (&stmt);
 
-      stmt.maybe_echo_code (in_function_or_script_body);
+	  if (Vecho_executing_commands & ECHO_FUNCTIONS)
+	    stmt.echo_code ();
+	}
 
       try
 	{
@@ -649,7 +656,7 @@
 	    cmd->accept (*this);
 	  else
 	    {
-	      if (in_function_or_script_body && Vsilent_functions)
+	      if (in_fcn_or_script_body && Vsilent_functions)
 		expr->set_print_flag (false);
 
 	      // FIXME -- maybe all of this should be packaged in
@@ -708,9 +715,6 @@
 	    {
 	      OCTAVE_QUIT;
 
-	      in_function_or_script_body
-		= lst.is_function_body () || lst.is_script_body ();
-
 	      elt->accept (*this);
 
 	      if (error_state)
@@ -986,9 +990,9 @@
 
   unwind_protect::begin_frame ("tree_evaluator::visit_while_command");
 
-  unwind_protect_bool (evaluating_looping_command);
+  unwind_protect_bool (in_loop_command);
 
-  evaluating_looping_command = true;
+  in_loop_command = true;
 
   tree_expression *expr = cmd.condition ();
 
@@ -1034,9 +1038,9 @@
 
   unwind_protect::begin_frame ("tree_evaluator::visit_do_until_command");
 
-  unwind_protect_bool (evaluating_looping_command);
+  unwind_protect_bool (in_loop_command);
 
-  evaluating_looping_command = true;
+  in_loop_command = true;
 
   tree_expression *expr = cmd.condition ();