# HG changeset patch # User John W. Eaton # Date 1235109625 18000 # Node ID 96d87674b818f72f34da798ca3e19ef569a9aadb # Parent 8dee145c777d0e8009837e1ecec6560b0ce19cca also stash directory name for subfunctions diff -r 8dee145c777d -r 96d87674b818 src/ChangeLog --- a/src/ChangeLog Thu Feb 19 16:26:27 2009 -0500 +++ b/src/ChangeLog Fri Feb 20 01:00:25 2009 -0500 @@ -1,3 +1,10 @@ +2009-02-20 John W. Eaton + + * symbtab.cc (symbol_table::stash_dir_name_for_subfunctions): + New function. + * symtab.h: Provide decl. + * parse.y (load_fcn_from_file): Call it after parsing a function. + 2009-02-19 Jaroslav Hajek * ov-cell.h (octave_cell::cellstr_cache): New field. diff -r 8dee145c777d -r 96d87674b818 src/parse.y --- a/src/parse.y Thu Feb 19 16:26:27 2009 -0500 +++ b/src/parse.y Fri Feb 20 01:00:25 2009 -0500 @@ -3377,7 +3377,16 @@ } if (retval) - retval->stash_dir_name (dir_name); + { + retval->stash_dir_name (dir_name); + + if (retval->is_user_function ()) + { + symbol_table::scope_id id = retval->scope (); + + symbol_table::stash_dir_name_for_subfunctions (id, dir_name); + } + } unwind_protect::run_frame ("load_fcn_from_file"); diff -r 8dee145c777d -r 96d87674b818 src/symtab.cc --- a/src/symtab.cc Thu Feb 19 16:26:27 2009 -0500 +++ b/src/symtab.cc Fri Feb 20 01:00:25 2009 -0500 @@ -36,6 +36,7 @@ #include "load-path.h" #include "symtab.h" #include "ov-fcn.h" +#include "ov-usr-fcn.h" #include "pager.h" #include "parse.h" #include "pt-arg-list.h" @@ -1078,6 +1079,34 @@ } } +void +symbol_table::stash_dir_name_for_subfunctions (scope_id scope, + const std::string& dir_name) +{ + // FIXME -- is this the best way to do this? Maybe it would be + // better if we had a map from scope to list of subfunctions + // stored with the function. Do we? + + for (fcn_table_const_iterator p = fcn_table.begin (); + p != fcn_table.end (); p++) + { + std::pair tmp + = p->second.subfunction_defined_in_scope (scope); + + std::string nm = tmp.first; + + if (! nm.empty ()) + { + octave_value& fcn = tmp.second; + + octave_user_function *f = fcn.user_function_value (); + + if (f) + f->stash_dir_name (dir_name); + } + } +} + octave_value symbol_table::do_find (const std::string& name, tree_argument_list *args, const string_vector& arg_names, diff -r 8dee145c777d -r 96d87674b818 src/symtab.h --- a/src/symtab.h Thu Feb 19 16:26:27 2009 -0500 +++ b/src/symtab.h Fri Feb 20 01:00:25 2009 -0500 @@ -1788,6 +1788,9 @@ symbol_table::scope_id_cache::free (scope); } + static void stash_dir_name_for_subfunctions (scope_id scope, + const std::string& dir_name); + private: typedef std::map::const_iterator table_const_iterator;