changeset 26965:be5c2a1bad93

allow dispatch class to be stored in stack frame (bug #45351) * call-stack.h, call-stack.cc (call_stack::get_dispatch_class, call_stack::set_dispatch_class): New methods. * stack-frame.h (stack_frame::m_dispatch_class): New data member. (stack_frame::get_dispatch_class, stack_frame::set_dispatch_class): New methods.
author John W. Eaton <jwe@octave.org>
date Mon, 25 Mar 2019 16:13:01 +0000
parents b57d596b909b
children 4ba365817652
files libinterp/corefcn/call-stack.cc libinterp/corefcn/call-stack.h libinterp/corefcn/stack-frame.h
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc	Mon Mar 25 10:56:14 2019 +0000
+++ b/libinterp/corefcn/call-stack.cc	Mon Mar 25 16:13:01 2019 +0000
@@ -354,6 +354,16 @@
     return retval;
   }
 
+  std::string call_stack::get_dispatch_class (void) const
+  {
+    return m_cs[m_curr_frame]->get_dispatch_class ();
+  }
+
+  void call_stack::set_dispatch_class (const std::string& class_name)
+  {
+    m_cs[m_curr_frame]->set_dispatch_class (class_name);
+  }
+
   bool call_stack::is_class_method_executing (std::string& dispatch_class) const
   {
     dispatch_class = "";
--- a/libinterp/corefcn/call-stack.h	Mon Mar 25 10:56:14 2019 +0000
+++ b/libinterp/corefcn/call-stack.h	Mon Mar 25 16:13:01 2019 +0000
@@ -154,6 +154,10 @@
     // Column number in current function that we are debugging.
     int debug_user_code_column (void) const;
 
+    std::string get_dispatch_class (void) const;
+
+    void set_dispatch_class (const std::string& class_name);
+
     bool is_class_method_executing (std::string& dispatch_class) const;
 
     bool is_class_constructor_executing (std::string& dispatch_class) const;
--- a/libinterp/corefcn/stack-frame.h	Mon Mar 25 10:56:14 2019 +0000
+++ b/libinterp/corefcn/stack-frame.h	Mon Mar 25 16:13:01 2019 +0000
@@ -143,7 +143,8 @@
     stack_frame (call_stack& cs, size_t prev, stack_frame *static_link,
                  stack_frame *access_link)
       : m_call_stack (cs), m_line (-1), m_column (-1), m_prev (prev),
-        m_static_link (static_link), m_access_link (access_link)
+        m_static_link (static_link), m_access_link (access_link),
+        m_dispatch_class ()
     { }
 
     stack_frame (const stack_frame& elt) = default;
@@ -536,6 +537,13 @@
 
     void clear_variables (void);
 
+    std::string get_dispatch_class (void) const { return m_dispatch_class; }
+
+    void set_dispatch_class (const std::string& class_name)
+    {
+      m_dispatch_class = class_name;
+    }
+
     virtual void mark_scope (const symbol_record&, scope_flags) = 0;
 
     virtual void display (bool follow = true) const;
@@ -567,6 +575,10 @@
     // non-local variables for nested and anonymous functions or as a
     // link to the parent frame in which a script is executed.
     stack_frame *m_access_link;
+
+    // Allow function handles to temporarily store their dispatch class
+    // in the call stack.
+    std::string m_dispatch_class;
   };
 
   class compiled_fcn_stack_frame : public stack_frame