diff libinterp/corefcn/fcn-info.h @ 26845:6322d51c655c

allow function search in arbitrary scope * fcn-info.h, fcn-info.cc (fcn_info::builtin_find, fcn_info::find, fcn_info::find_function, fcn_info::fcn_info_rep::builtin_find, fcn_info::fcn_info_rep::find, fcn_info::fcn_info_rep::find_function, fcn_info::fcn_info_rep::xfind, fcn_info::fcn_info_rep::x_builtin_find): Pass scope as argument. (fcn_info::find, fcn_info::builtin_find): If given scope is valid, use it, otherwise default to current scope). (fcn_info::fcn_info_rep::xfind): Also search for subfunctions. * symtab.h, symtab.cc (symbol_table::builtin_find, symbol_table::fcn_table_find, symbol_table::find_function): Pass scope as argument. (symbol_table::find_function): Don't search for subfunctions. * symscope.h (symbol_scope::function, symbol_scope:symbol_scope_rep::function): Now const.
author John W. Eaton <jwe@octave.org>
date Tue, 05 Mar 2019 05:01:18 +0000
parents 98f1a964ff33
children 4ff25d9b1eec
line wrap: on
line diff
--- a/libinterp/corefcn/fcn-info.h	Tue Mar 05 23:26:05 2019 +0100
+++ b/libinterp/corefcn/fcn-info.h	Tue Mar 05 05:01:18 2019 +0000
@@ -33,6 +33,7 @@
 
 #include "ov.h"
 #include "ovl.h"
+#include "symscope.h"
 
 namespace octave
 {
@@ -79,9 +80,10 @@
 
       octave_value load_class_method (const std::string& dispatch_type);
 
-      octave_value find (const octave_value_list& args);
+      octave_value find (const octave_value_list& args,
+                         const symbol_scope& search_scope);
 
-      octave_value builtin_find (void);
+      octave_value builtin_find (const symbol_scope& search_scope);
 
       octave_value find_method (const std::string& dispatch_type);
 
@@ -101,9 +103,10 @@
         return package.is_defined ();
       }
 
-      octave_value find_function (const octave_value_list& args)
+      octave_value find_function (const octave_value_list& args,
+                                  const symbol_scope& search_scope)
       {
-        return find (args);
+        return find (args, search_scope);
       }
 
       void install_cmdline_function (const octave_value& f)
@@ -229,9 +232,10 @@
 
     private:
 
-      octave_value xfind (const octave_value_list& args);
+      octave_value xfind (const octave_value_list& args,
+                          const symbol_scope& search_scope);
 
-      octave_value x_builtin_find (void);
+      octave_value x_builtin_find (const symbol_scope& search_scope);
     };
 
   public:
@@ -245,14 +249,16 @@
 
     ~fcn_info (void) = default;
 
-    octave_value find (const octave_value_list& args = octave_value_list ())
+    octave_value find (const octave_value_list& args = octave_value_list (),
+                       const symbol_scope& search_scope = symbol_scope ())
     {
-      return m_rep->find (args);
+      return m_rep->find (args, search_scope);
     }
 
-    octave_value builtin_find (void)
+    octave_value
+    builtin_find (const symbol_scope& search_scope = symbol_scope ())
     {
-      return m_rep->builtin_find ();
+      return m_rep->builtin_find (search_scope);
     }
 
     octave_value find_method (const std::string& dispatch_type) const
@@ -275,6 +281,7 @@
       return m_rep->find_autoload ();
     }
 
+    // FIXME: find_function_on_path might be a better name?
     octave_value find_user_function (void)
     {
       return m_rep->find_user_function ();
@@ -290,10 +297,11 @@
       return m_rep->is_package_defined ();
     }
 
-    octave_value find_function (const octave_value_list& args
-                                = octave_value_list ())
+    octave_value
+    find_function (const octave_value_list& args = octave_value_list (),
+                   const symbol_scope& search_scope = symbol_scope ())
     {
-      return m_rep->find_function (args);
+      return m_rep->find_function (args, search_scope);
     }
 
     void install_cmdline_function (const octave_value& f)