author | wenzelm |
Sun, 10 Feb 2008 20:49:48 +0100 | |
changeset 26054 | 345e495d3b92 |
parent 25840 | 8a84f00f7139 |
child 26109 | c69c3559355b |
permissions | -rw-r--r-- |
6346 | 1 |
(* Title: Pure/Isar/session.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
4 |
||
5 |
Session management -- maintain state of logic images. |
|
6 |
*) |
|
7 |
||
8 |
signature SESSION = |
|
9 |
sig |
|
25840 | 10 |
val id: unit -> string list |
11509 | 11 |
val name: unit -> string |
6346 | 12 |
val welcome: unit -> string |
24061 | 13 |
val use_dir: string -> bool -> string list -> bool -> bool -> string -> bool -> string list -> |
24118 | 14 |
string -> string -> bool * string -> string -> int -> bool -> int -> int -> unit |
6346 | 15 |
val finish: unit -> unit |
16 |
end; |
|
17 |
||
18 |
structure Session: SESSION = |
|
19 |
struct |
|
20 |
||
21 |
||
22 |
(* session state *) |
|
23 |
||
16451 | 24 |
val session = ref ([Context.PureN]: string list); |
6346 | 25 |
val session_path = ref ([]: string list); |
26 |
val session_finished = ref false; |
|
15979 | 27 |
val remote_path = ref (NONE: Url.T option); |
9414 | 28 |
|
29 |
||
30 |
(* access path *) |
|
6346 | 31 |
|
25840 | 32 |
fun id () = ! session; |
6346 | 33 |
fun path () = ! session_path; |
34 |
||
16451 | 35 |
fun str_of [] = Context.PureN |
6346 | 36 |
| str_of elems = space_implode "/" elems; |
37 |
||
11509 | 38 |
fun name () = "Isabelle/" ^ str_of (path ()); |
39 |
fun welcome () = "Welcome to " ^ name () ^ " (" ^ version ^ ")"; |
|
6346 | 40 |
|
41 |
||
9414 | 42 |
(* add_path *) |
43 |
||
44 |
fun add_path reset s = |
|
45 |
let val sess = ! session @ [s] in |
|
18964 | 46 |
(case duplicates (op =) sess of |
9414 | 47 |
[] => (session := sess; session_path := ((if reset then [] else ! session_path) @ [s])) |
48 |
| dups => error ("Duplicate session identifiers " ^ commas_quote dups ^ " in " ^ str_of sess)) |
|
49 |
end; |
|
50 |
||
51 |
||
6346 | 52 |
(* init *) |
53 |
||
54 |
fun init reset parent name = |
|
20664 | 55 |
if not (member (op =) (! session) parent) orelse not (! session_finished) then |
6346 | 56 |
error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name) |
57 |
else (add_path reset name; session_finished := false); |
|
58 |
||
59 |
||
60 |
(* finish *) |
|
61 |
||
62 |
fun finish () = |
|
16728 | 63 |
(Output.accumulated_time (); |
64 |
ThyInfo.finish (); |
|
6346 | 65 |
Present.finish (); |
21957 | 66 |
Toplevel.init_state (); |
6346 | 67 |
session_finished := true); |
68 |
||
69 |
||
70 |
(* use_dir *) |
|
71 |
||
17207 | 72 |
fun get_rpath rpath = |
73 |
(if rpath = "" then () else |
|
15979 | 74 |
if is_some (! remote_path) then |
7227
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
75 |
error "Path for remote theory browsing information may only be set once" |
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
76 |
else |
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20664
diff
changeset
|
77 |
remote_path := SOME (Url.explode rpath); |
17207 | 78 |
(! remote_path, rpath <> "")); |
79 |
||
80 |
fun dumping (_, "") = NONE |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20664
diff
changeset
|
81 |
| dumping (cp, path) = SOME (cp, Path.explode path); |
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
82 |
|
17074 | 83 |
fun use_dir root build modes reset info doc doc_graph doc_versions |
24061 | 84 |
parent name dump rpath level verbose max_threads trace_threads = |
23972 | 85 |
((fn () => |
86 |
(init reset parent name; |
|
87 |
Present.init build info doc doc_graph doc_versions (path ()) name |
|
88 |
(dumping dump) (get_rpath rpath) verbose (map ThyInfo.theory (ThyInfo.names ())); |
|
25703
832073e402ae
removed obsolete use_noncritical (plain use is already non-critical);
wenzelm
parents:
24612
diff
changeset
|
89 |
use root; |
23972 | 90 |
finish ())) |
91 |
|> setmp_noncritical Proofterm.proofs level |
|
24612 | 92 |
|> setmp_noncritical print_mode (modes @ print_mode_value ()) |
24061 | 93 |
|> setmp_noncritical Multithreading.trace trace_threads |
23979 | 94 |
|> setmp_noncritical Multithreading.max_threads |
95 |
(if Multithreading.available then max_threads |
|
96 |
else (if max_threads = 1 then () else warning "Multithreading support unavailable"; 1))) () |
|
18683 | 97 |
handle exn => (Output.error_msg (Toplevel.exn_message exn); exit 1); |
6346 | 98 |
|
99 |
end; |