Mercurial > hg > octave-shane
changeset 6505:c7901606ba70
[project @ 2007-04-06 16:11:38 by jwe]
author | jwe |
---|---|
date | Fri, 06 Apr 2007 16:11:38 +0000 |
parents | 7e9a548e8ddf |
children | e48c2a2528f6 |
files | src/ChangeLog src/ov-usr-fcn.cc src/ov-usr-fcn.h src/pt-fcn-handle.cc src/pt-fcn-handle.h |
diffstat | 5 files changed, 58 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,22 @@ +2007-04-06 John W. Eaton <jwe@octave.org> + + * pt-fcn-handle.cc (tree_anon_fcn_handle::param_list, + tree_anon_fcn_handle::cmd_list, tree_anon_fcn_handle::ret_list, + tree_anon_fcn_handle::sym_tab): Delete. Remove all uses. + (tree_anon_fcn_handle::fcn): New data member. + (tree_anon_fcn_handle::tree_anon_fcn_handle): Initialize it. + (tree_anon_fcn_handle::rvalue, tree_anon_fcn_handle::dup): + Extract parameter list, return list, function body, and symbol + table from fcn. + (tree_anon_fcn_handle::parameter_list, tree_anon_fcn_handle::body): + Forward request to fcn. + + * ov-usr-fcn.h (octave_user_function::local_sym_tab): Rename from + sym_tab. Change all uses. + (octave_user_function::sym_tab): New function. + + * octave.cc (execute_command_line_file): + 2007-04-05 David Bateman <dbateman@free.fr> * DLD-FUNCTIONS/regexp.cc (Fregexprep): Correct iteration over
--- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -73,7 +73,7 @@ tree_statement_list *cl, symbol_table *st) : octave_function (std::string (), std::string ()), param_list (pl), ret_list (rl), cmd_list (cl), - sym_tab (st), lead_comm (), trail_comm (), file_name (), + local_sym_tab (st), lead_comm (), trail_comm (), file_name (), parent_name (), t_parsed (static_cast<time_t> (0)), t_checked (static_cast<time_t> (0)), system_fcn_file (false), call_depth (0), num_named_args (0), @@ -89,7 +89,7 @@ { delete param_list; delete ret_list; - delete sym_tab; + delete local_sym_tab; delete cmd_list; delete lead_comm; delete trail_comm; @@ -277,15 +277,15 @@ if (call_depth > 1) { - sym_tab->push_context (); - unwind_protect::add (pop_symbol_table_context, sym_tab); + local_sym_tab->push_context (); + unwind_protect::add (pop_symbol_table_context, local_sym_tab); } install_automatic_vars (); // Force symbols to be undefined again when this function exits. - unwind_protect::add (clear_symbol_table, sym_tab); + unwind_protect::add (clear_symbol_table, local_sym_tab); // Save old and set current symbol table context, for // eval_undefined_error(). @@ -294,7 +294,7 @@ curr_caller_sym_tab = curr_sym_tab; unwind_protect_ptr (curr_sym_tab); - curr_sym_tab = sym_tab; + curr_sym_tab = local_sym_tab; unwind_protect_ptr (curr_caller_statement); curr_caller_statement = curr_statement; @@ -381,7 +381,7 @@ Cell varargout; - symbol_record *sr = sym_tab->lookup ("varargout"); + symbol_record *sr = local_sym_tab->lookup ("varargout"); if (sr && sr->is_variable ()) { @@ -436,8 +436,8 @@ void octave_user_function::print_symtab_info (std::ostream& os) const { - if (sym_tab) - sym_tab->print_info (os); + if (local_sym_tab) + local_sym_tab->print_info (os); else warning ("%s: no symbol table info!", my_name.c_str ()); } @@ -461,14 +461,14 @@ void octave_user_function::install_automatic_vars (void) { - if (sym_tab) + if (local_sym_tab) { - argn_sr = sym_tab->lookup ("argn", true); - nargin_sr = sym_tab->lookup ("__nargin__", true); - nargout_sr = sym_tab->lookup ("__nargout__", true); + argn_sr = local_sym_tab->lookup ("argn", true); + nargin_sr = local_sym_tab->lookup ("__nargin__", true); + nargout_sr = local_sym_tab->lookup ("__nargout__", true); if (takes_varargs ()) - varargin_sr = sym_tab->lookup ("varargin", true); + varargin_sr = local_sym_tab->lookup ("varargin", true); } }
--- a/src/ov-usr-fcn.h +++ b/src/ov-usr-fcn.h @@ -195,6 +195,8 @@ tree_statement_list *body (void) { return cmd_list; } + symbol_table *sym_tab (void) { return local_sym_tab; } + octave_comment_list *leading_comment (void) { return lead_comm; } octave_comment_list *trailing_comment (void) { return trail_comm; } @@ -216,7 +218,7 @@ tree_statement_list *cmd_list; // The local symbol table for this function. - symbol_table *sym_tab; + symbol_table *local_sym_tab; // The comments preceding the FUNCTION token. octave_comment_list *lead_comm;
--- a/src/pt-fcn-handle.cc +++ b/src/pt-fcn-handle.cc @@ -72,7 +72,7 @@ } tree_expression * -tree_fcn_handle::dup (symbol_table *sym_tab) +tree_fcn_handle::dup (symbol_table *) { tree_fcn_handle *new_fh = new tree_fcn_handle (nm, line (), column ()); @@ -87,19 +87,16 @@ tw.visit_fcn_handle (*this); } -tree_anon_fcn_handle::~tree_anon_fcn_handle (void) -{ - delete param_list; - delete cmd_list; - delete ret_list; - delete sym_tab; -} - octave_value tree_anon_fcn_handle::rvalue (void) { MAYBE_DO_BREAKPOINT; + tree_parameter_list *param_list = fcn.parameter_list (); + tree_parameter_list *ret_list = fcn.return_list (); + tree_statement_list *cmd_list = fcn.body (); + symbol_table *sym_tab = fcn.sym_tab (); + symbol_table *new_sym_tab = sym_tab ? sym_tab->dup () : 0; if (new_sym_tab) @@ -120,9 +117,9 @@ uf->mark_as_inline_function (); - octave_value fcn (uf); + octave_value ov_fcn (uf); - octave_value fh (new octave_fcn_handle (fcn, "@<anonymous>")); + octave_value fh (new octave_fcn_handle (ov_fcn, "@<anonymous>")); return fh; } @@ -143,6 +140,11 @@ tree_expression * tree_anon_fcn_handle::dup (symbol_table *st) { + tree_parameter_list *param_list = fcn.parameter_list (); + tree_parameter_list *ret_list = fcn.return_list (); + tree_statement_list *cmd_list = fcn.body (); + symbol_table *sym_tab = fcn.sym_tab (); + symbol_table *new_sym_tab = sym_tab ? sym_tab->dup () : 0; if (new_sym_tab)
--- a/src/pt-fcn-handle.h +++ b/src/pt-fcn-handle.h @@ -37,6 +37,7 @@ class tree_walker; #include "ov.h" +#include "ov-usr-fcn.h" class tree_fcn_handle : public tree_expression @@ -89,16 +90,14 @@ public: tree_anon_fcn_handle (int l = -1, int c = -1) - : tree_expression (l, c), param_list (0), cmd_list (0), - ret_list (0), sym_tab (0) { } + : tree_expression (l, c), fcn () { } - tree_anon_fcn_handle (tree_parameter_list *p, tree_parameter_list *r, + tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl, tree_statement_list *cl, symbol_table *st, int l = -1, int c = -1) - : tree_expression (l, c), param_list (p), cmd_list (cl), - ret_list (r), sym_tab (st) { } + : tree_expression (l, c), fcn (pl, rl, cl, st) { } - ~tree_anon_fcn_handle (void); + ~tree_anon_fcn_handle (void) { } bool has_magic_end (void) const { return false; } @@ -108,9 +107,9 @@ octave_value_list rvalue (int nargout); - tree_parameter_list *parameter_list (void) { return param_list; } + tree_parameter_list *parameter_list (void) { return fcn.parameter_list (); } - tree_statement_list *body (void) { return cmd_list; } + tree_statement_list *body (void) { return fcn.body (); } tree_expression *dup (symbol_table *sym_tab); @@ -118,17 +117,8 @@ private: - // The parameter list. - tree_parameter_list *param_list; - - // The statement that makes up the body of the function. - tree_statement_list *cmd_list; - - // The list of return values. - tree_parameter_list *ret_list; - - // The symbol table. - symbol_table *sym_tab; + // The function. + octave_user_function fcn; // No copying!