equal
deleted
inserted
replaced
16 val >>> : Toplevel.transition list -> unit |
16 val >>> : Toplevel.transition list -> unit |
17 val linear_undo: int -> unit |
17 val linear_undo: int -> unit |
18 val undo: int -> unit |
18 val undo: int -> unit |
19 val kill: unit -> unit |
19 val kill: unit -> unit |
20 val kill_proof: unit -> unit |
20 val kill_proof: unit -> unit |
21 val crashes: exn list ref |
21 val crashes: exn list Unsynchronized.ref |
22 val toplevel_loop: {init: bool, welcome: bool, sync: bool, secure: bool} -> unit |
22 val toplevel_loop: {init: bool, welcome: bool, sync: bool, secure: bool} -> unit |
23 val loop: unit -> unit |
23 val loop: unit -> unit |
24 val main: unit -> unit |
24 val main: unit -> unit |
25 end; |
25 end; |
26 |
26 |
34 |
34 |
35 type history = (Toplevel.state * Toplevel.transition) list; |
35 type history = (Toplevel.state * Toplevel.transition) list; |
36 (*previous state, state transition -- regular commands only*) |
36 (*previous state, state transition -- regular commands only*) |
37 |
37 |
38 local |
38 local |
39 val global_history = ref ([]: history); |
39 val global_history = Unsynchronized.ref ([]: history); |
40 val global_state = ref Toplevel.toplevel; |
40 val global_state = Unsynchronized.ref Toplevel.toplevel; |
41 val global_exn = ref (NONE: (exn * string) option); |
41 val global_exn = Unsynchronized.ref (NONE: (exn * string) option); |
42 in |
42 in |
43 |
43 |
44 fun edit_history count f = NAMED_CRITICAL "Isar" (fn () => |
44 fun edit_history count f = NAMED_CRITICAL "Isar" (fn () => |
45 let |
45 let |
46 fun edit 0 (st, hist) = (global_history := hist; global_state := st; global_exn := NONE) |
46 fun edit 0 (st, hist) = (global_history := hist; global_state := st; global_exn := NONE) |
113 | op >>> (tr :: trs) = if op >> tr then op >>> trs else (); |
113 | op >>> (tr :: trs) = if op >> tr then op >>> trs else (); |
114 |
114 |
115 |
115 |
116 (* toplevel loop *) |
116 (* toplevel loop *) |
117 |
117 |
118 val crashes = ref ([]: exn list); |
118 val crashes = Unsynchronized.ref ([]: exn list); |
119 |
119 |
120 local |
120 local |
121 |
121 |
122 fun raw_loop secure src = |
122 fun raw_loop secure src = |
123 let |
123 let |
128 NONE => if secure then quit () else () |
128 NONE => if secure then quit () else () |
129 | SOME (tr, src') => if op >> tr orelse check_secure () then raw_loop secure src' else ()) |
129 | SOME (tr, src') => if op >> tr orelse check_secure () then raw_loop secure src' else ()) |
130 handle exn => |
130 handle exn => |
131 (Output.error_msg (ML_Compiler.exn_message exn) |
131 (Output.error_msg (ML_Compiler.exn_message exn) |
132 handle crash => |
132 handle crash => |
133 (CRITICAL (fn () => change crashes (cons crash)); |
133 (CRITICAL (fn () => Unsynchronized.change crashes (cons crash)); |
134 warning "Recovering from Isar toplevel crash -- see also Isar.crashes"); |
134 warning "Recovering from Isar toplevel crash -- see also Isar.crashes"); |
135 raw_loop secure src) |
135 raw_loop secure src) |
136 end; |
136 end; |
137 |
137 |
138 in |
138 in |