comparison libinterp/parse-tree/oct-parse.in.yy @ 20569:b70cc4bd8109

begin removal of global error_state variable * gripes.h, gripes.cc (gripe_library_execution_error): Delete. * error.cc (warning_state): Delete unused variable. (reset_error_handler): Don't set warning_state or error_state. (debug_or_throw_exception): New static function. (verror): Don't check error_state. (vmessage): Call debug_or_throw_exception instead of setting error_state. (error_1, error_2): Combine into single function, error_1 that prints error message and ultimately calls debug_or_throw_exception. (verror, verror_with_cfn, verror_with_id_cfn): Call error_1. Don't check or set warning_state. (error): Don't check error_state. (Flasterror, Flasterr): Adapt to not using error_state. (interpreter_try): Don't unwind_protect error_state. * NEWS: Update. * doc/interpreter/external.txi: Explain octave_execution_exception instead of error_state for matrix addition example. * jit-typeinfo.cc (octave_jit_gripe_nan_to_logical_conversion, octave_jit_ginvalid_index, octave_jit_gindex_range, octave_jit_paren_scalar, octave_jit_paren_scalar_subsasgn): Don't catch octave_execution_exception. * cellfun.cc (Fcellfun): Use exceptions instead of error_state. * ls-mat-ascii.cc (save_mat_ascii_data): Likewise. * mex.cc (mexCallMATLAB, mexEvalString): Likewise. * variables.cc (safe_symbol_lookup): Likewise. * svd.cc (Fsvd): Eliminate use of error_state. * __magick_read__.cc (read_file, write_file): Likewise. * variables.cc (generate_struct_completions): Eliminate use of obsolete warning_state variable. * ov-builtin.cc (octave_builtin::do_multi_index_op): Don't catch octave_execution_exception and call gripe_library_execution_error. * ov-class.cc (octave_class::reconstruct_exemplar): Eliminate use of error_state. Catch possible octave_execution_exception in do_multi_index_op. * ov-mex-fcn.cc (octave_mex_function::do_multi_index_op): Eliminate use of error_state. Catch possible octave_execution_exception in call_mex. * ov-fcn-handle.cc (octave_fcn_binder::maybe_binder): Eliminate use of error_state. * ov-oncleanup.cc (octave_oncleanup::~octave_oncleanup): Eliminate use of error_state. Propagate possible octave_execution_exception from do_multi_index_op. * ov.cc (octave_value::assign, do_binary_op, do_unary_op, octave_value::do_non_const_unary_op): Don't catch octave_execution_exception here. * oct-parse.in.yy (octave_base_parser::finish_colon_expression, octave_base_parser::finish_array_list): Eliminate use of warning_state and error_state. (Feval, Fevalin): Use exceptions instead of error_state. * pt-eval.cc, pt-eval.h (tree_evaluator::unwind_protect_exception): New static variable. * (tree_evaluator::visit_statement): Don't catch octave_execution_exception here. (tree_evaluator::visit_try_catch_command, tree_evaluator::do_unwind_protect_cleanup): Eliminate use of error_state. (tree_evaluator::visit_unwind_protect_command): Use unwind_protect_exception to track whether an exception has occurred in the try block.
author John W. Eaton <jwe@octave.org>
date Thu, 01 Oct 2015 16:18:19 -0400
parents 075a5e2e1ba5
children 52ce821a52fd
comparison
equal deleted inserted replaced
20568:fcb792acab9b 20569:b70cc4bd8109
2245 tree_expression *retval = e; 2245 tree_expression *retval = e;
2246 2246
2247 unwind_protect frame; 2247 unwind_protect frame;
2248 2248
2249 frame.protect_var (error_state); 2249 frame.protect_var (error_state);
2250 frame.protect_var (warning_state);
2251 2250
2252 frame.protect_var (discard_error_messages); 2251 frame.protect_var (discard_error_messages);
2253 frame.protect_var (discard_warning_messages); 2252 frame.protect_var (discard_warning_messages);
2254 2253
2255 discard_error_messages = true; 2254 discard_error_messages = true;
2266 if (base->is_constant () && limit->is_constant () 2265 if (base->is_constant () && limit->is_constant ()
2267 && (! incr || (incr && incr->is_constant ()))) 2266 && (! incr || (incr && incr->is_constant ())))
2268 { 2267 {
2269 octave_value tmp = e->rvalue1 (); 2268 octave_value tmp = e->rvalue1 ();
2270 2269
2271 if (! (error_state || warning_state)) 2270 if (! error_state)
2272 { 2271 {
2273 tree_constant *tc_retval 2272 tree_constant *tc_retval
2274 = new tree_constant (tmp, base->line (), base->column ()); 2273 = new tree_constant (tmp, base->line (), base->column ());
2275 2274
2276 std::ostringstream buf; 2275 std::ostringstream buf;
3798 tree_expression *retval = array_list; 3797 tree_expression *retval = array_list;
3799 3798
3800 unwind_protect frame; 3799 unwind_protect frame;
3801 3800
3802 frame.protect_var (error_state); 3801 frame.protect_var (error_state);
3803 frame.protect_var (warning_state);
3804 3802
3805 frame.protect_var (discard_error_messages); 3803 frame.protect_var (discard_error_messages);
3806 frame.protect_var (discard_warning_messages); 3804 frame.protect_var (discard_warning_messages);
3807 3805
3808 discard_error_messages = true; 3806 discard_error_messages = true;
3810 3808
3811 if (array_list->all_elements_are_constant ()) 3809 if (array_list->all_elements_are_constant ())
3812 { 3810 {
3813 octave_value tmp = array_list->rvalue1 (); 3811 octave_value tmp = array_list->rvalue1 ();
3814 3812
3815 if (! (error_state || warning_state)) 3813 if (! error_state)
3816 { 3814 {
3817 tree_constant *tc_retval 3815 tree_constant *tc_retval
3818 = new tree_constant (tmp, array_list->line (), 3816 = new tree_constant (tmp, array_list->line (),
3819 array_list->column ()); 3817 array_list->column ());
3820 3818
4997 buffer_error_messages++; 4995 buffer_error_messages++;
4998 } 4996 }
4999 4997
5000 int parse_status = 0; 4998 int parse_status = 0;
5001 4999
5002 octave_value_list tmp = eval_string (args(0), nargout > 0, 5000 bool execution_error = false;
5003 parse_status, nargout); 5001
5004 5002 octave_value_list tmp;
5005 if (nargin > 1 && (parse_status != 0 || error_state)) 5003
5004 try
5006 { 5005 {
5007 error_state = 0; 5006 tmp = eval_string (args(0), nargout > 0, parse_status, nargout);
5008 5007 }
5008 catch (const octave_execution_exception&)
5009 {
5010 execution_error = true;
5011 }
5012
5013 if (nargin > 1 && (parse_status != 0 || execution_error))
5014 {
5009 // Set up for letting the user print any messages from 5015 // Set up for letting the user print any messages from
5010 // errors that occurred in the first part of this eval(). 5016 // errors that occurred in the first part of this eval().
5011 5017
5012 buffer_error_messages--; 5018 buffer_error_messages--;
5013 5019
5014 tmp = eval_string (args(1), nargout > 0, parse_status, nargout); 5020 tmp = eval_string (args(1), nargout > 0, parse_status, nargout);
5015 5021
5016 if (nargout > 0) 5022 if (nargout > 0)
5017 retval = tmp; 5023 retval = tmp;
5018 } 5024 }
5019 else if (nargout > 0) 5025 else
5020 retval = tmp; 5026 {
5027 if (nargout > 0)
5028 retval = tmp;
5029
5030 // FIXME: we should really be rethrowing whatever exception occurred,
5031 // not just throwing an execution exception.
5032 if (execution_error)
5033 octave_throw_execution_exception ();
5034 }
5021 } 5035 }
5022 else 5036 else
5023 print_usage (); 5037 print_usage ();
5024 5038
5025 return retval; 5039 return retval;
5154 buffer_error_messages++; 5168 buffer_error_messages++;
5155 } 5169 }
5156 5170
5157 int parse_status = 0; 5171 int parse_status = 0;
5158 5172
5159 octave_value_list tmp = eval_string (args(1), nargout > 0, 5173 bool execution_error = false;
5160 parse_status, nargout); 5174
5161 5175 octave_value_list tmp;
5162 if (nargout > 0) 5176
5163 retval = tmp; 5177 try
5164
5165 if (nargin > 2 && (parse_status != 0 || error_state))
5166 { 5178 {
5167 error_state = 0; 5179 tmp = eval_string (args(1), nargout > 0,
5168 5180 parse_status, nargout);
5181 }
5182 catch (const octave_execution_exception&)
5183 {
5184 execution_error = true;
5185 }
5186
5187 if (nargin > 2 && (parse_status != 0 || execution_error))
5188 {
5169 // Set up for letting the user print any messages from 5189 // Set up for letting the user print any messages from
5170 // errors that occurred in the first part of this eval(). 5190 // errors that occurred in the first part of this eval().
5171 5191
5172 buffer_error_messages--; 5192 buffer_error_messages--;
5173 5193
5174 tmp = eval_string (args(2), nargout > 0, 5194 tmp = eval_string (args(2), nargout > 0,
5175 parse_status, nargout); 5195 parse_status, nargout);
5176 5196
5177 retval = (nargout > 0) ? tmp : octave_value_list (); 5197 retval = (nargout > 0) ? tmp : octave_value_list ();
5198 }
5199 else
5200 {
5201 if (nargout > 0)
5202 retval = tmp;
5203
5204 // FIXME: we should really be rethrowing whatever
5205 // exception occurred, not just throwing an
5206 // execution exception.
5207 if (execution_error)
5208 octave_throw_execution_exception ();
5178 } 5209 }
5179 } 5210 }
5180 } 5211 }
5181 else 5212 else
5182 error ("evalin: CONTEXT must be a string"); 5213 error ("evalin: CONTEXT must be a string");