author | wenzelm |
Sat, 18 Mar 2017 20:24:12 +0100 | |
changeset 65310 | da9f1ef8ef7c |
parent 65225 | ec9ec04546fc |
child 65316 | c0fb8405416c |
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(), |
|
23 |
tree: Option[Sessions.Tree] = 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, |
33 |
tree = tree, store = store)) |
|
65216 | 34 |
} |
35 |
||
57917 | 36 |
def apply( |
62556
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
37 |
options: Options, |
62634
aa3b47b32100
less physical "logic" argument, with option -l like "isabelle console" etc.;
wenzelm
parents:
62633
diff
changeset
|
38 |
logic: String = "", |
62556
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
39 |
args: List[String] = Nil, |
62754
c35012b86e6f
proper session dirs for "isabelle jedit" and "isabelle console" with options -d and -l;
wenzelm
parents:
62668
diff
changeset
|
40 |
dirs: List[Path] = Nil, |
62556
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
41 |
modes: List[String] = Nil, |
65310 | 42 |
cwd: JFile = null, |
43 |
env: Map[String, String] = Isabelle_System.settings(), |
|
62633 | 44 |
receiver: Prover.Receiver = Console.println(_), |
65218 | 45 |
xml_cache: XML.Cache = new XML.Cache(), |
65310 | 46 |
tree: Option[Sessions.Tree] = None, |
62633 | 47 |
store: Sessions.Store = Sessions.store()): Isabelle_Process = |
57917 | 48 |
{ |
62556
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
49 |
val channel = System_Channel() |
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
50 |
val process = |
57916 | 51 |
try { |
65310 | 52 |
ML_Process(options, logic = logic, args = args, dirs = dirs, modes = modes, |
53 |
cwd = cwd, env = env, tree = tree, store = store, channel = Some(channel)) |
|
57916 | 54 |
} |
62556
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
55 |
catch { case exn @ ERROR(_) => channel.accepted(); throw exn } |
c115e69f457f
more abstract Session.start, without prover command-line;
wenzelm
parents:
62555
diff
changeset
|
56 |
process.stdin.close |
57917 | 57 |
|
65218 | 58 |
new Isabelle_Process(receiver, xml_cache, channel, process) |
57917 | 59 |
} |
57916 | 60 |
} |
27949
6eb0327c0b9b
Isabelle process management -- always reactive due to multi-threaded I/O.
wenzelm
parents:
diff
changeset
|
61 |
|
57917 | 62 |
class Isabelle_Process private( |
65218 | 63 |
receiver: Prover.Receiver, |
64 |
xml_cache: XML.Cache, |
|
65 |
channel: System_Channel, |
|
66 |
process: Prover.System_Process) |
|
67 |
extends Prover(receiver, xml_cache, channel, process) |
|
62309 | 68 |
{ |
69 |
def encode(s: String): String = Symbol.encode(s) |
|
70 |
def decode(s: String): String = Symbol.decode(s) |
|
71 |
} |