| author | wenzelm | 
| Wed, 08 Jun 2011 16:19:22 +0200 | |
| changeset 43279 | 6af741899bf6 | 
| parent 42003 | 6e45dc518ebb | 
| child 43700 | e4ece46a9ca7 | 
| permissions | -rw-r--r-- | 
| 6168 | 1 | (* Title: Pure/Thy/thy_load.ML | 
| 42002 | 2 | Author: Makarius | 
| 6168 | 3 | |
| 42002 | 4 | Loading files that contribute to a theory. Global master path. | 
| 6168 | 5 | *) | 
| 6 | ||
| 7 | signature THY_LOAD = | |
| 8 | sig | |
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 9 | val master_directory: theory -> Path.T | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 10 | val imports_of: theory -> string list | 
| 41955 
703ea96b13c6
files are identified via SHA1 digests -- discontinued ISABELLE_FILE_IDENT;
 wenzelm parents: 
41944diff
changeset | 11 | val provide: Path.T * (Path.T * SHA1.digest) -> theory -> theory | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 12 | val check_file: Path.T -> Path.T -> Path.T | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 13 | val check_thy: Path.T -> string -> | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 14 |     {master: Path.T * SHA1.digest, text: string, imports: string list, uses: (Path.T * bool) list}
 | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 15 | val loaded_files: theory -> Path.T list | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 16 | val all_current: theory -> bool | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 17 | val provide_file: Path.T -> theory -> theory | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 18 | val use_ml: Path.T -> unit | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 19 | val exec_ml: Path.T -> generic_theory -> generic_theory | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 20 | val begin_theory: Path.T -> string -> string list -> theory list -> (Path.T * bool) list -> theory | 
| 42002 | 21 | val set_master_path: Path.T -> unit | 
| 22 | val get_master_path: unit -> Path.T | |
| 6168 | 23 | end; | 
| 24 | ||
| 37216 
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
 wenzelm parents: 
33221diff
changeset | 25 | structure Thy_Load: THY_LOAD = | 
| 6168 | 26 | struct | 
| 27 | ||
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 28 | (* manage source files *) | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 29 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 30 | type files = | 
| 40741 
17d6293a1e26
moved file identification to thy_load.ML (where it is actually used);
 wenzelm parents: 
40625diff
changeset | 31 |  {master_dir: Path.T,  (*master directory of theory source*)
 | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 32 | imports: string list, (*source specification of imports*) | 
| 40741 
17d6293a1e26
moved file identification to thy_load.ML (where it is actually used);
 wenzelm parents: 
40625diff
changeset | 33 | required: Path.T list, (*source path*) | 
| 41955 
703ea96b13c6
files are identified via SHA1 digests -- discontinued ISABELLE_FILE_IDENT;
 wenzelm parents: 
41944diff
changeset | 34 | provided: (Path.T * (Path.T * SHA1.digest)) list}; (*source path, physical path, digest*) | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 35 | |
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 36 | fun make_files (master_dir, imports, required, provided): files = | 
| 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 37 |  {master_dir = master_dir, imports = imports, required = required, provided = provided};
 | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 38 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 39 | structure Files = Theory_Data | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 40 | ( | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 41 | type T = files; | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 42 | val empty = make_files (Path.current, [], [], []); | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 43 | fun extend _ = empty; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 44 | fun merge _ = empty; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 45 | ); | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 46 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 47 | fun map_files f = | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 48 |   Files.map (fn {master_dir, imports, required, provided} =>
 | 
| 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 49 | make_files (f (master_dir, imports, required, provided))); | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 50 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 51 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 52 | val master_directory = #master_dir o Files.get; | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 53 | val imports_of = #imports o Files.get; | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 54 | |
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 55 | fun put_deps dir imports = map_files (fn _ => (dir, imports, [], [])); | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 56 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 57 | fun require src_path = | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 58 | map_files (fn (master_dir, imports, required, provided) => | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 59 | if member (op =) required src_path then | 
| 41944 
b97091ae583a
Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
 wenzelm parents: 
41886diff
changeset | 60 |       error ("Duplicate source file dependency: " ^ Path.print src_path)
 | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 61 | else (master_dir, imports, src_path :: required, provided)); | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 62 | |
| 37978 
548f3f165d05
simplified Thy_Header.read -- include Source.of_string_limited here;
 wenzelm parents: 
37977diff
changeset | 63 | fun provide (src_path, path_id) = | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 64 | map_files (fn (master_dir, imports, required, provided) => | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 65 | if AList.defined (op =) provided src_path then | 
| 41944 
b97091ae583a
Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
 wenzelm parents: 
41886diff
changeset | 66 |       error ("Duplicate resolution of source file dependency: " ^ Path.print src_path)
 | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 67 | else (master_dir, imports, required, (src_path, path_id) :: provided)); | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 68 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 69 | |
| 23872 | 70 | (* check files *) | 
| 6232 | 71 | |
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 72 | fun check_file dir file = File.check_file (File.full_path dir file); | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 73 | |
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 74 | fun digest_file dir file = | 
| 6232 | 75 | let | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 76 | val full_path = check_file dir file; | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 77 | val id = SHA1.digest (File.read full_path); | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 78 | in (full_path, id) end; | 
| 37939 
965537d86fcc
discontinued special treatment of ML files -- no longer complete extensions on demand;
 wenzelm parents: 
