Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
20588:4bed806ee3d4 | 20589:b10432a40432 |
---|---|
128 { | 128 { |
129 octave_value_list retval; | 129 octave_value_list retval; |
130 | 130 |
131 unwind_protect frame; | 131 unwind_protect frame; |
132 | 132 |
133 if (! error_state) | 133 if (args.length () == 0 && nargout == 0) |
134 { | 134 { |
135 if (args.length () == 0 && nargout == 0) | 135 if (cmd_list) |
136 { | 136 { |
137 if (cmd_list) | 137 frame.protect_var (call_depth); |
138 { | 138 call_depth++; |
139 frame.protect_var (call_depth); | 139 |
140 call_depth++; | 140 if (call_depth < Vmax_recursion_depth) |
141 | 141 { |
142 if (call_depth < Vmax_recursion_depth) | 142 octave_call_stack::push (this); |
143 { | 143 |
144 octave_call_stack::push (this); | 144 frame.add_fcn (octave_call_stack::pop); |
145 | 145 |
146 frame.add_fcn (octave_call_stack::pop); | 146 frame.protect_var (tree_evaluator::statement_context); |
147 | 147 tree_evaluator::statement_context = tree_evaluator::script; |
148 frame.protect_var (tree_evaluator::statement_context); | 148 |
149 tree_evaluator::statement_context = tree_evaluator::script; | 149 BEGIN_PROFILER_BLOCK (octave_user_script) |
150 | 150 |
151 BEGIN_PROFILER_BLOCK (octave_user_script) | 151 cmd_list->accept (*current_evaluator); |
152 | 152 |
153 cmd_list->accept (*current_evaluator); | 153 END_PROFILER_BLOCK |
154 | 154 |
155 END_PROFILER_BLOCK | 155 if (tree_return_command::returning) |
156 | 156 tree_return_command::returning = 0; |
157 if (tree_return_command::returning) | 157 |
158 tree_return_command::returning = 0; | 158 if (tree_break_command::breaking) |
159 | 159 tree_break_command::breaking--; |
160 if (tree_break_command::breaking) | 160 } |
161 tree_break_command::breaking--; | 161 else |
162 } | 162 error ("max_recursion_depth exceeded"); |
163 else | 163 } |
164 error ("max_recursion_depth exceeded"); | 164 } |
165 } | 165 else |
166 } | 166 error ("invalid call to script %s", file_name.c_str ()); |
167 else | |
168 error ("invalid call to script %s", file_name.c_str ()); | |
169 } | |
170 | 167 |
171 return retval; | 168 return retval; |
172 } | 169 } |
173 | 170 |
174 void | 171 void |
474 const octave_value_list& _args, | 471 const octave_value_list& _args, |
475 const std::list<octave_lvalue>* lvalue_list) | 472 const std::list<octave_lvalue>* lvalue_list) |
476 { | 473 { |
477 octave_value_list retval; | 474 octave_value_list retval; |
478 | 475 |
479 if (error_state) | |
480 return retval; | |
481 | |
482 if (! cmd_list) | 476 if (! cmd_list) |
483 return retval; | 477 return retval; |
484 | 478 |
485 // If this function is a classdef constructor, extract the first input | 479 // If this function is a classdef constructor, extract the first input |
486 // argument, which must be the partially constructed object instance. | 480 // argument, which must be the partially constructed object instance. |
534 } | 528 } |
535 | 529 |
536 string_vector arg_names = args.name_tags (); | 530 string_vector arg_names = args.name_tags (); |
537 | 531 |
538 if (param_list && ! param_list->varargs_only ()) | 532 if (param_list && ! param_list->varargs_only ()) |
539 { | 533 param_list->define_from_arg_vector (args); |
540 param_list->define_from_arg_vector (args); | |
541 if (error_state) | |
542 return retval; | |
543 } | |
544 | 534 |
545 // For classdef constructor, pre-populate the output arguments | 535 // For classdef constructor, pre-populate the output arguments |
546 // with the pre-initialized object instance, extracted above. | 536 // with the pre-initialized object instance, extracted above. |
547 | 537 |
548 if (is_classdef_constructor ()) | 538 if (is_classdef_constructor ()) |
549 { | 539 { |
550 if (ret_list) | 540 if (ret_list) |
551 { | 541 ret_list->define_from_arg_vector (ret_args); |
552 ret_list->define_from_arg_vector (ret_args); | |
553 if (error_state) | |
554 return retval; | |
555 } | |
556 else | 542 else |
557 { | 543 { |
558 error ("%s: invalid classdef constructor, no output argument defined", | 544 error ("%s: invalid classdef constructor, no output argument defined", |
559 dispatch_class ().c_str ()); | 545 dispatch_class ().c_str ()); |
560 return retval; | 546 return retval; |
634 tree_return_command::returning = 0; | 620 tree_return_command::returning = 0; |
635 | 621 |
636 if (tree_break_command::breaking) | 622 if (tree_break_command::breaking) |
637 tree_break_command::breaking--; | 623 tree_break_command::breaking--; |
638 | 624 |
639 if (error_state) | |
640 return retval; | |
641 | |
642 // Copy return values out. | 625 // Copy return values out. |
643 | 626 |
644 if (ret_list && ! is_special_expr ()) | 627 if (ret_list && ! is_special_expr ()) |
645 { | 628 { |
646 ret_list->initialize_undefined_elements (my_name, nargout, Matrix ()); | 629 ret_list->initialize_undefined_elements (my_name, nargout, Matrix ()); |
658 if (error_state) | 641 if (error_state) |
659 error ("expecting varargout to be a cell array object"); | 642 error ("expecting varargout to be a cell array object"); |
660 } | 643 } |
661 } | 644 } |
662 | 645 |
663 if (! error_state) | 646 retval = ret_list->convert_to_const_vector (nargout, varargout); |
664 retval = ret_list->convert_to_const_vector (nargout, varargout); | |
665 } | 647 } |
666 | 648 |
667 return retval; | 649 return retval; |
668 } | 650 } |
669 | 651 |
801 { | 783 { |
802 octave_value val = symbol_table::varval (".saved_warning_states."); | 784 octave_value val = symbol_table::varval (".saved_warning_states."); |
803 | 785 |
804 if (val.is_defined ()) | 786 if (val.is_defined ()) |
805 { | 787 { |
806 // Don't use the usual approach of attempting to extract a value | 788 // Fail spectacularly if .saved_warning_states. is not an |
807 // and then checking error_state since this code might be | 789 // octave_map (or octave_scalar_map) object. |
808 // executing when error_state is already set. But do fail | |
809 // spectacularly if .saved_warning_states. is not an octave_map | |
810 // (or octave_scalar_map) object. | |
811 | 790 |
812 if (! val.is_map ()) | 791 if (! val.is_map ()) |
813 panic_impossible (); | 792 panic_impossible (); |
814 | 793 |
815 octave_map m = val.map_value (); | 794 octave_map m = val.map_value (); |
1121 ignored = tmp.matrix_value (); | 1100 ignored = tmp.matrix_value (); |
1122 | 1101 |
1123 if (args(0).is_scalar_type ()) | 1102 if (args(0).is_scalar_type ()) |
1124 { | 1103 { |
1125 double k = args(0).double_value (); | 1104 double k = args(0).double_value (); |
1126 if (! error_state) | 1105 |
1127 retval = isargout1 (nargout1, ignored, k); | 1106 retval = isargout1 (nargout1, ignored, k); |
1128 } | 1107 } |
1129 else if (args(0).is_numeric_type ()) | 1108 else if (args(0).is_numeric_type ()) |
1130 { | 1109 { |
1131 const NDArray ka = args(0).array_value (); | 1110 const NDArray ka = args(0).array_value (); |
1132 if (! error_state) | 1111 |
1133 { | 1112 boolNDArray r (ka.dims ()); |
1134 boolNDArray r (ka.dims ()); | 1113 for (octave_idx_type i = 0; |
1135 for (octave_idx_type i = 0; | 1114 i < ka.numel () && ! error_state; |
1136 i < ka.numel () && ! error_state; | 1115 i++) |
1137 i++) | 1116 r(i) = isargout1 (nargout1, ignored, ka(i)); |
1138 r(i) = isargout1 (nargout1, ignored, ka(i)); | 1117 |
1139 | 1118 retval = r; |
1140 retval = r; | |
1141 } | |
1142 } | 1119 } |
1143 else | 1120 else |
1144 gripe_wrong_type_arg ("isargout", args(0)); | 1121 gripe_wrong_type_arg ("isargout", args(0)); |
1145 } | 1122 } |
1146 else | 1123 else |