# HG changeset patch # User John W. Eaton # Date 1589832925 14400 # Node ID cf20fd68305e84f3df2313acd27ae795f7a651e4 # Parent bb47f604dfea644fdf88a8cdcfcef12848183c01# Parent 6349915869f27d82a23c10a97ab31714ca313c02 maint: merge stable to default. diff -r bb47f604dfea -r cf20fd68305e libinterp/corefcn/call-stack.cc --- a/libinterp/corefcn/call-stack.cc Mon May 18 20:52:05 2020 +0200 +++ b/libinterp/corefcn/call-stack.cc Mon May 18 16:15:25 2020 -0400 @@ -751,16 +751,6 @@ return m_cs[m_curr_frame]->all_variables (); } - std::list call_stack::glob (const std::string& pattern) const - { - return m_cs[m_curr_frame]->glob (pattern); - } - - std::list call_stack::regexp (const std::string& pattern) const - { - return m_cs[m_curr_frame]->regexp (pattern); - } - std::list call_stack::global_variable_names (void) const { std::list retval; @@ -831,7 +821,7 @@ symbol_info_list call_stack::regexp_symbol_info (const std::string& pattern) const { - return m_cs[m_curr_frame]->glob_symbol_info (pattern); + return m_cs[m_curr_frame]->regexp_symbol_info (pattern); } symbol_info_list call_stack::get_symbol_info (void) diff -r bb47f604dfea -r cf20fd68305e libinterp/corefcn/call-stack.h --- a/libinterp/corefcn/call-stack.h Mon May 18 20:52:05 2020 +0200 +++ b/libinterp/corefcn/call-stack.h Mon May 18 16:15:25 2020 -0400 @@ -250,10 +250,6 @@ symbol_info_list all_variables (void); - std::list glob (const std::string& pattern) const; - - std::list regexp (const std::string& pattern) const; - std::list global_variable_names (void) const; std::list top_level_variable_names (void) const; diff -r bb47f604dfea -r cf20fd68305e libinterp/corefcn/stack-frame.cc --- a/libinterp/corefcn/stack-frame.cc Mon May 18 20:52:05 2020 +0200 +++ b/libinterp/corefcn/stack-frame.cc Mon May 18 16:15:25 2020 -0400 @@ -247,6 +247,27 @@ panic_impossible (); } + symbol_info_list + stack_frame::make_symbol_info_list (const std::list& symrec_list) const + { + symbol_info_list symbol_stats; + + for (const auto& sym : symrec_list) + { + octave_value value = varval (sym); + + if (value.is_defined ()) + { + symbol_info syminf (sym.name (), value, sym.is_formal (), + is_global (sym), is_persistent (sym)); + + symbol_stats.append (syminf); + } + } + + return symbol_stats; + } + // Return first occurrence of variables in current stack frame and any // parent frames reachable through access links. @@ -259,59 +280,8 @@ return sia.symbol_info (); } - std::list - stack_frame::glob (const std::string& pattern) const - { - std::list retval; - - symbol_scope scope = get_scope (); - - const std::map& symbols = scope.symbols (); - - glob_match pat (pattern); - - for (const auto& nm_sr : symbols) - { - if (pat.match (nm_sr.first)) - { - symbol_record sr = nm_sr.second; - - if (! is_variable (sr)) - continue; - - retval.push_back (sr); - } - } - - return retval; - } - - std::list - stack_frame::regexp (const std::string& pattern) const - { - std::list retval; - - symbol_scope scope = get_scope (); - - const std::map& symbols = scope.symbols (); - - octave::regexp pat (pattern); - - for (const auto& nm_sr : symbols) - { - if (pat.is_match (nm_sr.first)) - { - symbol_record sr = nm_sr.second; - - if (! is_variable (sr)) - continue; - - retval.push_back (sr); - } - } - - return retval; - } + // FIXME: Should this function also find any variables in parent + // scopes accessible through access_links? std::list stack_frame::variable_names (void) const { @@ -332,6 +302,24 @@ return retval; } + symbol_info_list stack_frame::glob_symbol_info (const std::string& pattern) + { + symbol_info_accumulator sia (pattern, false); + + accept (sia); + + return sia.symbol_info (); + } + + symbol_info_list stack_frame::regexp_symbol_info (const std::string& pattern) + { + symbol_info_accumulator sia (pattern, true); + + accept (sia); + + return sia.symbol_info (); + } + size_t stack_frame::size (void) const { // This function should only be called for user_fcn_stack_frame or diff -r bb47f604dfea -r cf20fd68305e libinterp/corefcn/stack-frame.h --- a/libinterp/corefcn/stack-frame.h Mon May 18 20:52:05 2020 +0200 +++ b/libinterp/corefcn/stack-frame.h Mon May 18 16:15:25 2020 -0400 @@ -215,39 +215,11 @@ virtual unwind_protect * unwind_protect_frame (void) const { return nullptr; } - // FIXME: Should this function be private? - symbol_info_list - make_symbol_info_list (const std::list& symrec_list) const - { - symbol_info_list symbol_stats; - - for (const auto& sym : symrec_list) - { - octave_value value = varval (sym); - - if (value.is_defined ()) - { - symbol_info syminf (sym.name (), value, sym.is_formal (), - is_global (sym), is_persistent (sym)); - - symbol_stats.append (syminf); - } - } - - return symbol_stats; - } + make_symbol_info_list (const std::list& symrec_list) const; symbol_info_list all_variables (void); - // FIXME: Should these exist? Probably we should avoid returning - // lists of symbol_record objects, so maybe they should be - // private functions? - - std::list glob (const std::string& pattern) const; - - std::list regexp (const std::string& pattern) const; - std::list variable_names (void) const; // Look for named symbol visible from current scope. Don't @@ -258,19 +230,9 @@ // insert if missing. virtual symbol_record insert_symbol (const std::string&) = 0; - // FIXME: should these functions should return all symbols visible in - // the current stack frame including those that come from a parent - // scope/frame? + symbol_info_list glob_symbol_info (const std::string& pattern); - symbol_info_list glob_symbol_info (const std::string& pattern) const - { - return make_symbol_info_list (glob (pattern)); - } - - symbol_info_list regexp_symbol_info (const std::string& pattern) const - { - return make_symbol_info_list (regexp (pattern)); - } + symbol_info_list regexp_symbol_info (const std::string& pattern); symbol_info_list get_symbol_info (void) {