equal
deleted
inserted
replaced
10 - put_theory: |
10 - put_theory: |
11 . allow for undef entry only; |
11 . allow for undef entry only; |
12 . elim (via theory_ref); |
12 . elim (via theory_ref); |
13 - stronger handling of missing files (!?!?); |
13 - stronger handling of missing files (!?!?); |
14 - register_theory: do not require final parents (!?) (no?); |
14 - register_theory: do not require final parents (!?) (no?); |
15 - observe verbose flag; |
15 - hooks for init, update, finish operations (!?); |
16 *) |
16 *) |
17 |
17 |
18 signature BASIC_THY_INFO = |
18 signature BASIC_THY_INFO = |
19 sig |
19 sig |
20 val theory: string -> theory |
20 val theory: string -> theory |
29 end; |
29 end; |
30 |
30 |
31 signature THY_INFO = |
31 signature THY_INFO = |
32 sig |
32 sig |
33 include BASIC_THY_INFO |
33 include BASIC_THY_INFO |
34 val verbose: bool ref |
|
35 val names: unit -> string list |
34 val names: unit -> string list |
36 val get_theory: string -> theory |
35 val get_theory: string -> theory |
37 val put_theory: theory -> unit |
36 val put_theory: theory -> unit |
38 val loaded_files: string -> (Path.T * File.info) list |
37 val loaded_files: string -> (Path.T * File.info) list |
39 val load_file: bool -> Path.T -> unit |
38 val load_file: bool -> Path.T -> unit |
61 |
60 |
62 val show_path = space_implode " via " o map quote; |
61 val show_path = space_implode " via " o map quote; |
63 fun cycle_msg name names = loader_msg ("cyclic dependency of " ^ show_path (name :: names)) []; |
62 fun cycle_msg name names = loader_msg ("cyclic dependency of " ^ show_path (name :: names)) []; |
64 |
63 |
65 |
64 |
66 (* verbose mode *) |
|
67 |
|
68 val verbose = ref false; |
|
69 |
|
70 fun if_verbose f x = if ! verbose then f x else (); |
|
71 |
|
72 |
|
73 (* derived graph operations *) (* FIXME more abstract (!?) *) |
65 (* derived graph operations *) (* FIXME more abstract (!?) *) |
74 |
66 |
75 fun add_deps name parents G = |
67 fun add_deps name parents G = |
76 foldl (fn (H, parent) => Graph.add_edge_acyclic (parent, name) H) (G, parents) |
68 foldl (fn (H, parent) => Graph.add_edge_acyclic (parent, name) H) (G, parents) |
77 handle Graph.CYCLES namess => error (cat_lines (map (cycle_msg name) namess)); |
69 handle Graph.CYCLES namess => error (cat_lines (map (cycle_msg name) namess)); |
204 let |
196 let |
205 fun provide name info (deps as Some {present, outdated, master, files}) = |
197 fun provide name info (deps as Some {present, outdated, master, files}) = |
206 if exists (equal path o #1) files then |
198 if exists (equal path o #1) files then |
207 Some (make_deps present outdated master (overwrite (files, (path, Some info)))) |
199 Some (make_deps present outdated master (overwrite (files, (path, Some info)))) |
208 else (warning (loader_msg "undeclared dependency of theory" [name] ^ |
200 else (warning (loader_msg "undeclared dependency of theory" [name] ^ |
209 "\nfile: " ^ quote (Path.pack path)); deps) |
201 "on file: " ^ quote (Path.pack path)); deps) |
210 | provide _ _ None = None; |
202 | provide _ _ None = None; |
211 in |
203 in |
212 (case apsome PureThy.get_name (Context.get_context ()) of |
204 (case apsome PureThy.get_name (Context.get_context ()) of |
213 None => (ThyLoad.load_file path; ()) |
205 None => (ThyLoad.load_file path; ()) |
214 | Some name => |
206 | Some name => |