equal
deleted
inserted
replaced
12 val get_theory: string -> theory |
12 val get_theory: string -> theory |
13 val pure_theory: unit -> theory |
13 val pure_theory: unit -> theory |
14 val master_directory: string -> Path.T |
14 val master_directory: string -> Path.T |
15 val remove_thy: string -> unit |
15 val remove_thy: string -> unit |
16 val use_theories: |
16 val use_theories: |
17 {document: bool, last_timing: Toplevel.transition -> Time.time option, master_dir: Path.T} -> |
17 {document: bool, |
18 (string * Position.T) list -> unit |
18 symbols: HTML.symbols, |
|
19 last_timing: Toplevel.transition -> Time.time option, |
|
20 master_dir: Path.T} -> (string * Position.T) list -> unit |
19 val use_thys: (string * Position.T) list -> unit |
21 val use_thys: (string * Position.T) list -> unit |
20 val use_thy: string * Position.T -> unit |
22 val use_thy: string * Position.T -> unit |
21 val script_thy: Position.T -> string -> theory -> theory |
23 val script_thy: Position.T -> string -> theory -> theory |
22 val register_thy: theory -> unit |
24 val register_thy: theory -> unit |
23 val finish: unit -> unit |
25 val finish: unit -> unit |
235 local |
237 local |
236 |
238 |
237 fun required_by _ [] = "" |
239 fun required_by _ [] = "" |
238 | required_by s initiators = s ^ "(required by " ^ show_path (rev initiators) ^ ")"; |
240 | required_by s initiators = s ^ "(required by " ^ show_path (rev initiators) ^ ")"; |
239 |
241 |
240 fun load_thy document last_timing initiators update_time deps text (name, pos) keywords parents = |
242 fun load_thy document symbols last_timing |
|
243 initiators update_time deps text (name, pos) keywords parents = |
241 let |
244 let |
242 val _ = remove_thy name; |
245 val _ = remove_thy name; |
243 val _ = writeln ("Loading theory " ^ quote name ^ required_by " " initiators); |
246 val _ = writeln ("Loading theory " ^ quote name ^ required_by " " initiators); |
244 val _ = Output.try_protocol_message (Markup.loading_theory name) []; |
247 val _ = Output.try_protocol_message (Markup.loading_theory name) []; |
245 |
248 |
254 Execution.running Document_ID.none exec_id [] orelse |
257 Execution.running Document_ID.none exec_id [] orelse |
255 raise Fail ("Failed to register execution: " ^ Document_ID.print exec_id); |
258 raise Fail ("Failed to register execution: " ^ Document_ID.print exec_id); |
256 |
259 |
257 val text_pos = Position.put_id (Document_ID.print exec_id) (Path.position thy_path); |
260 val text_pos = Position.put_id (Document_ID.print exec_id) (Path.position thy_path); |
258 val (theory, present, weight) = |
261 val (theory, present, weight) = |
259 Resources.load_thy document last_timing update_time dir header text_pos text |
262 Resources.load_thy document symbols last_timing update_time dir header text_pos text |
260 (if name = Context.PureN then [ML_Context.the_global_context ()] else parents); |
263 (if name = Context.PureN then [ML_Context.the_global_context ()] else parents); |
261 fun commit () = update_thy deps theory; |
264 fun commit () = update_thy deps theory; |
262 in |
265 in |
263 Result {theory = theory, exec_id = exec_id, present = present, commit = commit, weight = weight} |
266 Result {theory = theory, exec_id = exec_id, present = present, commit = commit, weight = weight} |
264 end; |
267 end; |
281 | SOME theory => Resources.loaded_files_current theory); |
284 | SOME theory => Resources.loaded_files_current theory); |
282 in (current, deps', theory_pos', imports', keywords') end); |
285 in (current, deps', theory_pos', imports', keywords') end); |
283 |
286 |
284 in |
287 in |
285 |
288 |
286 fun require_thys document last_timing initiators dir strs tasks = |
289 fun require_thys document symbols last_timing initiators dir strs tasks = |
287 fold_map (require_thy document last_timing initiators dir) strs tasks |>> forall I |
290 fold_map (require_thy document symbols last_timing initiators dir) strs tasks |>> forall I |
288 and require_thy document last_timing initiators dir (str, require_pos) tasks = |
291 and require_thy document symbols last_timing initiators dir (str, require_pos) tasks = |
289 let |
292 let |
290 val path = Path.expand (Path.explode str); |
293 val path = Path.expand (Path.explode str); |
291 val name = Path.implode (Path.base path); |
294 val name = Path.implode (Path.base path); |
292 val node_name = File.full_path dir (Resources.thy_path path); |
295 val node_name = File.full_path dir (Resources.thy_path path); |
293 fun check_entry (Task (node_name', _, _)) = |
296 fun check_entry (Task (node_name', _, _)) = |
313 ("The error(s) above occurred for theory " ^ quote name ^ |
316 ("The error(s) above occurred for theory " ^ quote name ^ |
314 Position.here require_pos ^ required_by "\n" initiators); |
317 Position.here require_pos ^ required_by "\n" initiators); |
315 |
318 |
316 val parents = map (base_name o #1) imports; |
319 val parents = map (base_name o #1) imports; |
317 val (parents_current, tasks') = |
320 val (parents_current, tasks') = |
318 require_thys document last_timing (name :: initiators) |
321 require_thys document symbols last_timing (name :: initiators) |
319 (Path.append dir (master_dir (Option.map #1 deps))) imports tasks; |
322 (Path.append dir (master_dir (Option.map #1 deps))) imports tasks; |
320 |
323 |
321 val all_current = current andalso parents_current; |
324 val all_current = current andalso parents_current; |
322 val task = |
325 val task = |
323 if all_current then Finished (get_theory name) |
326 if all_current then Finished (get_theory name) |
326 NONE => raise Fail "Malformed deps" |
329 NONE => raise Fail "Malformed deps" |
327 | SOME (dep, text) => |
330 | SOME (dep, text) => |
328 let |
331 let |
329 val update_time = serial (); |
332 val update_time = serial (); |
330 val load = |
333 val load = |
331 load_thy document last_timing initiators update_time dep |
334 load_thy document symbols last_timing initiators update_time dep |
332 text (name, theory_pos) keywords; |
335 text (name, theory_pos) keywords; |
333 in Task (node_name, parents, load) end); |
336 in Task (node_name, parents, load) end); |
334 |
337 |
335 val tasks'' = new_entry name parents task tasks'; |
338 val tasks'' = new_entry name parents task tasks'; |
336 in (all_current, tasks'') end) |
339 in (all_current, tasks'') end) |
339 end; |
342 end; |
340 |
343 |
341 |
344 |
342 (* use_thy *) |
345 (* use_thy *) |
343 |
346 |
344 fun use_theories {document, last_timing, master_dir} imports = |
347 fun use_theories {document, symbols, last_timing, master_dir} imports = |
345 schedule_tasks (snd (require_thys document last_timing [] master_dir imports String_Graph.empty)); |
348 schedule_tasks |
346 |
349 (snd (require_thys document symbols last_timing [] master_dir imports String_Graph.empty)); |
347 val use_thys = use_theories {document = false, last_timing = K NONE, master_dir = Path.current}; |
350 |
|
351 val use_thys = |
|
352 use_theories |
|
353 {document = false, symbols = HTML.no_symbols, last_timing = K NONE, master_dir = Path.current}; |
|
354 |
348 val use_thy = use_thys o single; |
355 val use_thy = use_thys o single; |
349 |
356 |
350 |
357 |
351 (* toplevel scripting -- without maintaining database *) |
358 (* toplevel scripting -- without maintaining database *) |
352 |
359 |