Mercurial > hg > octave-max
changeset 9509:c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 10 Aug 2009 10:08:10 +0200 |
parents | e5e4e404a59d |
children | 1b290ce305fb |
files | src/ChangeLog src/ov-fcn-handle.cc src/symtab.cc src/symtab.h |
diffstat | 4 files changed, 63 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2009-08-10 Jaroslav Hajek <highegg@gmail.com> + + * symtab.cc (out_of_date_check): Remove overloads. Add check_relative + parameter. + (out_of_date_check_internal): Remove. + * symtab.h: Update. + * ov-fcn-handle.cc (octave_fcn_handle::do_index_op): Call + out_of_date_check with check_relative = false. + 2009-08-09 John W. Eaton <jwe@octave.org> * parse.y (Fevalin): Also return output from CATCH expression.
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -123,7 +123,7 @@ octave_value_list retval; if (fcn.is_defined ()) - out_of_date_check (fcn); + out_of_date_check (fcn, std::string (), false); if (disp.get () && ! args.empty ()) { @@ -142,7 +142,7 @@ str_ov_map::iterator pos = disp->find (sdt); if (pos != disp->end ()) { - out_of_date_check (pos->second, sdt); + out_of_date_check (pos->second, sdt, false); ovfcn = pos->second; } } @@ -152,7 +152,7 @@ str_ov_map::iterator pos = disp->find (ddt); if (pos != disp->end ()) { - out_of_date_check (pos->second, ddt); + out_of_date_check (pos->second, ddt, false); ovfcn = pos->second; } else @@ -1573,6 +1573,8 @@ parentage.elem(1) = fcn->parent_fcn_name (); m.assign ("parentage", octave_value (parentage)); } + else if (fcn->is_private_function ()) + m.assign ("type", "private"); else if (fh->is_overloaded ()) m.assign ("type", "overloaded"); else
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -156,12 +156,15 @@ return retval; } -static inline bool -out_of_date_check_internal (octave_function *fcn, octave_value& function, - const std::string& dispatch_type = std::string ()) +bool +out_of_date_check (octave_value& function, + const std::string& dispatch_type, + bool check_relative) { bool retval = false; + octave_function *fcn = function.function_value (true); + if (fcn) { // FIXME -- we need to handle nested functions properly here. @@ -174,37 +177,50 @@ { octave_time tc = fcn->time_checked (); - bool relative = fcn->is_relative (); + bool relative = check_relative && fcn->is_relative (); if (tc < Vlast_prompt_time || (relative && tc < Vlast_chdir_time)) { bool clear_breakpoints = false; - std::string nm = fcn->name (); + std::string nm = fcn->name (); + + bool is_same_file = false; - int nm_len = nm.length (); + std::string file; + std::string dir_name; - std::string file; - std::string dir_name; + if (check_relative) + { + int nm_len = nm.length (); - if (octave_env::absolute_pathname (nm) - && ((nm_len > 4 && (nm.substr (nm_len-4) == ".oct" - || nm.substr (nm_len-4) == ".mex")) - || (nm_len > 2 && nm.substr (nm_len-2) == ".m"))) - file = nm; - else - { - // We don't want to make this an absolute name, - // because load_fcn_file looks at the name to - // decide whether it came from a relative lookup. + if (octave_env::absolute_pathname (nm) + && ((nm_len > 4 && (nm.substr (nm_len-4) == ".oct" + || nm.substr (nm_len-4) == ".mex")) + || (nm_len > 2 && nm.substr (nm_len-2) == ".m"))) + file = nm; + else + { + // We don't want to make this an absolute name, + // because load_fcn_file looks at the name to + // decide whether it came from a relative lookup. - if (! dispatch_type.empty ()) - file = load_path::find_method (dispatch_type, nm, - dir_name); + if (! dispatch_type.empty ()) + file = load_path::find_method (dispatch_type, nm, + dir_name); + + if (file.empty ()) + file = load_path::find_fcn (nm, dir_name); + } - if (file.empty ()) - file = load_path::find_fcn (nm, dir_name); - } + if (! file.empty ()) + is_same_file = same_file (file, ff); + } + else + { + is_same_file = true; + file = ff; + } if (file.empty ()) { @@ -215,7 +231,7 @@ clear_breakpoints = true; } - else if (same_file (file, ff)) + else if (is_same_file) { // Same file. If it is out of date, then reload it. @@ -272,29 +288,6 @@ return retval; } -static inline bool -out_of_date_check_internal (octave_value& function, - const std::string& dispatch_type = std::string ()) -{ - return out_of_date_check_internal (function.function_value (true), - function, dispatch_type); -} - -bool -out_of_date_check (octave_value& function, - const std::string& dispatch_type) -{ - return out_of_date_check_internal (function, dispatch_type); -} - -bool -out_of_date_check (octave_function* fcn, - const std::string& dispatch_type) -{ - octave_value function; - return out_of_date_check_internal (fcn, function, dispatch_type); -} - octave_value symbol_table::fcn_info::fcn_info_rep::load_private_function (const std::string& dir_name) @@ -568,7 +561,7 @@ octave_value& fval = q->second; if (fval.is_defined ()) - out_of_date_check_internal (fval); + out_of_date_check (fval); if (fval.is_defined ()) return fval; @@ -600,7 +593,7 @@ octave_value& fval = q->second; if (fval.is_defined ()) - out_of_date_check_internal (fval, name); + out_of_date_check (fval, name); if (fval.is_defined ()) return fval; @@ -765,7 +758,7 @@ octave_value& fval = q->second; if (fval.is_defined ()) - out_of_date_check_internal (fval); + out_of_date_check (fval); if (fval.is_defined ()) return fval; @@ -831,7 +824,7 @@ octave_value& fval = q->second; if (fval.is_defined ()) - out_of_date_check_internal (fval, dispatch_type); + out_of_date_check (fval, dispatch_type); if (fval.is_defined ()) return fval; @@ -855,7 +848,7 @@ // Autoloaded function. if (autoload_function.is_defined ()) - out_of_date_check_internal (autoload_function); + out_of_date_check (autoload_function); if (! autoload_function.is_defined ()) { @@ -884,7 +877,7 @@ // Function on the path. if (function_on_path.is_defined ()) - out_of_date_check_internal (function_on_path); + out_of_date_check (function_on_path); if (! function_on_path.is_defined ()) {
--- a/src/symtab.h +++ b/src/symtab.h @@ -2303,10 +2303,8 @@ }; extern bool out_of_date_check (octave_value& function, - const std::string& dispatch_type = std::string ()); - -extern bool out_of_date_check (octave_function* fcn, - const std::string& dispatch_type = std::string ()); + const std::string& dispatch_type = std::string (), + bool check_relative = true); extern std::string get_dispatch_type (const octave_value_list& args);