# HG changeset patch # User Max Brister # Date 1352518161 25200 # Node ID fb9dffe5fbfb4469f66becd0dab61f02b34d679f # Parent 80a4ded6b89c18dd83451969802ca253c655d7f1 The silent_functions flag no longer modifies the parse tree * pt-assign.cc (tree_simple_assignment::rvalue1, tree_multi_assignment::rvalue): Check tree_evaluator::statement_printing_enabled. * pt-eval.cc (tree_evaluator::statement_printing_enabled): New function. (tree_evaluator::visit_statement): Do not modify parse tree and check tree_evaluator::statement_printing_enabled. * pt-eval.h (tree_evaluator::statement_printing_enabled): New declaration. * pt-exp.h (tree_expression::print_result): Added comment. * pt-id.cc (tree_identifier::rvalue): Check tree_evaluator::statement_printing_enabled. diff -r 80a4ded6b89c -r fb9dffe5fbfb libinterp/parse-tree/pt-assign.cc --- a/libinterp/parse-tree/pt-assign.cc Mon Nov 05 14:50:54 2012 -0800 +++ b/libinterp/parse-tree/pt-assign.cc Fri Nov 09 20:29:21 2012 -0700 @@ -38,6 +38,7 @@ #include "pt-arg-list.h" #include "pt-bp.h" #include "pt-assign.h" +#include "pt-eval.h" #include "pt-walk.h" #include "utils.h" #include "variables.h" @@ -247,7 +248,8 @@ else retval = ult.value (); - if (print_result ()) + if (print_result () + && tree_evaluator::statement_printing_enabled ()) { // We clear any index here so that we can // get the new value of the referenced @@ -459,7 +461,8 @@ if (error_state) break; - else if (print_result ()) + else if (print_result () + && tree_evaluator::statement_printing_enabled ()) { // We clear any index here so that we can get // the new value of the referenced object below, diff -r 80a4ded6b89c -r fb9dffe5fbfb libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc Mon Nov 05 14:50:54 2012 -0800 +++ b/libinterp/parse-tree/pt-eval.cc Fri Nov 09 20:29:21 2012 -0700 @@ -132,6 +132,13 @@ dbstep_flag = 0; } +bool +tree_evaluator::statement_printing_enabled (void) +{ + return ! (Vsilent_functions && (statement_context == function + || statement_context == script)); +} + static inline void do_global_init (tree_decl_elt& elt) { @@ -717,10 +724,6 @@ if (debug_mode) do_breakpoint (expr->is_breakpoint ()); - if ((statement_context == function || statement_context == script) - && Vsilent_functions) - expr->set_print_flag (false); - // FIXME -- maybe all of this should be packaged in // one virtual function that returns a flag saying whether // or not the expression will take care of binding ans and @@ -744,7 +747,8 @@ octave_value tmp_result = expr->rvalue1 (0); if (do_bind_ans && ! (error_state || tmp_result.is_undefined ())) - bind_ans (tmp_result, expr->print_result ()); + bind_ans (tmp_result, expr->print_result () + && statement_printing_enabled ()); // if (tmp_result.is_defined ()) // result_values(0) = tmp_result; diff -r 80a4ded6b89c -r fb9dffe5fbfb libinterp/parse-tree/pt-eval.h --- a/libinterp/parse-tree/pt-eval.h Mon Nov 05 14:50:54 2012 -0800 +++ b/libinterp/parse-tree/pt-eval.h Fri Nov 09 20:29:21 2012 -0700 @@ -136,6 +136,8 @@ static void reset_debug_state (void); + static bool statement_printing_enabled (void); + // If > 0, stop executing at the (N-1)th stopping point, counting // from the the current execution point in the current frame. // diff -r 80a4ded6b89c -r fb9dffe5fbfb libinterp/parse-tree/pt-exp.h --- a/libinterp/parse-tree/pt-exp.h Mon Nov 05 14:50:54 2012 -0800 +++ b/libinterp/parse-tree/pt-exp.h Fri Nov 09 20:29:21 2012 -0700 @@ -87,6 +87,9 @@ bool is_postfix_indexed (void) const { return postfix_indexed; } + // Check if the result of the expression should be printed. + // Should normally be used in conjunction with + // tree_evaluator::statement_printing_enabled. bool print_result (void) const { return print_flag; } virtual std::string oper (void) const { return ""; } diff -r 80a4ded6b89c -r fb9dffe5fbfb libinterp/parse-tree/pt-id.cc --- a/libinterp/parse-tree/pt-id.cc Mon Nov 05 14:50:54 2012 -0800 +++ b/libinterp/parse-tree/pt-id.cc Fri Nov 09 20:29:21 2012 -0700 @@ -30,6 +30,7 @@ #include "pager.h" #include "pt-bp.h" #include "pt-const.h" +#include "pt-eval.h" #include "pt-id.h" #include "pt-walk.h" #include "symtab.h" @@ -88,7 +89,8 @@ } else { - if (print_result () && nargout == 0) + if (print_result () && nargout == 0 + && tree_evaluator::statement_printing_enabled ()) val.print_with_name (octave_stdout, name ()); retval = val;