changeset 26824:d9770844392e

provide virtual dup methods for stack frames * stack-frame.h, stack-frame.cc (stack_frame::dup): New pure virtual. (compiled_fcn_stack_frame::dup, script_stack_frame::dup, user_fcn_stack_frame::dup, scope_stack_frame::dup): New functions.
author John W. Eaton <jwe@octave.org>
date Sun, 03 Mar 2019 07:08:52 +0000
parents 414685784cd3
children 6e9034836239
files libinterp/corefcn/stack-frame.cc libinterp/corefcn/stack-frame.h
diffstat 2 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/stack-frame.cc	Sat Mar 02 16:34:33 2019 +0000
+++ b/libinterp/corefcn/stack-frame.cc	Sun Mar 03 07:08:52 2019 +0000
@@ -518,6 +518,12 @@
       }
   }
 
+  compiled_fcn_stack_frame *
+  compiled_fcn_stack_frame::dup (void) const
+  {
+    return new compiled_fcn_stack_frame (*this);
+  }
+
   void compiled_fcn_stack_frame::display (bool follow) const
   {
     std::ostream& os = octave_stdout;
@@ -547,6 +553,12 @@
     set_script_offsets ();
   }
 
+  script_stack_frame *
+  script_stack_frame::dup (void) const
+  {
+    return new script_stack_frame (*this);
+  }
+
   size_t script_stack_frame::get_num_symbols (octave_user_script *script)
   {
     symbol_scope script_scope = script->scope ();
@@ -1087,6 +1099,12 @@
       }
   }
 
+  user_fcn_stack_frame *
+  user_fcn_stack_frame::dup (void) const
+  {
+    return new user_fcn_stack_frame (*this);
+  }
+
   // If this is a nested scope, set access_link to nearest parent
   // stack frame that corresponds to the lexical parent of this scope.
 
@@ -1358,6 +1376,12 @@
     sfw.visit_user_fcn_stack_frame (*this);
   }
 
+  scope_stack_frame *
+  scope_stack_frame::dup (void) const
+  {
+    return new scope_stack_frame (*this);
+  }
+
   symbol_record scope_stack_frame::insert_symbol (const std::string& name)
   {
     // There is no access link for scope frames, so there is no other
--- a/libinterp/corefcn/stack-frame.h	Sat Mar 02 16:34:33 2019 +0000
+++ b/libinterp/corefcn/stack-frame.h	Sun Mar 03 07:08:52 2019 +0000
@@ -152,6 +152,8 @@
 
     virtual ~stack_frame (void) = default;
 
+    virtual stack_frame * dup (void) const = 0;
+
     // FIXME: It would be nice to eliminate these but there are a few
     // places where we still need to know the specific type of the
     // stack frame that we are handling.
@@ -580,6 +582,8 @@
 
     ~compiled_fcn_stack_frame (void) = default;
 
+    compiled_fcn_stack_frame * dup (void) const;
+
     bool is_compiled_fcn_frame (void) const { return true; }
 
     symbol_scope get_scope (void) const
@@ -690,6 +694,8 @@
 
     ~script_stack_frame (void) = default;
 
+    script_stack_frame * dup (void) const;
+
     bool is_user_script_frame (void) const { return true; }
 
     static stack_frame * get_access_link (stack_frame *static_link);
@@ -895,6 +901,8 @@
 
     ~user_fcn_stack_frame (void) = default;
 
+    user_fcn_stack_frame * dup (void) const;
+
     bool is_user_fcn_frame (void) const { return true; }
 
     static stack_frame *
@@ -969,6 +977,8 @@
 
     ~scope_stack_frame (void) = default;
 
+    scope_stack_frame * dup (void) const;
+
     bool is_scope_frame (void) const { return true; }
 
     symbol_scope get_scope (void) const { return m_scope; }