Mercurial > octave-nkf
diff libinterp/parse-tree/pt-assign.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 | dd6345fd8a97 |
children |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-assign.cc Mon Oct 05 20:21:55 2015 -0400 +++ b/libinterp/parse-tree/pt-assign.cc Mon Oct 05 20:37:19 2015 -0400 @@ -77,78 +77,65 @@ { octave_value retval; - if (error_state) - return retval; - if (rhs) { octave_value rhs_val = rhs->rvalue1 (); - if (! error_state) + if (rhs_val.is_undefined ()) { - if (rhs_val.is_undefined ()) + error ("value on right hand side of assignment is undefined"); + return retval; + } + else + { + if (rhs_val.is_cs_list ()) { - error ("value on right hand side of assignment is undefined"); - return retval; - } - else - { - if (rhs_val.is_cs_list ()) - { - const octave_value_list lst = rhs_val.list_value (); + const octave_value_list lst = rhs_val.list_value (); - if (! lst.empty ()) - rhs_val = lst(0); - else - { - error ("invalid number of elements on RHS of assignment"); - return retval; - } + if (! lst.empty ()) + rhs_val = lst(0); + else + { + error ("invalid number of elements on RHS of assignment"); + return retval; } + } - try - { - octave_lvalue ult = lhs->lvalue (); + try + { + octave_lvalue ult = lhs->lvalue (); - if (ult.numel () != 1) - gripe_nonbraced_cs_list_assignment (); - - if (! error_state) - { - ult.assign (etype, rhs_val); + if (ult.numel () != 1) + gripe_nonbraced_cs_list_assignment (); - if (! error_state) - { - if (etype == octave_value::op_asn_eq) - retval = rhs_val; - else - retval = ult.value (); + ult.assign (etype, rhs_val); - 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, instead of the indexed - // value (which should be the same as the - // right hand side value). + if (etype == octave_value::op_asn_eq) + retval = rhs_val; + else + retval = ult.value (); - ult.clear_index (); + 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, instead of the indexed + // value (which should be the same as the + // right hand side value). - octave_value lhs_val = ult.value (); + ult.clear_index (); - if (! error_state) - lhs_val.print_with_name (octave_stdout, - lhs->name ()); - } - } - } + octave_value lhs_val = ult.value (); + + lhs_val.print_with_name (octave_stdout, + lhs->name ()); } - catch (index_exception& e) - { // problems with range, invalid index type etc. - e.set_var (lhs->name ()); - (*current_liboctave_error_with_id_handler) (e.id(), e.err()); - } + } + catch (index_exception& e) + { // problems with range, invalid index type etc. + e.set_var (lhs->name ()); + (*current_liboctave_error_with_id_handler) (e.id(), e.err()); } } } @@ -219,16 +206,10 @@ { octave_value_list retval; - if (error_state) - return retval; - if (rhs) { std::list<octave_lvalue> lvalue_list = lhs->lvalue_list (); - if (error_state) - return retval; - octave_idx_type n_out = 0; for (std::list<octave_lvalue>::const_iterator p = lvalue_list.begin (); @@ -243,9 +224,6 @@ ? rhs_val1(0).list_value () : rhs_val1); - if (error_state) - return retval; - octave_idx_type k = 0; octave_idx_type n = rhs_val.length (); @@ -303,12 +281,9 @@ ult.assign (octave_value::op_asn_eq, octave_value (ovl, true)); - if (! error_state) - { - retval_list.push_back (ovl); + retval_list.push_back (ovl); - k += nel; - } + k += nel; } else error ("some elements undefined in return list"); @@ -324,7 +299,7 @@ k++; continue; } - else if (! error_state) + else { retval_list.push_back (rhs_val(k)); @@ -358,10 +333,8 @@ } } - if (error_state) - break; - else if (print_result () - && tree_evaluator::statement_printing_enabled ()) + 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, @@ -372,19 +345,12 @@ octave_value lhs_val = ult.value (); - if (! error_state) - lhs_val.print_with_name (octave_stdout, - lhs_elt->name ()); + lhs_val.print_with_name (octave_stdout, lhs_elt->name ()); } - - if (error_state) - break; - } // Concatenate return values. retval = retval_list; - } return retval;