diff src/pt-eval.cc @ 10188:97ae300aa73a

improve implementation of break, continue, and return commands
author John W. Eaton <jwe@octave.org>
date Fri, 22 Jan 2010 14:37:33 -0500
parents 095a1e670e68
children d4f813c3f5ed
line wrap: on
line diff
--- a/src/pt-eval.cc	Fri Jan 22 12:12:21 2010 -0500
+++ b/src/pt-eval.cc	Fri Jan 22 14:37:33 2010 -0500
@@ -90,7 +90,9 @@
       if (debug_mode)
 	do_breakpoint (cmd.is_breakpoint ());
 
-      tree_break_command::breaking = 1;
+      if (tree_evaluator::in_fcn_or_script_body
+          || tree_evaluator::in_loop_command)
+        tree_break_command::breaking = 1;
     }
 }
 
@@ -101,10 +103,17 @@
 }
 
 void
-tree_evaluator::visit_continue_command (tree_continue_command&)
+tree_evaluator::visit_continue_command (tree_continue_command& cmd)
 {
   if (! error_state)
-    tree_continue_command::continuing = 1;
+    {
+      if (debug_mode)
+	do_breakpoint (cmd.is_breakpoint ());
+
+      if (tree_evaluator::in_fcn_or_script_body
+          || tree_evaluator::in_loop_command)
+        tree_continue_command::continuing = 1;
+    }
 }
 
 void
@@ -631,7 +640,18 @@
       if (debug_mode)
 	do_breakpoint (cmd.is_breakpoint ());
 
-      tree_return_command::returning = 1;
+      // Act like dbcont.
+
+      if (Vdebugging
+          && octave_call_stack::current_frame () == current_frame)
+        {
+          Vdebugging = false;
+
+          reset_debug_state;
+        }
+      else if (tree_evaluator::in_fcn_or_script_body
+               || tree_evaluator::in_loop_command)
+        tree_return_command::returning = 1;
     }
 }