Mercurial > octave
changeset 21264:dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
* symtab.cc (find_submethod): New function to find subfunc in old-style class
method.
* symtab.h (find_method): Call find_submethod if function exists but not found
through find_method.
* symtab.h (find_submethod): Prototype for new function.
author | Lachlan <lachlanbis@gmail.com> |
---|---|
date | Mon, 15 Feb 2016 14:03:23 -0800 |
parents | cf2eae837cc8 |
children | f780d057a3ec |
files | libinterp/corefcn/symtab.cc libinterp/corefcn/symtab.h |
diffstat | 2 files changed, 51 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/symtab.cc Mon Feb 15 11:04:52 2016 -0800 +++ b/libinterp/corefcn/symtab.cc Mon Feb 15 14:03:23 2016 -0800 @@ -1322,6 +1322,43 @@ return retval; } +// look for @class/method>subfunction +octave_value +symbol_table::find_submethod (const std::string& name, + const std::string& dispatch_type) +{ + octave_value fcn; + + std::string full_name = "@" + dispatch_type + file_ops::dir_sep_str () + name; + size_t pos = full_name.find_first_of (Vfilemarker); + + if (pos != std::string::npos) + { + std::string fcn_scope = full_name.substr (0, pos); + scope_id stored_scope = xcurrent_scope; + xcurrent_scope = xtop_scope; + octave_value parent = find_function (full_name.substr (0, pos), + octave_value_list (), false); + if (parent.is_defined ()) + { + octave_function *parent_fcn = parent.function_value (); + + if (parent_fcn) + { + xcurrent_scope = parent_fcn->scope (); + + if (xcurrent_scope > 1) + fcn = find_function (full_name.substr (pos + 1), + octave_value_list ()); + } + } + + xcurrent_scope = stored_scope; + } + + return fcn; +} + void symbol_table::dump (std::ostream& os, scope_id scope) {
--- a/libinterp/corefcn/symtab.h Mon Feb 15 11:04:52 2016 -0800 +++ b/libinterp/corefcn/symtab.h Mon Feb 15 14:03:23 2016 -0800 @@ -1497,13 +1497,23 @@ fcn_table_const_iterator p = fcn_table.find (name); if (p != fcn_table.end ()) - return p->second.find_method (dispatch_type); + { + octave_value fcn = p->second.find_method (dispatch_type); + + if (! fcn.is_defined ()) + fcn = find_submethod (name, dispatch_type); + + return fcn; + } else { fcn_info finfo (name); octave_value fcn = finfo.find_method (dispatch_type); + if (! fcn.is_defined ()) + fcn = find_submethod (name, dispatch_type); + if (fcn.is_defined ()) fcn_table[name] = finfo; @@ -1512,6 +1522,9 @@ } static octave_value + find_submethod (const std::string& name, const std::string& dispatch_type); + + static octave_value find_built_in_function (const std::string& name) { fcn_table_const_iterator p = fcn_table.find (name);