src/Pure/Isar/toplevel.ML
changeset 12987 b6db96775e52
parent 12881 eeb36b66480e
child 13486 54464ea94d6f
equal deleted inserted replaced
12986:58cd2ca93edc 12987:b6db96775e52
   185 fun copy_node true (Theory thy) = Theory (Theory.copy thy)
   185 fun copy_node true (Theory thy) = Theory (Theory.copy thy)
   186   | copy_node _ node = node;
   186   | copy_node _ node = node;
   187 
   187 
   188 fun interruptible f x =
   188 fun interruptible f x =
   189   let val y = ref (None: node History.T option);
   189   let val y = ref (None: node History.T option);
   190   in exhibit_interrupt (fn () => y := Some (f x)) (); the (! y) end;
   190   in raise_interrupt (fn () => y := Some (f x)) (); the (! y) end;
   191 
   191 
   192 val rollback = ERROR_MESSAGE "Stale signature encountered after succesful execution!";
   192 val rollback = ERROR_MESSAGE "Stale signature encountered after succesful execution!";
   193 
   193 
   194 fun return (result, None) = result
   194 fun return (result, None) = result
   195   | return (result, Some exn) = raise FAILURE (result, exn);
   195   | return (result, Some exn) = raise FAILURE (result, exn);
   252   | apply_tr _ Exit (State (Some (node, (exit, _)))) =
   252   | apply_tr _ Exit (State (Some (node, (exit, _)))) =
   253       (exit (History.current node); State None)
   253       (exit (History.current node); State None)
   254   | apply_tr _ Kill (State None) = raise UNDEF
   254   | apply_tr _ Kill (State None) = raise UNDEF
   255   | apply_tr _ Kill (State (Some (node, (_, kill)))) =
   255   | apply_tr _ Kill (State (Some (node, (_, kill)))) =
   256       (kill (History.current node); State None)
   256       (kill (History.current node); State None)
   257   | apply_tr int (Keep f) state = (exhibit_interrupt (f int) state; state)
   257   | apply_tr int (Keep f) state = (raise_interrupt (f int) state; state)
   258   | apply_tr _ (History _) (State None) = raise UNDEF
   258   | apply_tr _ (History _) (State None) = raise UNDEF
   259   | apply_tr _ (History f) (State (Some (node, term))) = State (Some (f node, term))
   259   | apply_tr _ (History f) (State (Some (node, term))) = State (Some (f node, term))
   260   | apply_tr int (MapCurrent f) state = node_trans int false f state
   260   | apply_tr int (MapCurrent f) state = node_trans int false f state
   261   | apply_tr int (AppCurrent f) state = node_trans int true f state;
   261   | apply_tr int (AppCurrent f) state = node_trans int true f state;
   262 
   262 
   497     None => (writeln "\nInterrupt."; raw_loop src)
   497     None => (writeln "\nInterrupt."; raw_loop src)
   498   | Some None => ()
   498   | Some None => ()
   499   | Some (Some (tr, src')) => if >> tr then raw_loop src' else ());
   499   | Some (Some (tr, src')) => if >> tr then raw_loop src' else ());
   500 
   500 
   501 
   501 
   502 fun loop src = mask_interrupt raw_loop src;
   502 fun loop src = ignore_interrupt raw_loop src;
   503 
   503 
   504 
   504 
   505 end;
   505 end;