Mercurial > hg > octave-lyh
comparison src/variables.cc @ 6323:ea65de49e18e
[project @ 2007-02-17 02:51:02 by jwe]
author | jwe |
---|---|
date | Sat, 17 Feb 2007 02:51:03 +0000 |
parents | 44c91c5dfe1d |
children | 5e00f0993233 |
comparison
equal
deleted
inserted
replaced
6322:723a32c8ee10 | 6323:ea65de49e18e |
---|---|
960 print_usage (); | 960 print_usage (); |
961 | 961 |
962 return retval; | 962 return retval; |
963 } | 963 } |
964 | 964 |
965 // Return TRUE if F and G are both names for the same file. | |
966 | |
967 static bool | |
968 same_file (const std::string& f, const std::string& g) | |
969 { | |
970 std::string c_f = file_ops::canonicalize_file_name (f); | |
971 std::string c_g = file_ops::canonicalize_file_name (g); | |
972 | |
973 file_stat f_fs (c_f); | |
974 file_stat g_fs (c_g); | |
975 | |
976 return (f_fs.ino () == g_fs.ino () && f_fs.dev () == g_fs.dev ()); | |
977 } | |
978 | |
979 bool | 965 bool |
980 fcn_out_of_date (octave_function *fcn, const std::string& ff, time_t tp) | 966 fcn_out_of_date (octave_function *fcn, const std::string& ff, time_t tp) |
981 { | 967 { |
982 bool retval = false; | 968 bool retval = false; |
983 | 969 |
1018 { | 1004 { |
1019 std::string ff = fcn->fcn_file_name (); | 1005 std::string ff = fcn->fcn_file_name (); |
1020 | 1006 |
1021 if (! ff.empty ()) | 1007 if (! ff.empty ()) |
1022 { | 1008 { |
1023 if (fcn->time_checked () < Vlast_prompt_time) | 1009 octave_time tc = fcn->time_checked (); |
1010 | |
1011 bool relative = fcn->is_relative (); | |
1012 | |
1013 if (tc < Vlast_prompt_time | |
1014 || (relative && tc < Vlast_chdir_time)) | |
1024 { | 1015 { |
1025 time_t tp = fcn->time_parsed (); | 1016 time_t tp = fcn->time_parsed (); |
1026 | 1017 |
1027 std::string nm = fcn->name (); | 1018 std::string nm = fcn->name (); |
1028 | 1019 |
1045 else | 1036 else |
1046 { | 1037 { |
1047 file = lookup_autoload (nm); | 1038 file = lookup_autoload (nm); |
1048 | 1039 |
1049 if (file.empty ()) | 1040 if (file.empty ()) |
1050 { | 1041 file = load_path::find_fcn (nm); |
1051 file = octave_env::make_absolute | 1042 |
1052 (load_path::find_fcn (nm), octave_env::getcwd ()); | 1043 file = octave_env::make_absolute (file, octave_env::getcwd ()); |
1053 } | |
1054 } | 1044 } |
1055 | 1045 |
1056 if (same_file (file, ff)) | 1046 if (relative && file.empty ()) |
1047 { | |
1048 // Can't see this function from current | |
1049 // directory, so we should clear it. | |
1050 | |
1051 sr->clear (); | |
1052 | |
1053 retval = true; | |
1054 } | |
1055 else if (same_file (file, ff)) | |
1057 { | 1056 { |
1058 retval = fcn_out_of_date (fcn, ff, tp); | 1057 retval = fcn_out_of_date (fcn, ff, tp); |
1059 } | 1058 } |
1060 else | 1059 else |
1061 { | 1060 { |
1062 // Check the full function name. Maybe we alrady | 1061 // Check the full function name. Maybe we already |
1063 // parsed it. | 1062 // parsed it. |
1064 | 1063 |
1065 symbol_record *full_sr = fbi_sym_tab->lookup (file); | 1064 symbol_record *full_sr = fbi_sym_tab->lookup (file); |
1066 | 1065 |
1067 if (full_sr) | 1066 if (full_sr) |
1145 | 1144 |
1146 return sym_rec; | 1145 return sym_rec; |
1147 } | 1146 } |
1148 | 1147 |
1149 octave_value | 1148 octave_value |
1150 lookup_function (const std::string& nm) | 1149 lookup_function (const std::string& nm, const std::string& parent) |
1151 { | 1150 { |
1152 octave_value retval; | 1151 octave_value retval; |
1153 | 1152 |
1154 symbol_record *sr = 0; | 1153 symbol_record *sr = 0; |
1155 | 1154 |
1156 if (curr_parent_function) | 1155 if (! parent.empty ()) |
1157 { | 1156 sr = fbi_sym_tab->lookup (parent + ":" + nm); |
1158 std::string parent = curr_parent_function->name (); | 1157 |
1159 | 1158 if (! sr || ! sr->is_function () && curr_parent_function) |
1160 sr = fbi_sym_tab->lookup (parent + ":" + nm); | 1159 sr = fbi_sym_tab->lookup (curr_parent_function->name () + ":" + nm); |
1161 } | |
1162 | 1160 |
1163 if (! sr || ! sr->is_function ()) | 1161 if (! sr || ! sr->is_function ()) |
1164 { | 1162 { |
1165 sr = fbi_sym_tab->lookup (nm, true); | 1163 sr = fbi_sym_tab->lookup (nm, true); |
1166 | 1164 |
1462 { | 1460 { |
1463 std::string nm = sr->name (); | 1461 std::string nm = sr->name (); |
1464 | 1462 |
1465 symbol_record *tmp_sym = 0; | 1463 symbol_record *tmp_sym = 0; |
1466 | 1464 |
1467 if (curr_parent_function) | 1465 octave_function *fcn = octave_call_stack::current (); |
1468 { | 1466 |
1469 std::string parent = curr_parent_function->name (); | 1467 std::string parent = fcn ? fcn->parent_fcn_name () : std::string (); |
1470 | 1468 |
1471 tmp_sym = fbi_sym_tab->lookup (parent + ":" + nm); | 1469 if (! parent.empty ()) |
1472 } | 1470 tmp_sym = fbi_sym_tab->lookup (parent + ":" + nm); |
1471 | |
1472 if (! tmp_sym && curr_parent_function) | |
1473 tmp_sym = fbi_sym_tab->lookup (curr_parent_function->name () + ":" + nm); | |
1473 | 1474 |
1474 if (! tmp_sym) | 1475 if (! tmp_sym) |
1475 tmp_sym = fbi_sym_tab->lookup (nm); | 1476 tmp_sym = fbi_sym_tab->lookup (nm); |
1476 | 1477 |
1477 if (tmp_sym | 1478 if (tmp_sym |