# HG changeset patch # User jwe # Date 1041048151 0 # Node ID 610671be879265d01fa1ccc5a624eea4793141e6 # Parent 189df16144fc95e830f5b03b1fad05491801bff2 [project @ 2002-12-28 04:02:31 by jwe] diff -r 189df16144fc -r 610671be8792 src/ChangeLog --- a/src/ChangeLog Sat Dec 28 02:00:05 2002 +0000 +++ b/src/ChangeLog Sat Dec 28 04:02:31 2002 +0000 @@ -1,3 +1,13 @@ +2002-12-27 John W. Eaton + + * parse.y (Fevalin): New function. + + * variables.cc (curr_caller_sym_tab): New global variable. + * variables.h: Provide decl. + (initialize_symbol_tables): Initialize it. + * ov-usr-fcn.cc (octave_user_function::do_multi_index_op): + Protect and set it here. + 2002-12-26 John W. Eaton * utils.cc (search_path_for_file): Second arg now string_vector. diff -r 189df16144fc -r 610671be8792 src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc Sat Dec 28 02:00:05 2002 +0000 +++ b/src/ov-usr-fcn.cc Sat Dec 28 04:02:31 2002 +0000 @@ -400,6 +400,9 @@ // Save old and set current symbol table context, for // eval_undefined_error(). + unwind_protect_ptr (curr_caller_sym_tab); + curr_caller_sym_tab = curr_sym_tab; + unwind_protect_ptr (curr_sym_tab); curr_sym_tab = sym_tab; diff -r 189df16144fc -r 610671be8792 src/parse.y --- a/src/parse.y Sat Dec 28 02:00:05 2002 +0000 +++ b/src/parse.y Sat Dec 28 04:02:31 2002 +0000 @@ -3732,6 +3732,75 @@ return retval; } +DEFUN (evalin, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} evalin (@var{context}, @var{try}, @var{catch})\n\ +Like @code{eval}, except that the expressions are evaluated in the\n\ +context @var{context}, which may be either @code{\"caller\"} or\n\ +@code{\"base\"}. +@end deftypefn") +{ + octave_value_list retval; + + int nargin = args.length (); + + if (nargin > 1) + { + std::string context = args(0).string_value (); + + if (! error_state) + { + unwind_protect::begin_frame ("Fevalin"); + + unwind_protect_ptr (curr_sym_tab); + + if (context == "caller") + curr_sym_tab = curr_caller_sym_tab; + else if (context == "base") + curr_sym_tab = top_level_sym_tab; + else + error ("evalin: context must be \"caller\" or \"base\""); + + if (nargin > 2) + { + unwind_protect_bool (buffer_error_messages); + buffer_error_messages = true; + } + + int parse_status = 0; + + retval = eval_string (args(1), ! Vdefault_eval_print_flag, + parse_status, nargout); + + if (nargin > 2 && (parse_status != 0 || error_state)) + { + error_state = 0; + + // Set up for letting the user print any messages from + // errors that occurred in the first part of this eval(). + + buffer_error_messages = false; + + bind_global_error_variable (); + + unwind_protect::add (clear_global_error_variable, 0); + + eval_string (args(2), 0, parse_status, nargout); + + retval = octave_value_list (); + } + + unwind_protect::run_frame ("Fevalin"); + } + else + error ("evalin: expecting string as first argument"); + } + else + print_usage ("evalin"); + + return retval; +} + static int default_eval_print_flag (void) { diff -r 189df16144fc -r 610671be8792 src/variables.cc --- a/src/variables.cc Sat Dec 28 02:00:05 2002 +0000 +++ b/src/variables.cc Sat Dec 28 04:02:31 2002 +0000 @@ -65,6 +65,9 @@ // Symbol table for the current scope. symbol_table *curr_sym_tab = 0; +// Symbol table for the current caller scope. +symbol_table *curr_caller_sym_tab = 0; + // Symbol table for global symbols. symbol_table *global_sym_tab = 0; @@ -94,7 +97,7 @@ if (! top_level_sym_tab) top_level_sym_tab = new symbol_table (4096, "TOP"); - curr_sym_tab = top_level_sym_tab; + curr_caller_sym_tab = curr_sym_tab = top_level_sym_tab; } // Attributes of variables and functions. diff -r 189df16144fc -r 610671be8792 src/variables.h --- a/src/variables.h Sat Dec 28 02:00:05 2002 +0000 +++ b/src/variables.h Sat Dec 28 04:02:31 2002 +0000 @@ -116,6 +116,9 @@ // Symbol table for the current scope. extern symbol_table *curr_sym_tab; +// Symbol table for the current caller scope. +extern symbol_table *curr_caller_sym_tab; + // Symbol table for global symbols. extern symbol_table *global_sym_tab;