37938diff
changeset | 79 | |
| 41886 | 80 | fun check_thy dir name = | 
| 23872 | 81 | let | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 82 | val master_file = check_file dir (Thy_Header.thy_path name); | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 83 | val text = File.read master_file; | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 84 | val (name', imports, uses) = | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 85 | if name = Context.PureN then (Context.PureN, [], []) | 
| 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 86 | else Thy_Header.read (Path.position master_file) text; | 
| 37950 
bc285d91041e
moved basic thy file name operations from Thy_Load to Thy_Header;
 wenzelm parents: 
37949diff
changeset | 87 | val _ = Thy_Header.consistent_name name name'; | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 88 |   in {master = (master_file, SHA1.digest text), text = text, imports = imports, uses = uses} end;
 | 
| 6168 | 89 | |
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 90 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 91 | (* loaded files *) | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 92 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 93 | val loaded_files = map (#1 o #2) o #provided o Files.get; | 
| 6168 | 94 | |
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 95 | fun check_loaded thy = | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 96 | let | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 97 |     val {required, provided, ...} = Files.get thy;
 | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 98 | val provided_paths = map #1 provided; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 99 | val _ = | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 100 | (case subtract (op =) provided_paths required of | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 101 | [] => NONE | 
| 41944 
b97091ae583a
Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
 wenzelm parents: 
41886diff
changeset | 102 |       | bad => error ("Pending source file dependencies: " ^ commas (map Path.print (rev bad))));
 | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 103 | val _ = | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 104 | (case subtract (op =) required provided_paths of | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 105 | [] => NONE | 
| 41944 
b97091ae583a
Path.print is the official way to show file-system paths to users -- note that Path.implode often indicates violation of the abstract datatype;
 wenzelm parents: 
41886diff
changeset | 106 |       | bad => error ("Undeclared source file dependencies: " ^ commas (map Path.print (rev bad))));
 | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 107 | in () end; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 108 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 109 | fun all_current thy = | 
| 37939 
965537d86fcc
discontinued special treatment of ML files -- no longer complete extensions on demand;
 wenzelm parents: 
37938diff
changeset | 110 | let | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 111 |     val {master_dir, provided, ...} = Files.get thy;
 | 
| 37978 
548f3f165d05
simplified Thy_Header.read -- include Source.of_string_limited here;
 wenzelm parents: 
37977diff
changeset | 112 | fun current (src_path, (_, id)) = | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 113 | (case try (digest_file master_dir) src_path of | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 114 | NONE => false | 
| 41886 | 115 | | SOME (_, id') => id = id'); | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 116 | in can check_loaded thy andalso forall current provided end; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 117 | |
| 37952 | 118 | val _ = Context.>> (Context.map_theory (Theory.at_end (fn thy => (check_loaded thy; NONE)))); | 
| 119 | ||
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 120 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 121 | (* provide files *) | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 122 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 123 | fun provide_file src_path thy = | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 124 | provide (src_path, digest_file (master_directory thy) src_path) thy; | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 125 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 126 | fun use_ml src_path = | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 127 | if is_none (Context.thread_data ()) then | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 128 | ML_Context.eval_file (check_file Path.current src_path) | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 129 | else | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 130 | let | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 131 | val thy = ML_Context.the_global_context (); | 
| 42003 
6e45dc518ebb
replaced File.check by specific File.check_file, File.check_dir;
 wenzelm parents: 
42002diff
changeset | 132 | val (path, id) = digest_file (master_directory thy) src_path; | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 133 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 134 | val _ = ML_Context.eval_file path; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 135 | val _ = Context.>> Local_Theory.propagate_ml_env; | 
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 136 | |
| 37978 
548f3f165d05
simplified Thy_Header.read -- include Source.of_string_limited here;
 wenzelm parents: 
37977diff
changeset | 137 | val provide = provide (src_path, (path, id)); | 
| 38757 
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
 wenzelm parents: 
38133diff
changeset | 138 | val _ = Context.>> (Context.mapping provide (Local_Theory.background_theory provide)); | 
| 37978 
548f3f165d05
simplified Thy_Header.read -- include Source.of_string_limited here;
 wenzelm parents: 
37977diff
changeset | 139 | in () end; | 
| 37949 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 140 | |
| 
48a874444164
moved management of auxiliary theory source files to Thy_Load -- as theory data instead of accidental loader state;
 wenzelm parents: 
37943diff
changeset | 141 | fun exec_ml src_path = ML_Context.exec (fn () => use_ml src_path); | 
| 6168 | 142 | |
| 37977 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 143 | |
| 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 144 | (* begin theory *) | 
| 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 145 | |
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 146 | fun begin_theory dir name imports parents uses = | 
| 37977 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 147 | Theory.begin_theory name parents | 
| 41548 
bd0bebf93fa6
Thy_Load.begin_theory: maintain source specification of imports;
 wenzelm parents: 
41414diff
changeset | 148 | |> put_deps dir imports | 
| 37977 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 149 | |> fold (require o fst) uses | 
| 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 150 | |> fold (fn (path, true) => Context.theory_map (exec_ml path) o Theory.checkpoint | _ => I) uses | 
| 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 151 | |> Theory.checkpoint; | 
| 
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
 wenzelm parents: 
37952diff
changeset | 152 | |
| 42002 | 153 | |
| 154 | (* global master path *) | |
| 155 | ||
| 156 | local | |
| 157 | val master_path = Unsynchronized.ref Path.current; | |
| 158 | in | |
| 159 | ||
| 160 | fun set_master_path path = master_path := path; | |
| 161 | fun get_master_path () = ! master_path; | |
| 162 | ||
| 6168 | 163 | end; | 
| 164 | ||
| 42002 | 165 | end; |