Mercurial > octave-nkf
diff libinterp/octave-value/ov-usr-fcn.cc @ 20589:b10432a40432
eliminate more simple uses of error_state
* dasrt.cc, debug.cc, find.cc, gammainc.cc, matrix_type.cc,
ov-usr-fcn.cc, pt-assign.cc, pt-binop.cc:
Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 05 Oct 2015 20:37:19 -0400 |
parents | 1f330d33388f |
children | eef93a493ce3 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.cc Mon Oct 05 20:21:55 2015 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.cc Mon Oct 05 20:37:19 2015 -0400 @@ -130,43 +130,40 @@ unwind_protect frame; - if (! error_state) + if (args.length () == 0 && nargout == 0) { - if (args.length () == 0 && nargout == 0) + if (cmd_list) { - if (cmd_list) - { - frame.protect_var (call_depth); - call_depth++; + frame.protect_var (call_depth); + call_depth++; - if (call_depth < Vmax_recursion_depth) - { - octave_call_stack::push (this); + if (call_depth < Vmax_recursion_depth) + { + octave_call_stack::push (this); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave_call_stack::pop); - frame.protect_var (tree_evaluator::statement_context); - tree_evaluator::statement_context = tree_evaluator::script; + frame.protect_var (tree_evaluator::statement_context); + tree_evaluator::statement_context = tree_evaluator::script; - BEGIN_PROFILER_BLOCK (octave_user_script) + BEGIN_PROFILER_BLOCK (octave_user_script) - cmd_list->accept (*current_evaluator); + cmd_list->accept (*current_evaluator); - END_PROFILER_BLOCK + END_PROFILER_BLOCK - if (tree_return_command::returning) - tree_return_command::returning = 0; + if (tree_return_command::returning) + tree_return_command::returning = 0; - if (tree_break_command::breaking) - tree_break_command::breaking--; - } - else - error ("max_recursion_depth exceeded"); + if (tree_break_command::breaking) + tree_break_command::breaking--; } + else + error ("max_recursion_depth exceeded"); } - else - error ("invalid call to script %s", file_name.c_str ()); } + else + error ("invalid call to script %s", file_name.c_str ()); return retval; } @@ -476,9 +473,6 @@ { octave_value_list retval; - if (error_state) - return retval; - if (! cmd_list) return retval; @@ -536,11 +530,7 @@ string_vector arg_names = args.name_tags (); if (param_list && ! param_list->varargs_only ()) - { - param_list->define_from_arg_vector (args); - if (error_state) - return retval; - } + param_list->define_from_arg_vector (args); // For classdef constructor, pre-populate the output arguments // with the pre-initialized object instance, extracted above. @@ -548,11 +538,7 @@ if (is_classdef_constructor ()) { if (ret_list) - { - ret_list->define_from_arg_vector (ret_args); - if (error_state) - return retval; - } + ret_list->define_from_arg_vector (ret_args); else { error ("%s: invalid classdef constructor, no output argument defined", @@ -636,9 +622,6 @@ if (tree_break_command::breaking) tree_break_command::breaking--; - if (error_state) - return retval; - // Copy return values out. if (ret_list && ! is_special_expr ()) @@ -660,8 +643,7 @@ } } - if (! error_state) - retval = ret_list->convert_to_const_vector (nargout, varargout); + retval = ret_list->convert_to_const_vector (nargout, varargout); } return retval; @@ -803,11 +785,8 @@ if (val.is_defined ()) { - // Don't use the usual approach of attempting to extract a value - // and then checking error_state since this code might be - // executing when error_state is already set. But do fail - // spectacularly if .saved_warning_states. is not an octave_map - // (or octave_scalar_map) object. + // Fail spectacularly if .saved_warning_states. is not an + // octave_map (or octave_scalar_map) object. if (! val.is_map ()) panic_impossible (); @@ -1123,22 +1102,20 @@ if (args(0).is_scalar_type ()) { double k = args(0).double_value (); - if (! error_state) - retval = isargout1 (nargout1, ignored, k); + + retval = isargout1 (nargout1, ignored, k); } else if (args(0).is_numeric_type ()) { const NDArray ka = args(0).array_value (); - if (! error_state) - { - boolNDArray r (ka.dims ()); - for (octave_idx_type i = 0; - i < ka.numel () && ! error_state; - i++) - r(i) = isargout1 (nargout1, ignored, ka(i)); - retval = r; - } + boolNDArray r (ka.dims ()); + for (octave_idx_type i = 0; + i < ka.numel () && ! error_state; + i++) + r(i) = isargout1 (nargout1, ignored, ka(i)); + + retval = r; } else gripe_wrong_type_arg ("isargout", args(0));