Mercurial > hg > octave-lyh
changeset 5858:6bd94066d360
[project @ 2006-06-13 18:55:53 by jwe]
author | jwe |
---|---|
date | Tue, 13 Jun 2006 18:55:53 +0000 |
parents | 6a558a8763df |
children | ba0bea22167b |
files | src/ChangeLog src/pt-stmt.cc |
diffstat | 2 files changed, 46 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2006-06-13 John W. Eaton <jwe@octave.org> + * pt-stmt.cc (tree_statement_list::eval): Revise previous change + to preserve return-last-value-computed semantics. + * DLD-FUNCTIONS/fsolve.cc (hybrd_info_to_fsolve_info): Warn about invalid values of INFO from MINPACK instead of calling panic_impossible.
--- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -154,42 +154,58 @@ { octave_value_list retval; + static octave_value_list empty_list; + if (error_state) return retval; - for (iterator p = begin (); p != end (); p++) - { - tree_statement *elt = *p; + iterator p = begin (); - if (elt) + if (p != end ()) + { + while (true) { - OCTAVE_QUIT; + tree_statement *elt = *p++; + + if (elt) + { + OCTAVE_QUIT; - // Clear preivous values before next statement is evaluated - // so that we aren't holding an extra reference to a value - // that may be used next. For example, in code like this: - // - // X = rand (N); ## refcount should be 1 after this statement. - // X(idx) = val; ## no extra copy should be needed, but - // ## we will be faked out if retval is not - // ## cleared between statements here. + retval = elt->eval (silent, nargout, function_body); + + if (error_state) + break; + + if (tree_break_command::breaking + || tree_continue_command::continuing) + break; + + if (tree_return_command::returning) + break; - retval = octave_value_list (); - - retval = elt->eval (silent, nargout, function_body); - - if (error_state) - break; + if (p == end ()) + break; + else + { + // Clear preivous values before next statement is + // evaluated so that we aren't holding an extra + // reference to a value that may be used next. For + // example, in code like this: + // + // X = rand (N); ## refcount for X should be 1 + // ## after this statement + // + // X(idx) = val; ## no extra copy of X should be + // ## needed, but we will be faked + // ## out if retval is not cleared + // ## between statements here - if (tree_break_command::breaking - || tree_continue_command::continuing) - break; - - if (tree_return_command::returning) - break; + retval = empty_list; + } + } + else + error ("invalid statement found in statement list!"); } - else - error ("invalid statement found in statement list!"); } return retval;