# HG changeset patch # User Jaroslav Hajek # Date 1285657709 -7200 # Node ID 4ab04ea74b08970e950d6c74772b685edd67433d # Parent 7d0d28aff7a925e06775a2cc9209738234a4eb59 make an internal function for try simulation diff -r 7d0d28aff7a9 -r 4ab04ea74b08 src/ChangeLog --- a/src/ChangeLog Mon Sep 27 21:08:16 2010 +0200 +++ b/src/ChangeLog Tue Sep 28 09:08:29 2010 +0200 @@ -1,3 +1,10 @@ +2010-09-28 Jaroslav Hajek + + * error.cc (interpreter_try): New function. + * error.h: Declare it. + * ov-fcn-handle.cc (octave_fcn_binder::maybe_binder): Use it here. + * variables.cc (safe_symbol_lookup): Also here. + 2010-09-27 John W. Eaton * gl-render.cc (opengl_renderer::draw_axes): Reverse order in diff -r 7d0d28aff7a9 -r 4ab04ea74b08 src/error.cc --- a/src/error.cc Mon Sep 27 21:08:16 2010 +0200 +++ b/src/error.cc Tue Sep 28 09:08:29 2010 +0200 @@ -1821,3 +1821,18 @@ { return Vlast_warning_id; } + +void +interpreter_try (unwind_protect& frame) +{ + frame.protect_var (error_state); + frame.protect_var (buffer_error_messages); + frame.protect_var (Vdebug_on_error); + frame.protect_var (Vdebug_on_warning); + + buffer_error_messages++; + Vdebug_on_error = false; + Vdebug_on_warning = false; +} + + diff -r 7d0d28aff7a9 -r 4ab04ea74b08 src/error.h --- a/src/error.h Mon Sep 27 21:08:16 2010 +0200 +++ b/src/error.h Tue Sep 28 09:08:29 2010 +0200 @@ -28,6 +28,7 @@ #include class octave_value_list; +class unwind_protect; #define panic_impossible() \ panic ("impossible state reached in file `%s' at line %d", \ @@ -137,4 +138,6 @@ extern OCTINTERP_API std::string last_warning_message (void); extern OCTINTERP_API std::string last_warning_id (void); +extern OCTINTERP_API void interpreter_try (unwind_protect&); + #endif diff -r 7d0d28aff7a9 -r 4ab04ea74b08 src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Mon Sep 27 21:08:16 2010 +0200 +++ b/src/ov-fcn-handle.cc Tue Sep 28 09:08:29 2010 +0200 @@ -1879,17 +1879,8 @@ else { // Simulate try/catch. - // FIXME: there should be a method for that. unwind_protect frame; - - frame.protect_var (error_state); - frame.protect_var (buffer_error_messages); - frame.protect_var (Vdebug_on_error); - frame.protect_var (Vdebug_on_warning); - - buffer_error_messages++; - Vdebug_on_error = false; - Vdebug_on_warning = false; + interpreter_try (frame); root_val = make_fcn_handle (head_name); if (error_state) diff -r 7d0d28aff7a9 -r 4ab04ea74b08 src/variables.cc --- a/src/variables.cc Mon Sep 27 21:08:16 2010 +0200 +++ b/src/variables.cc Tue Sep 28 09:08:29 2010 +0200 @@ -385,14 +385,7 @@ octave_value retval; unwind_protect frame; - - frame.protect_var (buffer_error_messages); - frame.protect_var (Vdebug_on_error); - frame.protect_var (Vdebug_on_warning); - - buffer_error_messages++; - Vdebug_on_error = false; - Vdebug_on_warning = false; + interpreter_try (frame); retval = symbol_table::find (symbol_name);