author | wenzelm |
Tue, 05 Oct 1999 15:34:54 +0200 | |
changeset 7728 | 2e737ce3cdb5 |
parent 7236 | e077484d50d8 |
child 7730 | ba9e55b92998 |
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 |
|
10 |
val welcome: unit -> string |
|
6651 | 11 |
val use_dir: bool -> bool -> string -> string -> string -> unit |
6346 | 12 |
val finish: unit -> unit |
13 |
end; |
|
14 |
||
15 |
structure Session: SESSION = |
|
16 |
struct |
|
17 |
||
18 |
||
19 |
(* session state *) |
|
20 |
||
21 |
val pure = "Pure"; |
|
22 |
||
23 |
val session = ref ([pure]: string list); |
|
24 |
val session_path = ref ([]: string list); |
|
25 |
val session_finished = ref false; |
|
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
26 |
val rpath = ref (None : Url.T option); |
6346 | 27 |
|
28 |
fun path () = ! session_path; |
|
29 |
||
30 |
fun add_path reset s = |
|
31 |
(session := ! session @ [s]; session_path := ((if reset then [] else ! session_path) @ [s])); |
|
32 |
||
33 |
||
34 |
(* diagnostics *) |
|
35 |
||
36 |
fun str_of [] = "Pure" |
|
37 |
| str_of elems = space_implode "/" elems; |
|
38 |
||
39 |
fun welcome () = "Welcome to Isabelle/" ^ str_of (path ()) ^ " (" ^ version ^ ")"; |
|
40 |
||
41 |
||
42 |
(* init *) |
|
43 |
||
44 |
fun init reset parent name = |
|
45 |
if not (parent mem_string (! session)) orelse not (! session_finished) then |
|
46 |
error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name) |
|
47 |
else (add_path reset name; session_finished := false); |
|
48 |
||
49 |
||
50 |
(* finish *) |
|
51 |
||
52 |
fun finish () = |
|
6663 | 53 |
(ThyInfo.finish (); |
6346 | 54 |
Present.finish (); |
55 |
session_finished := true); |
|
56 |
||
57 |
||
58 |
(* use_dir *) |
|
59 |
||
60 |
val root_file = ThyLoad.ml_path "ROOT"; |
|
61 |
||
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
62 |
fun get_rpath rpath_str = |
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
63 |
(if rpath_str = "" then () else |
7227
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
64 |
if is_some (!rpath) then |
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
65 |
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
|
66 |
else |
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
67 |
rpath := Some (Url.unpack rpath_str); |
7236
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
68 |
(!rpath, rpath_str <> "")); |
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
69 |
|
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
70 |
fun use_dir reset info parent name rpath_str = |
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
71 |
(init reset parent name; |
e077484d50d8
Better handling of path for remote theory browsing information.
berghofe
parents:
7227
diff
changeset
|
72 |
Present.init info (path ()) name (get_rpath rpath_str); |
7227
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
73 |
File.symbol_use root_file; |
a8e86b8e6fd1
Path for remote theory browsing information is now stored in referece variable rpath.
berghofe
parents:
6663
diff
changeset
|
74 |
finish ()) handle exn => (writeln (Toplevel.exn_message exn); exit 1); |
6346 | 75 |
|
76 |
||
77 |
end; |