diff libinterp/octave-value/ov-usr-fcn.h @ 24361:8bcfddad15ec

use shared_ptr to manage symbol_scope objects * symscope.h, symscope.cc (symbol_scope_rep): New class, renamed and adapted from symbol_scope. (symbol_scope): New class to manage symbol_scope_rep with shared_ptr. Change all uses of pointers ot symbol_scope objects to be symbol_scope objects or, in a few cases, pointers to symbol_scope_rep objects instead.
author John W. Eaton <jwe@octave.org>
date Mon, 27 Nov 2017 01:12:05 -0500
parents d22d2936f580
children 3fc24b792a24
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.h	Tue Dec 05 11:35:11 2017 -0800
+++ b/libinterp/octave-value/ov-usr-fcn.h	Mon Nov 27 01:12:05 2017 -0500
@@ -61,7 +61,7 @@
 protected:
 
   octave_user_code (const std::string& nm,
-                    octave::symbol_scope *scope = nullptr,
+                    const octave::symbol_scope& scope = octave::symbol_scope (),
                     const std::string& ds = "")
     : octave_function (nm, ds), m_scope (scope), m_file_info (nullptr),
       curr_unwind_protect_frame (nullptr)
@@ -70,7 +70,7 @@
 public:
 
   octave_user_code (void)
-    : octave_function (), m_scope (nullptr), m_file_info (nullptr),
+    : octave_function (), m_scope (), m_file_info (nullptr),
       curr_unwind_protect_frame (nullptr)
   { }
 
@@ -97,7 +97,7 @@
   void cache_function_text (const std::string& text,
                             const octave::sys::time& timestamp);
 
-  octave::symbol_scope *scope (void) { return m_scope; }
+  octave::symbol_scope scope (void) { return m_scope; }
 
   virtual std::map<std::string, octave_value> subfunctions (void) const;
 
@@ -108,7 +108,7 @@
   void get_file_info (void);
 
   // Our symbol table scope.
-  octave::symbol_scope *m_scope;
+  octave::symbol_scope m_scope;
 
   // Cached text of function or script code with line offsets
   // calculated.
@@ -128,12 +128,12 @@
   octave_user_script (void);
 
   octave_user_script (const std::string& fnm, const std::string& nm,
-                      octave::symbol_scope *scope = nullptr,
+                      const octave::symbol_scope& scope = octave::symbol_scope (),
                       octave::tree_statement_list *cmds = nullptr,
                       const std::string& ds = "");
 
   octave_user_script (const std::string& fnm, const std::string& nm,
-                      octave::symbol_scope *scope = nullptr,
+                      const octave::symbol_scope& scope = octave::symbol_scope (),
                       const std::string& ds = "");
 
   // No copying!
@@ -207,7 +207,7 @@
 {
 public:
 
-  octave_user_function (octave::symbol_scope *scope = nullptr,
+  octave_user_function (const octave::symbol_scope& scope = octave::symbol_scope (),
                         octave::tree_parameter_list *pl = nullptr,
                         octave::tree_parameter_list *rl = nullptr,
                         octave::tree_statement_list *cl = nullptr);
@@ -260,7 +260,7 @@
 
   void stash_parent_fcn_name (const std::string& p) { parent_name = p; }
 
-  void stash_parent_fcn_scope (octave::symbol_scope *ps);
+  void stash_parent_fcn_scope (const octave::symbol_scope& ps);
 
   void stash_leading_comment (octave::comment_list *lc) { lead_comm = lc; }
 
@@ -280,7 +280,7 @@
 
   std::string parent_fcn_name (void) const { return parent_name; }
 
-  octave::symbol_scope *
+  octave::symbol_scope
   parent_fcn_scope (void) const { return parent_scope; }
 
   octave::sys::time time_parsed (void) const { return t_parsed; }
@@ -481,7 +481,7 @@
   bool class_method;
 
   // The scope of the parent function, if any.
-  octave::symbol_scope *parent_scope;
+  octave::symbol_scope parent_scope;
 
 #if defined (HAVE_LLVM)
   octave::jit_function_info *jit_info;