Mercurial > hg > octave-lyh
changeset 11029:4ab04ea74b08
make an internal function for try simulation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 28 Sep 2010 09:08:29 +0200 |
parents | 7d0d28aff7a9 |
children | 231946a9ad55 |
files | src/ChangeLog src/error.cc src/error.h src/ov-fcn-handle.cc src/variables.cc |
diffstat | 5 files changed, 27 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-09-28 Jaroslav Hajek <highegg@gmail.com> + + * 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 <jwe@octave.org> * gl-render.cc (opengl_renderer::draw_axes): Reverse order in
--- a/src/error.cc +++ b/src/error.cc @@ -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; +} + +
--- a/src/error.h +++ b/src/error.h @@ -28,6 +28,7 @@ #include <string> 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
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -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)
--- a/src/variables.cc +++ b/src/variables.cc @@ -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);