| author | nipkow | 
| Thu, 04 Oct 2018 11:18:39 +0200 | |
| changeset 69118 | 12dce58bcd3f | 
| parent 62944 | 3ee643c5ed00 | 
| child 71611 | fb6953e77000 | 
| permissions | -rw-r--r-- | 
| 56210 | 1 | (* Title: Pure/PIDE/session.ML | 
| 52052 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52050diff
changeset | 2 | Author: Makarius | 
| 6346 | 3 | |
| 56210 | 4 | Prover session: persistent state of logic image. | 
| 6346 | 5 | *) | 
| 6 | ||
| 7 | signature SESSION = | |
| 8 | sig | |
| 60081 | 9 | val get_name: unit -> string | 
| 6346 | 10 | val welcome: unit -> string | 
| 59086 
94b2690ad494
node-specific keywords, with session base syntax as default;
 wenzelm parents: 
58928diff
changeset | 11 | val get_keywords: unit -> Keyword.keywords | 
| 61381 | 12 | val init: HTML.symbols -> bool -> bool -> Path.T -> string -> string -> (string * string) list -> | 
| 59445 | 13 | (Path.T * Path.T) list -> Path.T -> string -> string * string -> bool -> unit | 
| 59369 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 14 | val shutdown: unit -> unit | 
| 48457 | 15 | val finish: unit -> unit | 
| 52111 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 16 | val protocol_handler: string -> unit | 
| 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 17 | val init_protocol_handlers: unit -> unit | 
| 6346 | 18 | end; | 
| 19 | ||
| 20 | structure Session: SESSION = | |
| 21 | struct | |
| 22 | ||
| 62928 | 23 | (** persistent session information **) | 
| 6346 | 24 | |
| 62944 
3ee643c5ed00
more standard session build process, including browser_info;
 wenzelm parents: 
62936diff
changeset | 25 | val session = Synchronized.var "Session.session" ({chapter = "", name = ""}, true);
 | 
| 48542 | 26 | |
| 62928 | 27 | fun get_name () = #name (#1 (Synchronized.value session)); | 
| 60081 | 28 | |
| 29 | fun description () = "Isabelle/" ^ get_name (); | |
| 30173 
eabece26b89b
moved isabelle_process.ML, isabelle_process.scala, isar.ML, session.ML to Pure/System/ (together with associated Isar commands);
 wenzelm parents: 
29435diff
changeset | 30 | |
| 26109 
c69c3559355b
more elaborate structure Distribution (filled-in by makedist);
 wenzelm parents: 
25840diff
changeset | 31 | fun welcome () = | 
| 57649 
a43898f76ae9
further distinction of Isabelle distribution: alert for identified release candidates;
 wenzelm parents: 
56533diff
changeset | 32 | if Distribution.is_identified then | 
| 60081 | 33 |     "Welcome to " ^ description () ^ " (" ^ Distribution.version ^ ")"
 | 
| 34 |   else "Unofficial version of " ^ description () ^ " (" ^ Distribution.version ^ ")";
 | |
| 6346 | 35 | |
| 36 | ||
| 59086 
94b2690ad494
node-specific keywords, with session base syntax as default;
 wenzelm parents: 
58928diff
changeset | 37 | (* base syntax *) | 
| 
94b2690ad494
node-specific keywords, with session base syntax as default;
 wenzelm parents: 
58928diff
changeset | 38 | |
| 62928 | 39 | val keywords = Synchronized.var "Session.keywords" Keyword.empty_keywords; | 
| 40 | ||
| 41 | fun get_keywords () = Synchronized.value keywords; | |
| 42 | ||
| 43 | fun update_keywords () = | |
| 44 | Synchronized.change keywords | |
| 45 | (K (fold (curry Keyword.merge_keywords o Thy_Header.get_keywords o Thy_Info.get_theory) | |
| 46 | (Thy_Info.get_names ()) Keyword.empty_keywords)); | |
| 59086 
94b2690ad494
node-specific keywords, with session base syntax as default;
 wenzelm parents: 
58928diff
changeset | 47 | |
| 
94b2690ad494
node-specific keywords, with session base syntax as default;
 wenzelm parents: 
58928diff
changeset | 48 | |
| 51399 
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
 wenzelm parents: 
51398diff
changeset | 49 | (* init *) | 
| 9414 | 50 | |
| 61381 | 51 | fun init symbols build info info_path doc doc_output doc_variants doc_files graph_file | 
| 56530 
5c178501cf78
removed obsolete doc_dump option (see also 892061142ba6);
 wenzelm parents: 
56333diff
changeset | 52 | parent (chapter, name) verbose = | 
| 62928 | 53 |   (Synchronized.change session (fn ({name = parent_name, ...}, parent_finished) =>
 | 
| 54 | if parent_name <> parent orelse not parent_finished then | |
| 55 |       error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name)
 | |
| 56 |     else ({chapter = chapter, name = name}, false));
 | |
| 57 | Present.init symbols build info info_path (if doc = "false" then "" else doc) | |
| 58 | doc_output doc_variants doc_files graph_file (chapter, name) verbose); | |
| 6346 | 59 | |
| 60 | ||
| 61 | (* finish *) | |
| 62 | ||
| 59369 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 63 | fun shutdown () = | 
| 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 64 | (Execution.shutdown (); | 
| 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 65 | Event_Timer.shutdown (); | 
| 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 66 | Future.shutdown ()); | 
| 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 67 | |
| 6346 | 68 | fun finish () = | 
| 59369 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 69 | (shutdown (); | 
| 49911 
262c36fd5f26
collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
 wenzelm parents: 
49895diff
changeset | 70 | Thy_Info.finish (); | 
| 
262c36fd5f26
collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
 wenzelm parents: 
49895diff
changeset | 71 | Present.finish (); | 
| 59369 
7090199d3f78
more informative build_theories_result: cumulative Runtime.exn_message;
 wenzelm parents: 
59345diff
changeset | 72 | shutdown (); | 
| 62928 | 73 | update_keywords (); | 
| 74 | Synchronized.change session (apsnd (K true))); | |
| 6346 | 75 | |
| 52111 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 76 | |
| 56210 | 77 | |
| 52111 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 78 | (** protocol handlers **) | 
| 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 79 | |
| 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 80 | val protocol_handlers = Synchronized.var "protocol_handlers" ([]: string list); | 
| 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 81 | |
| 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 82 | fun protocol_handler name = | 
| 62936 | 83 | if Thread_Data.is_virtual then () | 
| 84 | else | |
| 85 | Synchronized.change protocol_handlers (fn handlers => | |
| 86 | (Output.try_protocol_message (Markup.protocol_handler name) []; | |
| 87 | if not (member (op =) handlers name) then () | |
| 88 |       else warning ("Redefining protocol handler: " ^ quote name);
 | |
| 89 | update (op =) name handlers)); | |
| 52111 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 90 | |
| 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 91 | fun init_protocol_handlers () = | 
| 62936 | 92 | if Thread_Data.is_virtual then () | 
| 93 | else | |
| 94 | Synchronized.value protocol_handlers | |
| 95 | |> List.app (fn name => Output.try_protocol_message (Markup.protocol_handler name) []); | |
| 52111 
1fd184eaa310
explicit management of Session.Protocol_Handlers, with protocol state and functions;
 wenzelm parents: 
52083diff
changeset | 96 | |
| 6346 | 97 | end; |