changeset 28330:cf20fd68305e

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Mon, 18 May 2020 16:15:25 -0400
parents bb47f604dfea (current diff) 6349915869f2 (diff)
children be3dab3212e9
files
diffstat 4 files changed, 45 insertions(+), 109 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc	Mon May 18 20:52:05 2020 +0200
+++ b/libinterp/corefcn/call-stack.cc	Mon May 18 16:15:25 2020 -0400
@@ -751,16 +751,6 @@
     return m_cs[m_curr_frame]->all_variables ();
   }
 
-  std::list<symbol_record> call_stack::glob (const std::string& pattern) const
-  {
-    return m_cs[m_curr_frame]->glob (pattern);
-  }
-
-  std::list<symbol_record> call_stack::regexp (const std::string& pattern) const
-  {
-    return m_cs[m_curr_frame]->regexp (pattern);
-  }
-
   std::list<std::string> call_stack::global_variable_names (void) const
   {
     std::list<std::string> retval;
@@ -831,7 +821,7 @@
   symbol_info_list
   call_stack::regexp_symbol_info (const std::string& pattern) const
   {
-    return m_cs[m_curr_frame]->glob_symbol_info (pattern);
+    return m_cs[m_curr_frame]->regexp_symbol_info (pattern);
   }
 
   symbol_info_list call_stack::get_symbol_info (void)
--- a/libinterp/corefcn/call-stack.h	Mon May 18 20:52:05 2020 +0200
+++ b/libinterp/corefcn/call-stack.h	Mon May 18 16:15:25 2020 -0400
@@ -250,10 +250,6 @@
 
     symbol_info_list all_variables (void);
 
-    std::list<symbol_record> glob (const std::string& pattern) const;
-
-    std::list<symbol_record> regexp (const std::string& pattern) const;
-
     std::list<std::string> global_variable_names (void) const;
 
     std::list<std::string> top_level_variable_names (void) const;
--- a/libinterp/corefcn/stack-frame.cc	Mon May 18 20:52:05 2020 +0200
+++ b/libinterp/corefcn/stack-frame.cc	Mon May 18 16:15:25 2020 -0400
@@ -247,6 +247,27 @@
     panic_impossible ();
   }
 
+  symbol_info_list
+  stack_frame::make_symbol_info_list (const std::list<symbol_record>& symrec_list) const
+  {
+    symbol_info_list symbol_stats;
+
+    for (const auto& sym : symrec_list)
+      {
+        octave_value value = varval (sym);
+
+        if (value.is_defined ())
+          {
+            symbol_info syminf (sym.name (), value, sym.is_formal (),
+                                is_global (sym), is_persistent (sym));
+
+            symbol_stats.append (syminf);
+          }
+      }
+
+    return symbol_stats;
+  }
+
   // Return first occurrence of variables in current stack frame and any
   // parent frames reachable through access links.
 
@@ -259,59 +280,8 @@
     return sia.symbol_info ();
   }
 
-  std::list<symbol_record>
-  stack_frame::glob (const std::string& pattern) const
-  {
-    std::list<symbol_record> retval;
-
-    symbol_scope scope = get_scope ();
-
-    const std::map<std::string, symbol_record>& symbols = scope.symbols ();
-
-    glob_match pat (pattern);
-
-    for (const auto& nm_sr : symbols)
-      {
-        if (pat.match (nm_sr.first))
-          {
-            symbol_record sr = nm_sr.second;
-
-            if (! is_variable (sr))
-              continue;
-
-            retval.push_back (sr);
-          }
-      }
-
-    return retval;
-  }
-
-  std::list<symbol_record>
-  stack_frame::regexp (const std::string& pattern) const
-  {
-    std::list<symbol_record> retval;
-
-    symbol_scope scope = get_scope ();
-
-    const std::map<std::string, symbol_record>& symbols = scope.symbols ();
-
-    octave::regexp pat (pattern);
-
-    for (const auto& nm_sr : symbols)
-      {
-        if (pat.is_match (nm_sr.first))
-          {
-            symbol_record sr = nm_sr.second;
-
-            if (! is_variable (sr))
-              continue;
-
-            retval.push_back (sr);
-          }
-      }
-
-    return retval;
-  }
+  // FIXME: Should this function also find any variables in parent
+  // scopes accessible through access_links?
 
   std::list<std::string> stack_frame::variable_names (void) const
   {
@@ -332,6 +302,24 @@
     return retval;
   }
 
+  symbol_info_list stack_frame::glob_symbol_info (const std::string& pattern)
+  {
+    symbol_info_accumulator sia (pattern, false);
+
+    accept (sia);
+
+    return sia.symbol_info ();
+  }
+
+  symbol_info_list stack_frame::regexp_symbol_info (const std::string& pattern)
+  {
+    symbol_info_accumulator sia (pattern, true);
+
+    accept (sia);
+
+    return sia.symbol_info ();
+  }
+
   size_t stack_frame::size (void) const
   {
     // This function should only be called for user_fcn_stack_frame or
--- a/libinterp/corefcn/stack-frame.h	Mon May 18 20:52:05 2020 +0200
+++ b/libinterp/corefcn/stack-frame.h	Mon May 18 16:15:25 2020 -0400
@@ -215,39 +215,11 @@
     virtual unwind_protect *
     unwind_protect_frame (void) const { return nullptr; }
 
-    // FIXME: Should this function be private?
-
     symbol_info_list
-    make_symbol_info_list (const std::list<symbol_record>& symrec_list) const
-    {
-      symbol_info_list symbol_stats;
-
-      for (const auto& sym : symrec_list)
-        {
-          octave_value value = varval (sym);
-
-          if (value.is_defined ())
-            {
-              symbol_info syminf (sym.name (), value, sym.is_formal (),
-                                  is_global (sym), is_persistent (sym));
-
-              symbol_stats.append (syminf);
-            }
-        }
-
-      return symbol_stats;
-    }
+    make_symbol_info_list (const std::list<symbol_record>& symrec_list) const;
 
     symbol_info_list all_variables (void);
 
-    // FIXME: Should these exist?  Probably we should avoid returning
-    // lists of symbol_record objects, so maybe they should be
-    // private functions?
-
-    std::list<symbol_record> glob (const std::string& pattern) const;
-
-    std::list<symbol_record> regexp (const std::string& pattern) const;
-
     std::list<std::string> variable_names (void) const;
 
     // Look for named symbol visible from current scope.  Don't
@@ -258,19 +230,9 @@
     // insert if missing.
     virtual symbol_record insert_symbol (const std::string&) = 0;
 
-    // FIXME: should these functions should return all symbols visible in
-    // the current stack frame including those that come from a parent
-    // scope/frame?
+    symbol_info_list glob_symbol_info (const std::string& pattern);
 
-    symbol_info_list glob_symbol_info (const std::string& pattern) const
-    {
-      return make_symbol_info_list (glob (pattern));
-    }
-
-    symbol_info_list regexp_symbol_info (const std::string& pattern) const
-    {
-      return make_symbol_info_list (regexp (pattern));
-    }
+    symbol_info_list regexp_symbol_info (const std::string& pattern);
 
     symbol_info_list get_symbol_info (void)
     {