changeset 27594:e091e09d26f0

restore some symbol table functions for backward compatibility These functions were removed from the public interface before being deprecated. * interpreter.h, interpreter.cc (interpreter::top_level_variable_names): New function. * pt-eval.h, pt-eval.cc (tree_evaluator::top_level_variable_names): New function. * call-stack.h, call-stack.cc (call_stack::top_level_variable_names): New function. * symtab.h, symtab.cc (symbol_table::at_top_level, symbol_table::varval, symbol_table::global_varval, symbol_table::top_level_varval, symbol_table::global_variable_names, symbol_table::top_level_variable_names, symbol_table::variable_names, symbol_table::assign, symbol_table::clear_all, symbol_table::clear_global, symbol_table::clear_global_pattern, symbol_table::clear_symbol, symbol_table::clear_symbol_pattern, symbol_table::global_assign, symbol_table::top_level_assign): New functions.
author John W. Eaton <jwe@octave.org>
date Thu, 31 Oct 2019 00:51:45 -0400
parents a2db1e36e9b2
children 92e829d0a63b
files libinterp/corefcn/call-stack.cc libinterp/corefcn/call-stack.h libinterp/corefcn/interpreter.cc libinterp/corefcn/interpreter.h libinterp/corefcn/symtab.cc libinterp/corefcn/symtab.h libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h
diffstat 8 files changed, 182 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/corefcn/call-stack.cc	Thu Oct 31 00:51:45 2019 -0400
@@ -735,11 +735,6 @@
     return m_cs[m_curr_frame]->regexp (pattern);
   }
 
-  std::list<std::string> call_stack::variable_names (void) const
-  {
-    return m_cs[m_curr_frame]->variable_names ();
-  }
-
   std::list<std::string> call_stack::global_variable_names (void) const
   {
     std::list<std::string> retval;
@@ -755,6 +750,16 @@
     return retval;
   }
 
+  std::list<std::string> call_stack::top_level_variable_names (void) const
+  {
+    return m_cs[0]->variable_names ();
+  }
+
+  std::list<std::string> call_stack::variable_names (void) const
+  {
+    return m_cs[m_curr_frame]->variable_names ();
+  }
+
   void call_stack::clear_global_variable (const std::string& name)
   {
     auto p = m_global_values.find (name);
--- a/libinterp/corefcn/call-stack.h	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/corefcn/call-stack.h	Thu Oct 31 00:51:45 2019 -0400
@@ -261,9 +261,11 @@
 
     std::list<symbol_record> regexp (const std::string& pattern) const;
 
-    std::list<std::string> variable_names (void) const;
+    std::list<std::string> global_variable_names (void) const;
 
-    std::list<std::string> global_variable_names (void) const;
+    std::list<std::string> top_level_variable_names (void) const;
+
+    std::list<std::string> variable_names (void) const;
 
     void clear_global_variable (const std::string& name);
 
--- a/libinterp/corefcn/interpreter.cc	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/corefcn/interpreter.cc	Thu Oct 31 00:51:45 2019 -0400
@@ -1693,6 +1693,11 @@
     return m_evaluator.global_variable_names ();
   }
 
+  std::list<std::string> interpreter::top_level_variable_names (void)
+  {
+    return m_evaluator.top_level_variable_names ();
+  }
+
   std::list<std::string> interpreter::variable_names (void)
   {
     return m_evaluator.variable_names ();
--- a/libinterp/corefcn/interpreter.h	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/corefcn/interpreter.h	Thu Oct 31 00:51:45 2019 -0400
@@ -421,9 +421,11 @@
 
     void clear_symbol_regexp (const std::string& pat);
 
-    std::list<std::string> global_variable_names (void);
+    std::list<std::string> variable_names (void);
 
-    std::list<std::string> variable_names (void);
+    std::list<std::string> top_level_variable_names (void);
+
+    std::list<std::string> global_variable_names (void);
 
     std::list<std::string> user_function_names (void);
 
--- a/libinterp/corefcn/symtab.cc	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/corefcn/symtab.cc	Thu Oct 31 00:51:45 2019 -0400
@@ -634,6 +634,98 @@
 
     return octave_value (info_map);
   }
