author | wenzelm |
Sun, 09 Apr 2006 18:51:20 +0200 | |
changeset 19385 | c0f2f8224ea8 |
parent 18964 | 67f572e03236 |
child 20664 | ffbc5a57191a |
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 |
|
11509 | 10 |
val name: unit -> string |
6346 | 11 |
val welcome: unit -> string |
17074 | 12 |
val use_dir: string -> bool -> string list -> bool -> bool -> string -> bool -> |
17207 | 13 |
string list -> string -> string -> bool * string -> string -> int -> bool -> unit |
6346 | 14 |
val finish: unit -> unit |
15 |
end; |
|
16 |
||
17 |
structure Session: SESSION = |
|
18 |
struct |
|
19 |
||
20 |
||
21 |
(* session state *) |
|
22 |
||
16451 | 23 |
val session = ref ([Context.PureN]: string list); |
6346 | 24 |
val session_path = ref ([]: string list); |
25 |
val session_finished = ref false; |
|
15979 | 26 |
val remote_path = ref (NONE: Url.T option); |
9414 | 27 |
|
28 |
||
29 |
(* access path *) |
|
6346 | 30 |
|
31 |
fun path () = ! session_path; |
|
32 |
||
16451 | 33 |
fun str_of [] = Context.PureN |
6346 | 34 |
| str_of elems = space_implode "/" elems; |
35 |
||
11509 | 36 |
fun name () = "Isabelle/" ^ str_of (path ()); |
37 |
fun welcome () = "Welcome to " ^ name () ^ " (" ^ version ^ ")"; |
|
6346 | 38 |
|
39 |
||
9414 | 40 |
(* add_path *) |
41 |
||
42 |
fun add_path reset s = |
|
43 |
let val sess = ! session @ [s] in |
|
18964 | 44 |
(case duplicates (op =) sess of |
9414 | 45 |
[] => (session := sess; session_path := ((if reset then [] else ! session_path) @ [s])) |
46 |
| dups => error ("Duplicate session identifiers " ^ commas_quote dups ^ " in " ^ str_of sess)) |
|
47 |
end; |
|
48 |
||
49 |
||
6346 | 50 |
(* init *) |
51 |
||
52 |
fun init reset parent name = |
|
53 |
if not (parent mem_string (! session)) orelse not (! session_finished) then |
|
54 |
error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name) |
|
55 |
else (add_path reset name; session_finished := false); |
|
56 |
||
57 |
||
58 |
(* finish *) |
|
59 |
||
60 |
fun finish () = |
|
16728 | 61 |
(Output.accumulated_time (); |
62 |
ThyInfo.finish (); |
|
6346 | 63 |
Present.finish (); |
64 |
session_finished := true); |
|
65 |
||
66 |
||
67 |
(* use_dir *) |
|
68 |
||
17207 | 69 |
fun get_rpath rpath = |
70 |
(if rpath = "" then () else |
|
15979 | 71 |
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
|
72 |
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
|
73 |
else |
17207 | 74 |
remote_path := SOME (Url.unpack rpath); |
75 |
(! remote_path, rpath <> "")); |
|
76 |
||
77 |
fun dumping (_, "") = NONE |
|
78 |
| dumping (cp, path) = SOME (cp, Path.unpack path); |
|
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
79 |
|
17074 | 80 |
fun use_dir root build modes reset info doc doc_graph doc_versions |
17207 | 81 |
parent name dump rpath level verbose = |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11527
diff
changeset
|
82 |
Library.setmp print_mode (modes @ ! print_mode) |
17074 | 83 |
(Library.setmp Proofterm.proofs level (fn () => |
11543
d61b913431c5
renamed `keep_derivs' to `proofs', and made an integer;
wenzelm
parents:
11527
diff
changeset
|
84 |
(init reset parent name; |
17074 | 85 |
Present.init build info doc doc_graph doc_versions (path ()) name |
17207 | 86 |
(dumping dump) (get_rpath rpath) verbose; |
16715 | 87 |
ThyInfo.time_use root; |
17074 | 88 |
finish ()))) () |
18683 | 89 |
handle exn => (Output.error_msg (Toplevel.exn_message exn); exit 1); |
6346 | 90 |
|
91 |
||
92 |
end; |