equal
deleted
inserted
replaced
|
1 (* Title: Pure/General/secure.ML |
|
2 Author: Makarius |
|
3 |
|
4 Secure critical operations. |
|
5 *) |
|
6 |
|
7 signature SECURE = |
|
8 sig |
|
9 val set_secure: unit -> unit |
|
10 val is_secure: unit -> bool |
|
11 val deny: string -> unit |
|
12 val deny_ml: unit -> unit |
|
13 end; |
|
14 |
|
15 structure Secure: SECURE = |
|
16 struct |
|
17 |
|
18 val secure = Unsynchronized.ref false; |
|
19 |
|
20 fun set_secure () = secure := true; |
|
21 fun is_secure () = ! secure; |
|
22 |
|
23 fun deny msg = if is_secure () then error msg else (); |
|
24 |
|
25 fun deny_ml () = deny "Cannot evaluate ML source in secure mode"; |
|
26 |
|
27 end; |