author | wenzelm |
Mon, 25 Mar 2019 17:21:26 +0100 | |
changeset 69981 | 3dced198b9ec |
parent 69788 | c175499a7537 |
child 70009 | 435fb018e8ee |
permissions | -rw-r--r-- |
68090 | 1 |
(* Title: Pure/Thy/export.ML |
2 |
Author: Makarius |
|
3 |
||
68102 | 4 |
Manage theory exports: compressed blobs. |
68090 | 5 |
*) |
6 |
||
7 |
signature EXPORT = |
|
8 |
sig |
|
69788 | 9 |
type params = {theory: theory, path: Path.T, executable: bool, compress: bool} |
10 |
val export_params: params -> string list -> unit |
|
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
11 |
val export: theory -> Path.T -> string list -> unit |
69788 | 12 |
val export_executable: theory -> Path.T -> string list -> unit |
69650 | 13 |
val markup: theory -> string -> Markup.T |
14 |
val message: theory -> string -> string |
|
68090 | 15 |
end; |
16 |
||
17 |
structure Export: EXPORT = |
|
18 |
struct |
|
19 |
||
69648 | 20 |
(* export *) |
21 |
||
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
22 |
fun check_name path = |
68105 | 23 |
let |
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
24 |
val name = Path.implode path; |
69627 | 25 |
val _ = |
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
26 |
if not (Path.is_current path) andalso Path.all_basic path then () |
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
27 |
else error ("Bad export name: " ^ quote name); |
68105 | 28 |
in name end; |
29 |
||
69788 | 30 |
type params = {theory: theory, path: Path.T, executable: bool, compress: bool}; |
31 |
||
32 |
fun export_params ({theory, path, executable, compress}: params) blob = |
|
68090 | 33 |
(Output.try_protocol_message o Markup.export) |
34 |
{id = Position.get_id (Position.thread_data ()), |
|
68101 | 35 |
serial = serial (), |
69788 | 36 |
theory_name = Context.theory_long_name theory, |
69784
24bbc4e30e5b
clarified signature: Path.T as in Generated_Files;
wenzelm
parents:
69650
diff
changeset
|
37 |
name = check_name path, |
69788 | 38 |
executable = executable, |
39 |
compress = compress} blob; |
|
68090 | 40 |
|
69788 | 41 |
fun export theory path blob = |
42 |
export_params {theory = theory, path = path, executable = false, compress = true} blob; |
|
43 |
||
44 |
fun export_executable theory path blob = |
|
45 |
export_params {theory = theory, path = path, executable = true, compress = true} blob; |
|
68090 | 46 |
|
69648 | 47 |
|
48 |
(* information message *) |
|
49 |
||
69650 | 50 |
fun markup thy s = |
51 |
let val name = (Markup.nameN, Context.theory_long_name thy ^ (if s = "" then "" else "/" ^ s)) |
|
52 |
in Active.make_markup Markup.theory_exportsN {implicit = false, properties = [name]} end; |
|
69648 | 53 |
|
69650 | 54 |
fun message thy s = |
55 |
"See " ^ Markup.markup (markup thy s) "theory exports"; |
|
69648 | 56 |
|
68090 | 57 |
end; |