Mercurial > octave
diff libinterp/corefcn/interpreter.cc @ 23723:ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
* pt-stmt.h, pt-stmt.cc (tree_statement::echo_code): New argument,
prefix. Pass prefix to tree_print_code constructor instead of VPS4.
* basics.txi: Delete documentation for echo_executing_commands.
* interpreter.h, interpreter.cc (interpreter::maximum_braindamage):
Now a member function.
(interpreter::interpreter): Call tree_evaluator::echo directly instead
of using Fecho_executing_commands. Don't force input to be echoed if
forced_interactive is etst.
* input.h, input.cc (Fecho_executing_commands): Delete.
(Vecho_executing_commands): Delete variable and all uses.
(VPS4): Delete.
(set_default_prompts): Don't set global value for PS4 here.
(base_reader::do_input_echo): Delete.
(gnu_readline): Don't call do_input_echo.
* pt-eval.h, pt-eval.cc (Fecho_executing_commands): Delete.
(FPS4): Move here from input.cc.
(Fecho): Move here from input.cc Rewrite. Handle "echo function
on|off" syntax.
(echo_state): Move enum declaration to tree_evaluator class from input.h.
* ov-usr-fcn.cc (octave_user_script::call, octave_user_function::call):
Push echo state before executing commands. Don't print function
header or trailer here.
(octave_user_function::print_code_function_header,
octave_user_function::print_code_function_trailer): New arg, prefix.
Pass prefix to tree_print_code constructor instead of VPS4.
* pt-eval.h, pt-eval.cc (tree_evaluator::m_PS4,
tree_evaluator::m_echo, tree_evaluator::m_echo_state,
tree_evaluator::m_echo_file_name, tree_evaluator::m_echo_file_pos,
tree_evaluator::m_echo_files): New member variables.
(tree_evaluator::echo_state, tree_evaluator::PS4,
tree_evaluator::echo, tree_evaluator::push_echo_state,
tree_evaluator::set_echo_state, tree_evaluator::set_echo_file_name,
tree_evaluator::set_echo_file_pos, tree_evaluator::echo_this_file,
tree_evaluator::echo_code): New member functions.
(tree_evaluator::visit_break_command,
tree_evaluator::visit_continue_command,
tree_evaluator::visit_decl_command,
tree_evaluator::visit_simple_for_command,
tree_evaluator::visit_complex_for_command,
tree_evaluator::visit_if_command,
tree_evaluator::visit_no_op_command,
tree_evaluator::visit_return_command,
tree_evaluator::visit_switch_command,
tree_evaluator::visit_try_catch_command,
tree_evaluator::visit_unwind_protect_command,
tree_evaluator::visit_while_command,
tree_evaluator::visit_do_until_command):
Manage echo_file_pos and echo code here.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 30 Jun 2017 20:59:54 -0400 |
parents | b2d55b52ee51 |
children | 8acd390d16c9 |
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc Fri Jun 30 01:21:31 2017 -0400 +++ b/libinterp/corefcn/interpreter.cc Fri Jun 30 20:59:54 2017 -0400 @@ -173,33 +173,6 @@ set_liboctave_warning_with_id_handler (warning_with_id); } -// What internal options get configured by --traditional. - -static void -maximum_braindamage (void) -{ - FPS1 (octave_value (">> ")); - FPS2 (octave_value ("")); - FPS4 (octave_value ("")); - Fbeep_on_error (octave_value (true)); - Fconfirm_recursive_rmdir (octave_value (false)); - Fcrash_dumps_octave_core (octave_value (false)); - Fdisable_diagonal_matrix (octave_value (true)); - Fdisable_permutation_matrix (octave_value (true)); - Fdisable_range (octave_value (true)); - Ffixed_point_format (octave_value (true)); - Fhistory_timestamp_format_string (octave_value ("%%-- %D %I:%M %p --%%")); - Fpage_screen_output (octave_value (false)); - Fprint_empty_dimensions (octave_value (false)); - Fsave_default_options (octave_value ("-mat-binary")); - Fstruct_levels_to_print (octave_value (0)); - - disable_warning ("Octave:abbreviated-property-match"); - disable_warning ("Octave:data-file-in-path"); - disable_warning ("Octave:function-name-clash"); - disable_warning ("Octave:possible-matlab-short-circuit-operator"); -} - DEFUN (quit, args, , doc: /* -*- texinfo -*- @deftypefn {} {} exit @@ -505,10 +478,8 @@ // instead of using the interpreter-level functions. if (options.echo_commands ()) - { - int val = ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE; - Fecho_executing_commands (octave_value (val)); - } + m_evaluator.echo + (tree_evaluator::ECHO_SCRIPTS | tree_evaluator::ECHO_FUNCTIONS); std::string docstrings_file = options.docstrings_file (); if (! docstrings_file.empty ()) @@ -700,16 +671,8 @@ return exit_status; } - // Force input to be echoed if not really interactive, - // but the user has forced interactive behavior. - if (options.forced_interactive ()) - { - command_editor::blink_matching_paren (false); - - // FIXME: is this the right thing to do? - Fecho_executing_commands (octave_value (ECHO_CMD_LINE)); - } + command_editor::blink_matching_paren (false); } // Avoid counting commands executed from startup or script files. @@ -1310,4 +1273,32 @@ return found; } + + // What internal options get configured by --traditional. + + void interpreter::maximum_braindamage (void) + { + FPS1 (octave_value (">> ")); + FPS2 (octave_value ("")); + + m_evaluator.PS4 (""); + + Fbeep_on_error (octave_value (true)); + Fconfirm_recursive_rmdir (octave_value (false)); + Fcrash_dumps_octave_core (octave_value (false)); + Fdisable_diagonal_matrix (octave_value (true)); + Fdisable_permutation_matrix (octave_value (true)); + Fdisable_range (octave_value (true)); + Ffixed_point_format (octave_value (true)); + Fhistory_timestamp_format_string (octave_value ("%%-- %D %I:%M %p --%%")); + Fpage_screen_output (octave_value (false)); + Fprint_empty_dimensions (octave_value (false)); + Fsave_default_options (octave_value ("-mat-binary")); + Fstruct_levels_to_print (octave_value (0)); + + disable_warning ("Octave:abbreviated-property-match"); + disable_warning ("Octave:data-file-in-path"); + disable_warning ("Octave:function-name-clash"); + disable_warning ("Octave:possible-matlab-short-circuit-operator"); + } }