| author | wenzelm | 
| Sat, 17 Feb 2018 19:37:18 +0100 | |
| changeset 67647 | 27f3dceb5a70 | 
| parent 67178 | 70576478bda9 | 
| child 68169 | 395432e7516e | 
| permissions | -rw-r--r-- | 
| 43283 | 1 | /* Title: Pure/System/isabelle_process.scala | 
| 27949 
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
 wenzelm parents: diff
changeset | 2 | Author: Makarius | 
| 
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
 wenzelm parents: diff
changeset | 3 | |
| 57916 | 4 | Isabelle process wrapper. | 
| 27949 
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
 wenzelm parents: diff
changeset | 5 | */ | 
| 
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
 wenzelm parents: diff
changeset | 6 | |
| 
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
 wenzelm parents: diff
changeset | 7 | package isabelle | 
| 
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
 wenzelm parents: diff
changeset | 8 | |
| 55618 | 9 | |
| 65310 | 10 | import java.io.{File => JFile}
 | 
| 11 | ||
| 12 | ||
| 57917 | 13 | object Isabelle_Process | 
| 14 | {
 | |
| 65216 | 15 | def start(session: Session, | 
| 16 | options: Options, | |
| 17 | logic: String = "", | |
| 18 | args: List[String] = Nil, | |
| 19 | dirs: List[Path] = Nil, | |
| 20 | modes: List[String] = Nil, | |
| 65310 | 21 | cwd: JFile = null, | 
| 22 | env: Map[String, String] = Isabelle_System.settings(), | |
| 67052 | 23 | sessions: Option[Sessions.Structure] = None, | 
| 65225 | 24 | store: Sessions.Store = Sessions.store(), | 
| 25 | phase_changed: Session.Phase => Unit = null) | |
| 65216 | 26 |   {
 | 
| 65225 | 27 | if (phase_changed != null) | 
| 28 |       session.phase_changed += Session.Consumer("Isabelle_Process")(phase_changed)
 | |
| 29 | ||
| 65216 | 30 | session.start(receiver => | 
| 31 | Isabelle_Process(options, logic = logic, args = args, dirs = dirs, modes = modes, | |
| 65310 | 32 | cwd = cwd, env = env, receiver = receiver, xml_cache = session.xml_cache, | 
| 65415 
8cd54b18b68b
clarified signature: tree structure is not essential;
 wenzelm parents: 
65345diff
changeset | 33 | sessions = sessions, store = store)) | 
| 65216 | 34 | } | 
| 35 | ||
| 57917 | 36 | def apply( | 
| 62556 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 37 | options: Options, | 
| 62634 
aa3b47b32100
less physical "logic" argument, with option -l like "isabelle console" etc.;
 wenzelm parents: 
62633diff
changeset | 38 | logic: String = "", | 
| 62556 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 39 | args: List[String] = Nil, | 
| 62754 
c35012b86e6f
proper session dirs for "isabelle jedit" and "isabelle console" with options -d and -l;
 wenzelm parents: 
62668diff
changeset | 40 | dirs: List[Path] = Nil, | 
| 62556 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 41 | modes: List[String] = Nil, | 
| 65310 | 42 | cwd: JFile = null, | 
| 43 | env: Map[String, String] = Isabelle_System.settings(), | |
| 67178 | 44 | receiver: Prover.Receiver = (msg: Prover.Message) => Output.writeln(msg.toString, stdout = true), | 
| 65218 | 45 | xml_cache: XML.Cache = new XML.Cache(), | 
| 67052 | 46 | sessions: Option[Sessions.Structure] = None, | 
| 65345 
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
 wenzelm parents: 
65316diff
changeset | 47 | store: Sessions.Store = Sessions.store()): Prover = | 
| 57917 | 48 |   {
 | 
| 62556 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 49 | val channel = System_Channel() | 
| 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 50 | val process = | 
| 57916 | 51 |       try {
 | 
| 65310 | 52 | ML_Process(options, logic = logic, args = args, dirs = dirs, modes = modes, | 
| 65415 
8cd54b18b68b
clarified signature: tree structure is not essential;
 wenzelm parents: 
65345diff
changeset | 53 | cwd = cwd, env = env, sessions = sessions, store = store, channel = Some(channel)) | 
| 57916 | 54 | } | 
| 62556 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 55 |       catch { case exn @ ERROR(_) => channel.accepted(); throw exn }
 | 
| 
c115e69f457f
more abstract Session.start, without prover command-line;
 wenzelm parents: 
62555diff
changeset | 56 | process.stdin.close | 
| 57917 | 57 | |
| 65345 
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
 wenzelm parents: 
65316diff
changeset | 58 | new Prover(receiver, xml_cache, channel, process) | 
| 57917 | 59 | } | 
| 57916 | 60 | } |