# HG changeset patch # User John W. Eaton # Date 1264189053 18000 # Node ID 97ae300aa73a7b59900867812500199855fec0bc # Parent a44d15813a39c4ff94b79ffbfd135ccf4e08a8fd improve implementation of break, continue, and return commands diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2010-01-22 John W. Eaton + + * oct-parse.yy (make_break_command, make_continue_command, + make_return_command): Don't examine evaluator state here. + * pt-eval.cc (tree_evaluator::visit_break_command): Don't set + tree_break_command::breaking unless inside function or script + body, or inside a looping command. + (tree_evaluator::visit_continue_command): Likewise, for + tree_continue_command::continuing. + (tree_evaluator::visit_return_command): Likewise, for + tree_return_command::returning. Act like dbcont if debugging + and in the top-level debugging stack frame. + 2010-01-22 John W. Eaton * oct-stream.cc (octave_base_stream::do_scanf): Don't skip diff --git a/src/oct-parse.yy b/src/oct-parse.yy --- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -2488,16 +2488,7 @@ int l = break_tok->line (); int c = break_tok->column (); - // We check to see if we are evaluating a function, script, or loop - // so that we don't turn eval ("break;") inside a function, script, - // or loop into a no-op command. - - if (lexer_flags.looping || current_function_depth > 0 - || reading_script_file || tree_evaluator::in_fcn_or_script_body - || tree_evaluator::in_loop_command) - retval = new tree_break_command (l, c); - else - retval = new tree_no_op_command ("break", l, c); + retval = new tree_break_command (l, c); return retval; } @@ -2512,13 +2503,7 @@ int l = continue_tok->line (); int c = continue_tok->column (); - // We check to see if we are evaluating a loop so that we don't turn - // eval ("continue;") into a no-op command inside a loop. - - if (lexer_flags.looping || tree_evaluator::in_loop_command) - retval = new tree_continue_command (l, c); - else - retval = new tree_no_op_command ("continue", l, c); + retval = new tree_continue_command (l, c); return retval; } @@ -2533,24 +2518,7 @@ int l = return_tok->line (); int c = return_tok->column (); - if (Vdebugging) - { - Vdebugging = false; - - retval = new tree_no_op_command ("return", l, c); - } - else - { - // We check to see if we are evaluating a function or script so - // that we don't turn eval ("return;") inside a function, script, - // or loop into a no-op command. - - if (current_function_depth > 0 || reading_script_file - || tree_evaluator::in_fcn_or_script_body) - retval = new tree_return_command (l, c); - else - retval = new tree_no_op_command ("return", l, c); - } + retval = new tree_return_command (l, c); return retval; } diff --git a/src/pt-eval.cc b/src/pt-eval.cc --- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -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; } }