Mercurial > hg > octave-lyh
changeset 5312:80c1aa832cb2
[project @ 2005-04-28 01:54:46 by jwe]
author | jwe |
---|---|
date | Thu, 28 Apr 2005 01:54:46 +0000 |
parents | 46de0f964c1b |
children | d2979f3da3cb |
files | src/ChangeLog src/ov-fcn-handle.cc src/parse.h src/parse.y src/variables.cc src/variables.h |
diffstat | 6 files changed, 98 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2005-04-27 John W. Eaton <jwe@octave.org> + * ov-fcn-handle.cc (octave_fcn_handle::subsref): check to see if + function is out of date. + + * variables.cc (symbol_out_of_date (octave_fucntion *)): New function. + (function_out_of_date): New function. + * parse.y (load_fcn_from_file (const std::string&, bool)): + New function. + * DLD-FUNCTIONS/gplot.l (gnuplot_init): New function to handle initialization. If builtin variables have already been installed, simply update our cached values.
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -68,7 +68,26 @@ case '(': { octave_function *f = function_value (); - retval = f->subsref (type, idx, nargout); + + // XXX FIXME XXX -- need to check to see if the function has a + // new definition. The following does not work for function + // handles that refer to subfunctions or functions defined on + // the command line. + // + // if (function_out_of_date (f)) + // { + // octave_value tmp = lookup_function (fcn_name ()); + // + // octave_function *ftmp = tmp.function_value (true); + // + // if (ftmp) + // f = ftmp; + // } + + if (f) + retval = f->subsref (type, idx, nargout); + else + error ("invalid function handle"); } break;
--- a/src/parse.h +++ b/src/parse.h @@ -95,6 +95,9 @@ extern std::string get_help_from_file (const std::string& f); extern bool +load_fcn_from_file (const std::string& nm, bool exec_script); + +extern bool load_fcn_from_file (symbol_record *sym_rec, bool exec_script); extern void
--- a/src/parse.y +++ b/src/parse.y @@ -3332,12 +3332,10 @@ } bool -load_fcn_from_file (symbol_record *sym_rec, bool exec_script) +load_fcn_from_file (const std::string& nm, bool exec_script) { bool script_file_executed = false; - std::string nm = sym_rec->name (); - string_vector names (2); names[0] = nm + ".oct"; @@ -3377,6 +3375,12 @@ return script_file_executed; } +bool +load_fcn_from_file (symbol_record *sym_rec, bool exec_script) +{ + return load_fcn_from_file (sym_rec->name (), exec_script); +} + void source_file (const std::string file_name) {
--- a/src/variables.cc +++ b/src/variables.cc @@ -979,6 +979,52 @@ // symbol definition? static bool +function_out_of_date_internal (octave_function *fcn) +{ + bool retval = false; + + if (fcn) + { + std::string ff = fcn->fcn_file_name (); + + if (! (ff.empty () + || (Vignore_function_time_stamp + && fcn->is_system_fcn_file ()))) + { + if (fcn->time_checked () < Vlast_prompt_time) + { + time_t tp = fcn->time_parsed (); + + std::string nm = fcn->name (); + + string_vector names (2); + + names[0] = nm + ".oct"; + names[1] = nm + ".m"; + + std::string file = octave_env::make_absolute + (Vload_path_dir_path.find_first_of (names), + octave_env::getcwd ()); + + if (same_file (file, ff)) + { + fcn->mark_fcn_file_up_to_date (octave_time ()); + + file_stat fs (ff); + + if (fs && fs.is_newer (tp)) + retval = true; + } + else + retval = true; + } + } + } + + return retval; +} + +static bool symbol_out_of_date (symbol_record *sr) { bool retval = false; @@ -989,49 +1035,24 @@ octave_function *tmp = ans.function_value (true); - if (tmp) - { - std::string ff = tmp->fcn_file_name (); - - if (! (ff.empty () - || (Vignore_function_time_stamp - && tmp->is_system_fcn_file ()))) - { - if (tmp->time_checked () < Vlast_prompt_time) - { - time_t tp = tmp->time_parsed (); - - std::string nm = tmp->name (); - - string_vector names (2); - - names[0] = nm + ".oct"; - names[1] = nm + ".m"; - - std::string file = octave_env::make_absolute - (Vload_path_dir_path.find_first_of (names), - octave_env::getcwd ()); - - if (same_file (file, ff)) - { - tmp->mark_fcn_file_up_to_date (octave_time ()); - - file_stat fs (ff); - - if (fs && fs.is_newer (tp)) - retval = true; - } - else - retval = true; - } - } - } + retval = function_out_of_date_internal (tmp); } return retval; } bool +function_out_of_date (octave_function *fcn) +{ + bool retval = false; + + if (Vignore_function_time_stamp != 2) + retval = function_out_of_date_internal (fcn); + + return retval; +} + +bool lookup (symbol_record *sym_rec, bool exec_script) { bool script_executed = false;