diff libinterp/corefcn/symtab.cc @ 28437:8f3aedc5ab4f stable

split search for private functions into separate function * fcn-info.h, fcn-info.cc (fcn_info::fcn_info_rep::find_private_function): New function extracted from find_scoped_function. (fcn_info::fcn_info_rep::find_scoped_function): Use it. (fcn_info::find_private_function): New function. * symtab.h, symtab.cc (symbol_table::find_private_function): New function.
author John W. Eaton <jwe@octave.org>
date Tue, 09 Jun 2020 16:48:17 -0400
parents 22e90bdcf47f
children 0a5b15007766
line wrap: on
line diff
--- a/libinterp/corefcn/symtab.cc	Tue Jun 09 16:52:57 2020 -0400
+++ b/libinterp/corefcn/symtab.cc	Tue Jun 09 16:48:17 2020 -0400
@@ -95,6 +95,30 @@
       }
   }
 
+  octave_value
+  symbol_table::find_private_function (const std::string& dir_name,
+                                       const std::string& name)
+  {
+    if (name.empty ())
+      return octave_value ();
+
+    fcn_table_const_iterator p = m_fcn_table.find (name);
+
+    if (p != m_fcn_table.end ())
+      return p->second.find_private_function (dir_name);
+    else
+      {
+        fcn_info finfo (name);
+
+        octave_value fcn = finfo.find_private_function (dir_name);
+
+        if (fcn.is_defined ())
+          m_fcn_table[name] = finfo;
+
+        return fcn;
+      }
+  }
+
   // FIXME: this function only finds legacy class methods, not
   // classdef methods.