Mercurial > octave
changeset 28436:22e90bdcf47f stable
make find_scoped_function available in symbol_table class
* fcn-info.h (fcn_info::find_scoped_function): Now const.
* symtab.h, symtab.cc (symbol_table::find_scoped_function):
New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 09 Jun 2020 16:52:57 -0400 |
parents | 76a9f31540e3 |
children | 8f3aedc5ab4f |
files | libinterp/corefcn/fcn-info.h libinterp/corefcn/symtab.cc libinterp/corefcn/symtab.h |
diffstat | 3 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/fcn-info.h Tue May 12 12:43:42 2020 -0400 +++ b/libinterp/corefcn/fcn-info.h Tue Jun 09 16:52:57 2020 -0400 @@ -259,7 +259,7 @@ return m_rep->builtin_find (search_scope); } - octave_value find_scoped_function (const symbol_scope& search_scope) + octave_value find_scoped_function (const symbol_scope& search_scope) const { return m_rep->find_scoped_function (search_scope); }
--- a/libinterp/corefcn/symtab.cc Tue May 12 12:43:42 2020 -0400 +++ b/libinterp/corefcn/symtab.cc Tue Jun 09 16:52:57 2020 -0400 @@ -71,6 +71,30 @@ return val.is_defined (); } + octave_value + symbol_table::find_scoped_function (const std::string& name, + const symbol_scope& search_scope) + { + if (name.empty ()) + return octave_value (); + + fcn_table_const_iterator p = m_fcn_table.find (name); + + if (p != m_fcn_table.end ()) + return p->second.find_scoped_function (search_scope); + else + { + fcn_info finfo (name); + + octave_value fcn = finfo.find_scoped_function (search_scope); + + if (fcn.is_defined ()) + m_fcn_table[name] = finfo; + + return fcn; + } + } + // FIXME: this function only finds legacy class methods, not // classdef methods.
--- a/libinterp/corefcn/symtab.h Tue May 12 12:43:42 2020 -0400 +++ b/libinterp/corefcn/symtab.h Tue Jun 09 16:52:57 2020 -0400 @@ -72,6 +72,9 @@ bool is_built_in_function_name (const std::string& name); + octave_value find_scoped_function (const std::string& name, + const symbol_scope& search_scope); + // FIXME: this function only finds legacy class methods, not // classdef methods. octave_value find_method (const std::string& name,