Mercurial > octave
diff libinterp/octave-value/cdef-class.cc @ 27189:946c6f117091
use dummy stack frame when creating meta class (bug #55766 and #55768)
* pt-classdef.h (tree_classdef::m_scope): New data member.
(tree_classdef::tree_classdef): New arg, SCOPE.
* oct-parse.yy (base_parser::make_classdef): Pass current dummy scope
to tree_classdef constructor.
* cdef_class.cc (cdef_class::make_meta_class): Push dummy stack frame
when for expression evaluation while creating meta class object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 15 Jun 2019 11:04:52 -0500 |
parents | c776d553c19e |
children | 823b4bcf79fc |
line wrap: on
line diff
--- a/libinterp/octave-value/cdef-class.cc Fri Jun 14 15:34:44 2019 -0500 +++ b/libinterp/octave-value/cdef-class.cc Sat Jun 15 11:04:52 2019 -0500 @@ -49,6 +49,7 @@ #include "pt-misc.h" #include "pt-stmt.h" #include "pt-walk.h" +#include "unwind-prot.h" // Define to 1 to enable debugging statements. #define DEBUG_TRACE 0 @@ -861,6 +862,18 @@ std::cerr << "class: " << full_class_name << std::endl; #endif + // Push a dummy scope frame on the call stack that corresponds to + // the scope that was used when parsing classdef object. Without + // this, we may pick up stray values from the current scope when + // evaluating expressions found in things like attribute lists. + + unwind_protect frame; + + tree_evaluator& tw = interp.get_evaluator (); + + tw.push_dummy_scope (full_class_name); + frame.add_method (tw, &octave::tree_evaluator::pop_scope); + std::list<cdef_class> slist; if (t->superclass_list ()) @@ -899,8 +912,6 @@ // Class attributes - tree_evaluator& tw = interp.get_evaluator (); - if (t->attribute_list ()) { for (const auto& attr : (*t->attribute_list ()))