changeset 8819:96d87674b818

also stash directory name for subfunctions
author John W. Eaton <jwe@octave.org>
date Fri, 20 Feb 2009 01:00:25 -0500
parents 8dee145c777d
children 89b95972e178
files src/ChangeLog src/parse.y src/symtab.cc src/symtab.h
diffstat 4 files changed, 49 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2009-02-20  John W. Eaton  <jwe@octave.org>
+
+	* 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  <highegg@gmail.com>
 
 	* ov-cell.h (octave_cell::cellstr_cache): New field.
--- a/src/parse.y
+++ b/src/parse.y
@@ -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");
 
--- a/src/symtab.cc
+++ b/src/symtab.cc
@@ -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<std::string, octave_value> 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,
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -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<std::string, symbol_record>::const_iterator table_const_iterator;