Mercurial > octave
changeset 24348:64691264dd21
eliminate some uses of decl_scope in symbol_record class
* symrec.cc, symrec.h (symbol_record::clear (void)): Delete.
(symbol_record::clear (symbol_scope *),
symbol_record_rep::clear (symbol_scope *)):
Eliminate argument. Change all uses.
(symbol_record_rep::push_context, symbol_record_rep::pop_context):
Eliminate symbol_scope argument. Change all uses. Eliminate call for
fwd_rep.
(symbol_record::push_context, symbol_record::pop_context):
Eliminate symbol_scope argument. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Nov 2017 12:43:25 -0500 |
parents | 222addbadf46 |
children | 4ced2bfd737e |
files | libinterp/corefcn/symrec.cc libinterp/corefcn/symrec.h libinterp/corefcn/symscope.h |
diffstat | 3 files changed, 40 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/symrec.cc Sun Dec 03 12:37:13 2017 +0100 +++ b/libinterp/corefcn/symrec.cc Tue Nov 28 12:43:25 2017 -0500 @@ -48,28 +48,6 @@ } void - symbol_record::symbol_record_rep::clear (symbol_scope *sid) - { - if (auto t_fwd_rep = m_fwd_rep.lock ()) - { - t_fwd_rep->clear (sid); - return; - } - - if (! (is_hidden () || is_inherited ()) - && sid == decl_scope ()) - { - if (is_global ()) - unmark_global (); - - assign (octave_value ()); - - if (is_persistent ()) - unmark_persistent (); - } - } - - void symbol_record::symbol_record_rep::init_persistent (void) { if (auto t_fwd_rep = m_fwd_rep.lock ())
--- a/libinterp/corefcn/symrec.h Sun Dec 03 12:37:13 2017 +0100 +++ b/libinterp/corefcn/symrec.h Tue Nov 28 12:43:25 2017 -0500 @@ -196,16 +196,12 @@ return octave_value (); } - void push_context (symbol_scope *sid) + void push_context (void) { if (auto t_fwd_rep = m_fwd_rep.lock ()) - { - t_fwd_rep->push_context (sid); - return; - } + return; - if (! (is_persistent () || is_global ()) - && sid == decl_scope ()) + if (! (is_persistent () || is_global ())) m_value_stack.push_back (octave_value ()); } @@ -223,15 +219,14 @@ // // Here, X should only exist in the final stack frame. - size_t pop_context (symbol_scope *sid) + size_t pop_context (void) { - if (auto t_fwd_rep = m_fwd_rep.lock ()) - return t_fwd_rep->pop_context (sid); - size_t retval = 1; - if (! (is_persistent () || is_global ()) - && sid == decl_scope ()) + if (auto t_fwd_rep = m_fwd_rep.lock ()) + return retval; + + if (! (is_persistent () || is_global ())) { m_value_stack.pop_back (); retval = m_value_stack.size (); @@ -242,17 +237,33 @@ void clear (void) { + // There is no need to do anything with a fowarded + // symbol_record_rep here. + // + // For scripts, we are never executing in the script "scope". + // + // For globals, we are only interested in breaking the link to + // the global value and clearing the local value, not the + // global one. + + // For persistent values, we clear the value then unmark so + // that we clear the first element of the value stack. + if (auto t_fwd_rep = m_fwd_rep.lock ()) + return; + + if (! (is_hidden () || is_inherited ())) { - t_fwd_rep->clear (); - return; + if (is_global ()) + unmark_global (); + + assign (octave_value ()); + + if (is_persistent ()) + unmark_persistent (); } - - clear (decl_scope ()); } - void clear (symbol_scope *sid); - bool is_defined (void) const { if (auto t_fwd_rep = m_fwd_rep.lock ()) @@ -666,14 +677,12 @@ return m_rep->varval (); } - void push_context (symbol_scope *sid) { m_rep->push_context (sid); } + void push_context (void) { m_rep->push_context (); } - size_t pop_context (symbol_scope *sid) { return m_rep->pop_context (sid); } + size_t pop_context (void) { return m_rep->pop_context (); } void clear (void) { m_rep->clear (); } - void clear (symbol_scope *sid) { m_rep->clear (sid); } - bool is_defined (void) const { return m_rep->is_defined ();
--- a/libinterp/corefcn/symscope.h Sun Dec 03 12:37:13 2017 +0100 +++ b/libinterp/corefcn/symscope.h Tue Nov 28 12:43:25 2017 -0500 @@ -261,7 +261,7 @@ void push_context (void) { for (auto& nm_sr : m_symbols) - nm_sr.second.push_context (this); + nm_sr.second.push_context (); } void pop_context (void) @@ -270,7 +270,7 @@ while (tbl_it != m_symbols.end ()) { - if (tbl_it->second.pop_context (this) == 0) + if (tbl_it->second.pop_context () == 0) m_symbols.erase (tbl_it++); else tbl_it++; @@ -284,14 +284,14 @@ symbol_record& sr = nm_sr.second; if (! sr.is_persistent ()) - sr.clear (this); + sr.clear (); } } void clear_variables (void) { for (auto& nm_sr : m_symbols) - nm_sr.second.clear (this); + nm_sr.second.clear (); } void clear_objects (void) @@ -301,7 +301,7 @@ symbol_record& sr = nm_sr.second; octave_value val = sr.varval (); if (val.isobject ()) - nm_sr.second.clear (this); + nm_sr.second.clear (); } } @@ -312,7 +312,7 @@ table_iterator p = m_symbols.find (name); if (p != m_symbols.end ()) - p->second.clear (this); + p->second.clear (); } void clear_global_pattern (const std::string& pat); @@ -328,7 +328,7 @@ if (sr.is_defined () || sr.is_global ()) { if (pattern.match (sr.name ())) - sr.clear (this); + sr.clear (); } } } @@ -344,7 +344,7 @@ if (sr.is_defined () || sr.is_global ()) { if (pattern.is_match (sr.name ())) - sr.clear (this); + sr.clear (); } } }