changeset 7942:db6478d9c669

out_of_date_check_internal: make it work for class methods
author John W. Eaton <jwe@octave.org>
date Thu, 17 Jul 2008 14:25:11 -0400
parents f8cab9eeb128
children 7b8aca1cdf0a
files src/ChangeLog src/symtab.cc src/toplev.h
diffstat 3 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Jul 17 10:56:22 2008 -0400
+++ b/src/ChangeLog	Thu Jul 17 14:25:11 2008 -0400
@@ -1,3 +1,11 @@
+2008-07-17  John W. Eaton  <jwe@octave.org>
+
+	* symtab.cc (out_of_date_check_internal): New arg, dispatch_type.
+	Use it to handle class methods.
+
+	* toplev.h (octave_call_stack::do_caller): New function.
+	(octave_call_stack::caller): Use it.
+
 2008-07-17  Jaroslav Hajek <highegg@gmail.com>
 
 	* Makefile.in (convhulln.oct, __delaunayn__.oct, __voronoi__.oct, 
--- a/src/symtab.cc	Thu Jul 17 10:56:22 2008 -0400
+++ b/src/symtab.cc	Thu Jul 17 14:25:11 2008 -0400
@@ -149,7 +149,8 @@
 }
 
 static inline bool
-out_of_date_check_internal (octave_value& function)
+out_of_date_check_internal (octave_value& function,
+			    const std::string& dispatch_type = std::string ())
 {
   bool retval = false;
 
@@ -186,14 +187,15 @@
 		    file = nm;
 		  else
 		    {
-		      // FIXME -- this lookup is not right since it doesn't
-		      // account for dispatch type.
-
 		      // We don't want to make this an absolute name,
 		      // because load_fcn_file looks at the name to
 		      // decide whether it came from a relative lookup.
 
-		      file = load_path::find_fcn (nm, dir_name);
+		      if (dispatch_type.empty ())
+			file = load_path::find_fcn (nm, dir_name);
+		      else
+			file = load_path::find_method (nm, dispatch_type,
+						       dir_name);
 		    }
 
 		  if (file.empty ())
@@ -477,7 +479,7 @@
       octave_value& fval = q->second;
 
       if (fval.is_defined ())
-	out_of_date_check_internal (fval);
+	out_of_date_check_internal (fval, name);
 
       if (fval.is_defined ())
 	return fval;
@@ -620,7 +622,7 @@
       octave_value& fval = q->second;
 
       if (fval.is_defined ())
-	out_of_date_check_internal (fval);
+	out_of_date_check_internal (fval, dispatch_type);
 
       if (fval.is_defined ())
 	return fval;
--- a/src/toplev.h	Thu Jul 17 10:56:22 2008 -0400
+++ b/src/toplev.h	Thu Jul 17 14:25:11 2008 -0400
@@ -157,7 +157,7 @@
   // Caller function, may be built-in.
   static octave_function *caller (void)
   {
-    return element (1);
+    return instance_ok () ? instance->do_caller () : 0;
   }
 
   static size_t current_frame (void)
@@ -286,6 +286,11 @@
 
   int do_caller_user_code_column (void) const;
 
+  octave_function *do_caller (void) const
+  {
+    return curr_frame > 1 ? cs[curr_frame-1].fcn : cs[0].fcn;
+  }
+
   size_t do_current_frame (void) { return curr_frame; }
 
   size_t do_size (void) { return cs.size (); }