equal
deleted
inserted
replaced
254 local |
254 local |
255 |
255 |
256 fun provide path name info (deps as SOME {present, outdated, master, files}) = |
256 fun provide path name info (deps as SOME {present, outdated, master, files}) = |
257 (if exists (equal path o #1) files then () |
257 (if exists (equal path o #1) files then () |
258 else warning (loader_msg "undeclared dependency of theory" [name] ^ |
258 else warning (loader_msg "undeclared dependency of theory" [name] ^ |
259 " on file: " ^ quote (Path.pack path)); |
259 " on file: " ^ quote (Path.implode path)); |
260 SOME (make_deps present outdated master (AList.update (op =) (path, SOME info) files))) |
260 SOME (make_deps present outdated master (AList.update (op =) (path, SOME info) files))) |
261 | provide _ _ _ NONE = NONE; |
261 | provide _ _ _ NONE = NONE; |
262 |
262 |
263 fun run_file path = |
263 fun run_file path = |
264 (case Option.map Context.theory_name (Context.get_context ()) of |
264 (case Option.map Context.theory_name (Context.get_context ()) of |
270 |
270 |
271 in |
271 in |
272 |
272 |
273 fun load_file time path = Output.toplevel_errors (fn () => |
273 fun load_file time path = Output.toplevel_errors (fn () => |
274 if time then |
274 if time then |
275 let val name = Path.pack path in |
275 let val name = Path.implode path in |
276 timeit (fn () => |
276 timeit (fn () => |
277 (priority ("\n**** Starting file " ^ quote name ^ " ****"); |
277 (priority ("\n**** Starting file " ^ quote name ^ " ****"); |
278 run_file path; |
278 run_file path; |
279 priority ("**** Finished file " ^ quote name ^ " ****\n"))) |
279 priority ("**** Finished file " ^ quote name ^ " ****\n"))) |
280 end |
280 end |
281 else run_file path) (); |
281 else run_file path) (); |
282 |
282 |
283 val use = load_file false o Path.unpack; |
283 val use = load_file false o Path.explode; |
284 val time_use = load_file true o Path.unpack; |
284 val time_use = load_file true o Path.explode; |
285 |
285 |
286 end; |
286 end; |
287 |
287 |
288 |
288 |
289 (* load_thy *) |
289 (* load_thy *) |
301 val master = |
301 val master = |
302 if really then ThyLoad.load_thy dir name ml time |
302 if really then ThyLoad.load_thy dir name ml time |
303 else #1 (ThyLoad.deps_thy dir name ml); |
303 else #1 (ThyLoad.deps_thy dir name ml); |
304 |
304 |
305 val files = get_files name; |
305 val files = get_files name; |
306 val missing_files = map_filter (fn (path, NONE) => SOME (Path.pack path) | _ => NONE) files; |
306 val missing_files = map_filter (fn (path, NONE) => SOME (Path.implode path) | _ => NONE) files; |
307 in |
307 in |
308 if null missing_files then () |
308 if null missing_files then () |
309 else warning (loader_msg "unresolved dependencies of theory" [name] ^ |
309 else warning (loader_msg "unresolved dependencies of theory" [name] ^ |
310 " on file(s): " ^ commas_quote missing_files); |
310 " on file(s): " ^ commas_quote missing_files); |
311 change_deps name (fn _ => SOME (make_deps true false (SOME master) files)); |
311 change_deps name (fn _ => SOME (make_deps true false (SOME master) files)); |
313 end; |
313 end; |
314 |
314 |
315 |
315 |
316 (* require_thy *) |
316 (* require_thy *) |
317 |
317 |
318 fun base_of_path s = Path.pack (Path.base (Path.unpack s)); |
318 fun base_of_path s = Path.implode (Path.base (Path.explode s)); |
319 |
319 |
320 local |
320 local |
321 |
321 |
322 fun load_deps ml dir name = |
322 fun load_deps ml dir name = |
323 let val (master, (parents, files)) = ThyLoad.deps_thy dir name ml |
323 let val (master, (parents, files)) = ThyLoad.deps_thy dir name ml |
331 (case lookup_deps name of |
331 (case lookup_deps name of |
332 NONE => (false, load_deps ml dir name) |
332 NONE => (false, load_deps ml dir name) |
333 | SOME deps => |
333 | SOME deps => |
334 let |
334 let |
335 fun get_name s = (case opt_path'' (lookup_deps s) of NONE => s |
335 fun get_name s = (case opt_path'' (lookup_deps s) of NONE => s |
336 | SOME p => Path.pack (Path.append p (Path.basic s))); |
336 | SOME p => Path.implode (Path.append p (Path.basic s))); |
337 val same_deps = (NONE, map get_name (thy_graph Graph.imm_preds name)) |
337 val same_deps = (NONE, map get_name (thy_graph Graph.imm_preds name)) |
338 in |
338 in |
339 (case deps of |
339 (case deps of |
340 NONE => (true, same_deps) |
340 NONE => (true, same_deps) |
341 | SOME {present, outdated, master, files} => |
341 | SOME {present, outdated, master, files} => |
347 end) |
347 end) |
348 end); |
348 end); |
349 |
349 |
350 fun require_thy really ml time strict keep_strict initiators prfx (visited, str) = |
350 fun require_thy really ml time strict keep_strict initiators prfx (visited, str) = |
351 let |
351 let |
352 val path = Path.expand (Path.unpack str); |
352 val path = Path.expand (Path.explode str); |
353 val name = Path.pack (Path.base path); |
353 val name = Path.implode (Path.base path); |
354 in |
354 in |
355 if member (op =) initiators name then error (cycle_msg initiators) else (); |
355 if member (op =) initiators name then error (cycle_msg initiators) else (); |
356 if known_thy name andalso is_finished name orelse member (op =) visited name then |
356 if known_thy name andalso is_finished name orelse member (op =) visited name then |
357 (visited, (true, name)) |
357 (visited, (true, name)) |
358 else |
358 else |
420 |
420 |
421 fun check_uses name uses = |
421 fun check_uses name uses = |
422 let val illegal = map (fn ext => Path.ext ext (Path.basic name)) ThyLoad.ml_exts in |
422 let val illegal = map (fn ext => Path.ext ext (Path.basic name)) ThyLoad.ml_exts in |
423 (case find_first (member (op =) illegal o Path.base o Path.expand o #1) uses of |
423 (case find_first (member (op =) illegal o Path.base o Path.expand o #1) uses of |
424 NONE => () |
424 NONE => () |
425 | SOME (path, _) => error ("Illegal use of theory ML file: " ^ quote (Path.pack path))) |
425 | SOME (path, _) => error ("Illegal use of theory ML file: " ^ quote (Path.implode path))) |
426 end; |
426 end; |
427 |
427 |
428 fun begin_theory present name parents uses int = |
428 fun begin_theory present name parents uses int = |
429 let |
429 let |
430 val bparents = map base_of_path parents; |
430 val bparents = map base_of_path parents; |