Mercurial > octave
diff libinterp/corefcn/symtab.cc @ 26846:4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
* fcn-info.h, fcn-info.cc (fcn_info::find, fcn_info::builtin_find,
fcn_info::find_function): Don't allow search_scope arg to be omitted.
Don't set default value here.
* symtab.cc (symbol_table::builtin_find, symbol_table::find_function,
symbol_table::fcn_table_find): Set default search scope here if
argument is omitted or otherwise undefined.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Mar 2019 07:32:38 +0000 |
parents | 6322d51c655c |
children | 340d44f2f942 |
line wrap: on
line diff
--- a/libinterp/corefcn/symtab.cc Tue Mar 05 05:01:18 2019 +0000 +++ b/libinterp/corefcn/symtab.cc Tue Mar 05 07:32:38 2019 +0000 @@ -129,14 +129,18 @@ ? p->second.find_autoload () : octave_value ()); } - octave_value symbol_table::builtin_find (const std::string& name, - const symbol_scope& search_scope) + octave_value + symbol_table::builtin_find (const std::string& name, + const symbol_scope& search_scope_arg) { if (name.empty ()) return octave_value (); fcn_table_iterator p = m_fcn_table.find (name); + symbol_scope search_scope + = (search_scope_arg ? search_scope_arg : current_scope ()); + if (p != m_fcn_table.end ()) return p->second.builtin_find (search_scope); else @@ -154,22 +158,26 @@ return octave_value (); } - octave_value symbol_table::fcn_table_find (const std::string& name, - const octave_value_list& args, - const symbol_scope& search_scope) + octave_value + symbol_table::fcn_table_find (const std::string& name, + const octave_value_list& args, + const symbol_scope& search_scope_arg) { if (name.empty ()) return octave_value (); fcn_table_iterator p = m_fcn_table.find (name); + symbol_scope search_scope + = (search_scope_arg ? search_scope_arg : current_scope ()); + if (p != m_fcn_table.end ()) - return p->second.find (args, search_scope); + return p->second.find (search_scope, args); else { fcn_info finfo (name); - octave_value fcn = finfo.find (args, search_scope); + octave_value fcn = finfo.find (search_scope, args); if (fcn.is_defined ()) m_fcn_table[name] = finfo; @@ -180,8 +188,9 @@ return octave_value (); } - octave_value symbol_table::find_function (const std::string& name, - const symbol_scope& search_scope) + octave_value + symbol_table::find_function (const std::string& name, + const symbol_scope& search_scope_arg) { if (name.empty ()) return octave_value (); @@ -199,17 +208,23 @@ return find_method (method, dispatch_type); } else - return find_function (name, ovl (), search_scope); + { + symbol_scope search_scope + = (search_scope_arg ? search_scope_arg : current_scope ()); + + return find_function (name, ovl (), search_scope); + } } - octave_value symbol_table::find_function (const std::string& name, - const octave_value_list& args, - const symbol_scope& scope_arg) + octave_value + symbol_table::find_function (const std::string& name, + const octave_value_list& args, + const symbol_scope& search_scope) { if (name.empty ()) return octave_value (); - return fcn_table_find (name, args, scope_arg); + return fcn_table_find (name, args, search_scope); } octave_value