Mercurial > hg > octave-nkf
changeset 11238:1783b360976f
also consider parent classes when checking if class methods are out of date
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Nov 2010 02:30:32 -0500 |
parents | 110e570e5f8d |
children | 5fa7667f90e5 |
files | src/ChangeLog src/symtab.cc src/symtab.h |
diffstat | 3 files changed, 54 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2010-11-11 John W. Eaton <jwe@octave.org> + + Bug #31165. + + * symtab.h (symbol_table::parent_classes): New static function. + * symtab.cc (out_of_date_check): Also look for methods defined + in parent classes of dispatch_type. + (symbol_table::fcn_info::fcn_info_rep::load_class_method): Call + parent_classes instead of accessing parent_map directly. + 2010-11-10 John W. Eaton <jwe@octave.org> * octave.cc (octave_main): Call octave_ieee_init here.
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -208,8 +208,27 @@ // decide whether it came from a relative lookup. if (! dispatch_type.empty ()) - file = load_path::find_method (dispatch_type, nm, - dir_name); + { + file = load_path::find_method (dispatch_type, nm, + dir_name); + + if (file.empty ()) + { + const std::list<std::string>& plist + = symbol_table::parent_classes (dispatch_type); + std::list<std::string>::const_iterator it + = plist.begin (); + + while (it != plist.end ()) + { + file = load_path::find_method (*it, nm, dir_name); + if (! file.empty ()) + break; + + it++; + } + } + } // Maybe it's an autoload? if (file.empty ()) @@ -387,25 +406,21 @@ { // Search parent classes - const_parent_map_iterator r = parent_map.find (dispatch_type); + const std::list<std::string>& plist = parent_classes (dispatch_type); - if (r != parent_map.end ()) + std::list<std::string>::const_iterator it = plist.begin (); + + while (it != plist.end ()) { - const std::list<std::string>& plist = r->second; - std::list<std::string>::const_iterator it = plist.begin (); + retval = find_method (*it); - while (it != plist.end ()) + if (retval.is_defined ()) { - retval = find_method (*it); + class_methods[dispatch_type] = retval; + break; + } - if (retval.is_defined ()) - { - class_methods[dispatch_type] = retval; - break; - } - - it++; - } + it++; } } }
--- a/src/symtab.h +++ b/src/symtab.h @@ -1825,6 +1825,19 @@ parent_map[classname] = parent_list; } + static std::list<std::string> + parent_classes (const std::string& dispatch_type) + { + std::list<std::string> retval; + + const_parent_map_iterator it = parent_map.find (dispatch_type); + + if (it != parent_map.end ()) + retval = it->second; + + return retval; + } + static octave_user_function *get_curr_fcn (scope_id scope = xcurrent_scope) { symbol_table *inst = get_instance (scope);