247 if master <> master' then (false, load_deps dir name ml) |
247 if master <> master' then (false, load_deps dir name ml) |
248 else (not outdated andalso forall file_current files, same_deps) |
248 else (not outdated andalso forall file_current files, same_deps) |
249 end) |
249 end) |
250 end); |
250 end); |
251 |
251 |
252 fun require_thy ml time strict keep_strict initiators s = |
252 fun require_thy ml time strict keep_strict initiators prfx s = |
253 let |
253 let |
254 val path = Path.expand (Path.unpack s); |
254 val path = Path.expand (Path.unpack s); |
255 val name = Path.pack (Path.base path); |
255 val name = Path.pack (Path.base path); |
256 val dir = Path.dir path; |
256 val dir = Path.append prfx (Path.dir path); |
257 val opt_dir = if Path.is_current dir then None else Some dir; |
|
258 |
257 |
259 val require_parent = |
258 val require_parent = |
260 #1 o require_thy ml time (strict andalso keep_strict) keep_strict (name :: initiators); |
259 #1 o require_thy ml time (strict andalso keep_strict) keep_strict (name :: initiators) dir; |
261 val (current, (new_deps, parents)) = current_deps ml strict opt_dir name handle ERROR => |
260 val (current, (new_deps, parents)) = current_deps ml strict dir name handle ERROR => |
262 error (loader_msg "The error(s) above occurred while examining theory" [name] ^ |
261 error (loader_msg "The error(s) above occurred while examining theory" [name] ^ |
263 (if null initiators then "" else "\n" ^ required_by initiators)); |
262 (if null initiators then "" else "\n" ^ required_by initiators)); |
264 val parents_current = map require_parent parents; |
263 val parents_current = map require_parent parents; |
265 |
264 |
266 val result = |
265 val result = |
267 if current andalso forall I parents_current then true |
266 if current andalso forall I parents_current then true |
268 else |
267 else |
269 ((case new_deps of |
268 ((case new_deps of |
270 Some deps => change_thys (update_node name parents (untouch_deps deps, None)) |
269 Some deps => change_thys (update_node name parents (untouch_deps deps, None)) |
271 | None => ()); |
270 | None => ()); |
272 load_thy ml time initiators opt_dir name parents; |
271 load_thy ml time initiators dir name parents; |
273 false); |
272 false); |
274 in (result, name) end; |
273 in (result, name) end; |
275 |
274 |
276 fun gen_use_thy f s = let val (_, name) = f s in Context.context (get_theory name) end; |
275 fun gen_use_thy f s = |
|
276 let val (_, name) = f Path.current s in Context.context (get_theory name) end; |
277 |
277 |
278 val weak_use_thy = gen_use_thy (require_thy true false false false []); |
278 val weak_use_thy = gen_use_thy (require_thy true false false false []); |
279 val use_thy = gen_use_thy (require_thy true false true false []); |
279 val use_thy = gen_use_thy (require_thy true false true false []); |
280 val update_thy = gen_use_thy (require_thy true false true true []); |
280 val update_thy = gen_use_thy (require_thy true false true true []); |
281 val time_use_thy = gen_use_thy (require_thy true true true false []); |
281 val time_use_thy = gen_use_thy (require_thy true true true false []); |