+
+  // DEPRECATED
+  bool symbol_table::at_top_level (void)
+  {
+    return m_interpreter.at_top_level ();
+  }
+
+  // DEPRECATED
+  octave_value symbol_table::varval (const std::string& name) const
+  {
+    return m_interpreter.varval (name);
+  }
+
+  // DEPRECATED
+  octave_value symbol_table::global_varval (const std::string& name) const
+  {
+    return m_interpreter.global_varval (name);
+  }
+
+  // DEPRECATED
+  octave_value symbol_table::top_level_varval (const std::string& name) const
+  {
+    return m_interpreter.top_level_varval (name);
+  }
+
+  // DEPRECATED
+  std::list<std::string> symbol_table::global_variable_names (void)
+  {
+    return m_interpreter.global_variable_names ();
+  }
+
+  // DEPRECATED
+  std::list<std::string> symbol_table::top_level_variable_names (void)
+  {
+    return m_interpreter.top_level_variable_names ();
+  }
+
+  // DEPRECATED
+  std::list<std::string> symbol_table::variable_names (void)
+  {
+    return m_interpreter.variable_names ();
+  }
+
+  // DEPRECATED
+  void symbol_table::assign (const std::string& name, const octave_value& value)
+  {
+    return m_interpreter.assign (name, value);
+  }
+
+  // DEPRECATED
+  void symbol_table::clear_all (bool force)
+  {
+    return m_interpreter.clear_all (force);
+  }
+
+  // DEPRECATED
+  void symbol_table::clear_global (const std::string& name)
+  {
+    return m_interpreter.clear_global_variable (name);
+  }
+
+  // DEPRECATED
+  void symbol_table::clear_global_pattern (const std::string& pattern)
+  {
+    return m_interpreter.clear_global_variable_pattern (pattern);
+  }
+
+  // DEPRECATED
+  void symbol_table::clear_symbol (const std::string& name)
+  {
+    return m_interpreter.clear_symbol (name);
+  }
+
+  // DEPRECATED
+  void symbol_table::clear_symbol_pattern (const std::string& pattern)
+  {
+    return m_interpreter.clear_symbol_pattern (pattern);
+  }
+
+  // DEPRECATED
+  void symbol_table::global_assign (const std::string& name,
+                                    const octave_value& value)
+  {
+    return m_interpreter.global_assign (name, value);
+  }
+
+  // DEPRECATED
+  void symbol_table::top_level_assign (const std::string& name,
+                                       const octave_value& value)
+  {
+    return m_interpreter.top_level_assign (name, value);
+  }
 }
 
 DEFMETHOD (__dump_symtab_info__, interp, args, ,
--- a/libinterp/corefcn/symtab.h	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/corefcn/symtab.h	Thu Oct 31 00:51:45 2019 -0400
@@ -46,6 +46,8 @@
 
 namespace octave
 {
+  class interpreter;
+
   class OCTINTERP_API symbol_table
   {
   public:
@@ -177,6 +179,64 @@
 
     fcn_info * get_fcn_info (const std::string& name);
 
+    // The remaining functions are all provided for backward
+    // compatibility.  New code should use the functions provided by the
+    // interpreter class.
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::at_top_level' instead")
+    bool at_top_level (void);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::varval' instead")
+    octave_value varval (const std::string& name) const;
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::global_varval' instead")
+    octave_value global_varval (const std::string& name) const;
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::top_level_varval' instead")
+    octave_value top_level_varval (const std::string& name) const;
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::global_variable_names' instead")
+    std::list<std::string> global_variable_names (void);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::top_level_variable_names' instead")
+    std::list<std::string> top_level_variable_names (void);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::variable_names' instead")
+    std::list<std::string> variable_names (void);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::assign' instead")
+    void assign (const std::string& name, const octave_value& value = octave_value ());
+
+    // Note, FORCE_ADD no longer has any meaning.
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::assign' instead")
+    void assign (const std::string& name, const octave_value& value, bool /*force_add*/)
+    {
+      assign (name, value);
+    }
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::clear_all' instead")
+    void clear_all (bool force = false);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::clear_global' instead")
+    void clear_global (const std::string& name);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::clear_global_pattern' instead")
+    void clear_global_pattern (const std::string& pattern);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::clear_symbol' instead")
+    void clear_symbol (const std::string& name);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::clear_symbol_pattern' instead")
+    void clear_symbol_pattern (const std::string& pattern);
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::global_assign' instead")
+    void global_assign (const std::string& name,
+                        const octave_value& value = octave_value ());
+
+    // OCTAVE_DEPRECATED (V, "use 'interpreter::top_level_assign' instead")
+    void top_level_assign (const std::string& name,
+                           const octave_value& value = octave_value ());
+
   private:
 
     interpreter& m_interpreter;
--- a/libinterp/parse-tree/pt-eval.cc	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Oct 31 00:51:45 2019 -0400
@@ -1873,6 +1873,11 @@
     return m_call_stack.global_variable_names ();
   }
 
+  std::list<std::string> tree_evaluator::top_level_variable_names (void) const
+  {
+    return m_call_stack.top_level_variable_names ();
+  }
+
   std::list<std::string> tree_evaluator::variable_names (void) const
   {
     return m_call_stack.variable_names ();
--- a/libinterp/parse-tree/pt-eval.h	Wed Oct 30 15:19:07 2019 -0700
+++ b/libinterp/parse-tree/pt-eval.h	Thu Oct 31 00:51:45 2019 -0400
@@ -506,6 +506,8 @@
 
     std::list<std::string> global_variable_names (void) const;
 
+    std::list<std::string> top_level_variable_names (void) const;
+
     std::list<std::string> variable_names (void) const;
 
     octave_user_code * get_user_code (const std::string& fname = "",