Mercurial > hg > octave-lyh
comparison src/variables.cc @ 5397:b12c0f920da0
[project @ 2005-06-17 07:52:28 by jwe]
author | jwe |
---|---|
date | Fri, 17 Jun 2005 07:52:28 +0000 |
parents | 80c1aa832cb2 |
children | 2ed5009be503 |
comparison
equal
deleted
inserted
replaced
5396:983bf1f4bab5 | 5397:b12c0f920da0 |
---|---|
973 file_stat g_fs (c_g); | 973 file_stat g_fs (c_g); |
974 | 974 |
975 return (f_fs.ino () == g_fs.ino () && f_fs.dev () == g_fs.dev ()); | 975 return (f_fs.ino () == g_fs.ino () && f_fs.dev () == g_fs.dev ()); |
976 } | 976 } |
977 | 977 |
978 static bool | |
979 fcn_out_of_date (octave_function *fcn, const std::string& ff, time_t tp) | |
980 { | |
981 bool retval = false; | |
982 | |
983 fcn->mark_fcn_file_up_to_date (octave_time ()); | |
984 | |
985 if (! (Vignore_function_time_stamp == 2 | |
986 || (Vignore_function_time_stamp && fcn->is_system_fcn_file ()))) | |
987 { | |
988 file_stat fs (ff); | |
989 | |
990 if (fs && fs.is_newer (tp)) | |
991 retval = true; | |
992 } | |
993 | |
994 return retval; | |
995 } | |
996 | |
978 // Is there a corresponding function file that is newer than the | 997 // Is there a corresponding function file that is newer than the |
979 // symbol definition? | 998 // symbol definition? |
980 | 999 |
981 static bool | 1000 static bool |
982 function_out_of_date_internal (octave_function *fcn) | 1001 symbol_out_of_date (symbol_record *sr) |
983 { | 1002 { |
984 bool retval = false; | 1003 bool retval = false; |
985 | 1004 |
986 if (fcn) | 1005 if (sr) |
987 { | 1006 { |
988 std::string ff = fcn->fcn_file_name (); | 1007 octave_value ans = sr->def (); |
989 | 1008 |
990 if (! (ff.empty () | 1009 octave_function *fcn = ans.function_value (true); |
991 || (Vignore_function_time_stamp | 1010 |
992 && fcn->is_system_fcn_file ()))) | 1011 if (fcn) |
993 { | 1012 { |
994 if (fcn->time_checked () < Vlast_prompt_time) | 1013 std::string ff = fcn->fcn_file_name (); |
1014 | |
1015 if (! ff.empty ()) | |
995 { | 1016 { |
996 time_t tp = fcn->time_parsed (); | 1017 if (fcn->time_checked () < Vlast_prompt_time) |
997 | |
998 std::string nm = fcn->name (); | |
999 | |
1000 string_vector names (2); | |
1001 | |
1002 names[0] = nm + ".oct"; | |
1003 names[1] = nm + ".m"; | |
1004 | |
1005 std::string file = octave_env::make_absolute | |
1006 (Vload_path_dir_path.find_first_of (names), | |
1007 octave_env::getcwd ()); | |
1008 | |
1009 if (same_file (file, ff)) | |
1010 { | 1018 { |
1011 fcn->mark_fcn_file_up_to_date (octave_time ()); | 1019 time_t tp = fcn->time_parsed (); |
1012 | 1020 |
1013 file_stat fs (ff); | 1021 std::string nm = fcn->name (); |
1014 | 1022 |
1015 if (fs && fs.is_newer (tp)) | 1023 string_vector names (2); |
1016 retval = true; | 1024 |
1025 names[0] = nm + ".oct"; | |
1026 names[1] = nm + ".m"; | |
1027 | |
1028 std::string file = octave_env::make_absolute | |
1029 (Vload_path_dir_path.find_first_of (names), | |
1030 octave_env::getcwd ()); | |
1031 | |
1032 if (same_file (file, ff)) | |
1033 { | |
1034 retval = fcn_out_of_date (fcn, ff, tp); | |
1035 } | |
1036 else | |
1037 { | |
1038 // Check the full function name. Maybe we alrady | |
1039 // parsed it. | |
1040 | |
1041 symbol_record *full_sr = fbi_sym_tab->lookup (file); | |
1042 | |
1043 if (full_sr) | |
1044 { | |
1045 octave_value v = full_sr->def (); | |
1046 | |
1047 if (v.is_function ()) | |
1048 { | |
1049 // OK, swap the aliases around. | |
1050 | |
1051 // XXX FIXME XXX -- this is a bit | |
1052 // tricky, so maybe some refactoring is | |
1053 // in order here too... | |
1054 | |
1055 symbol_record *short_sr = fbi_sym_tab->lookup (nm); | |
1056 | |
1057 if (short_sr) | |
1058 short_sr->alias (full_sr); | |
1059 | |
1060 // Make local symbol table entry point | |
1061 // to correct global function too. | |
1062 | |
1063 sr->alias (full_sr); | |
1064 | |
1065 fcn = v.function_value (); | |
1066 | |
1067 retval = fcn_out_of_date (fcn, file, tp); | |
1068 } | |
1069 else | |
1070 retval = true; | |
1071 } | |
1072 else | |
1073 retval = true; | |
1074 } | |
1017 } | 1075 } |
1018 else | |
1019 retval = true; | |
1020 } | 1076 } |
1021 } | 1077 } |
1022 } | 1078 } |
1023 | |
1024 return retval; | |
1025 } | |
1026 | |
1027 static bool | |
1028 symbol_out_of_date (symbol_record *sr) | |
1029 { | |
1030 bool retval = false; | |
1031 | |
1032 if (Vignore_function_time_stamp != 2 && sr) | |
1033 { | |
1034 octave_value ans = sr->def (); | |
1035 | |
1036 octave_function *tmp = ans.function_value (true); | |
1037 | |
1038 retval = function_out_of_date_internal (tmp); | |
1039 } | |
1040 | |
1041 return retval; | |
1042 } | |
1043 | |
1044 bool | |
1045 function_out_of_date (octave_function *fcn) | |
1046 { | |
1047 bool retval = false; | |
1048 | |
1049 if (Vignore_function_time_stamp != 2) | |
1050 retval = function_out_of_date_internal (fcn); | |
1051 | 1079 |
1052 return retval; | 1080 return retval; |
1053 } | 1081 } |
1054 | 1082 |
1055 bool | 1083 bool |