src/Pure/PIDE/command.ML
changeset 52605 a2a805549c74
parent 52604 ff2f0818aebc
child 52606 0d68d108d7e0
equal deleted inserted replaced
52604:ff2f0818aebc 52605:a2a805549c74
    18     ({command_name: string} -> print_fn option) -> unit
    18     ({command_name: string} -> print_fn option) -> unit
    19   val no_print_function: string -> unit
    19   val no_print_function: string -> unit
    20   type exec = eval * print list
    20   type exec = eval * print list
    21   val no_exec: exec
    21   val no_exec: exec
    22   val exec_ids: exec option -> Document_ID.exec list
    22   val exec_ids: exec option -> Document_ID.exec list
    23   val exec: Exec.context -> exec -> unit
    23   val exec: Execution.context -> exec -> unit
    24 end;
    24 end;
    25 
    25 
    26 structure Command: COMMAND =
    26 structure Command: COMMAND =
    27 struct
    27 struct
    28 
    28 
    49   | Expr _ =>
    49   | Expr _ =>
    50       Synchronized.timed_access v (fn _ => SOME Time.zeroTime)
    50       Synchronized.timed_access v (fn _ => SOME Time.zeroTime)
    51         (fn Result res => SOME (res, Result res)
    51         (fn Result res => SOME (res, Result res)
    52           | expr as Expr (exec_id, e) =>
    52           | expr as Expr (exec_id, e) =>
    53               uninterruptible (fn restore_attributes => fn () =>
    53               uninterruptible (fn restore_attributes => fn () =>
    54                 if Exec.running context exec_id then
    54                 if Execution.running context exec_id then
    55                   let
    55                   let
    56                     val res = Exn.capture (restore_attributes e) ();
    56                     val res = Exn.capture (restore_attributes e) ();
    57                     val _ = Exec.finished exec_id (not (Exn.is_interrupt_exn res));
    57                     val _ = Execution.finished exec_id (not (Exn.is_interrupt_exn res));
    58                   in SOME (res, Result res) end
    58                   in SOME (res, Result res) end
    59                 else SOME (Exn.interrupt_exn, expr)) ())
    59                 else SOME (Exn.interrupt_exn, expr)) ())
    60       |> (fn NONE => error "Concurrent execution attempt" | SOME res => res))
    60       |> (fn NONE => error "Concurrent execution attempt" | SOME res => res))
    61   |> Exn.release |> ignore;
    61   |> Exn.release |> ignore;
    62 
    62 
   111 
   111 
   112 fun eval_result (Eval {eval_process, ...}) = memo_result eval_process;
   112 fun eval_result (Eval {eval_process, ...}) = memo_result eval_process;
   113 val eval_result_state = #state o eval_result;
   113 val eval_result_state = #state o eval_result;
   114 
   114 
   115 fun eval_same (Eval {exec_id, ...}, Eval {exec_id = exec_id', ...}) =
   115 fun eval_same (Eval {exec_id, ...}, Eval {exec_id = exec_id', ...}) =
   116   exec_id = exec_id' andalso Exec.is_stable exec_id;
   116   exec_id = exec_id' andalso Execution.is_stable exec_id;
   117 
   117 
   118 local
   118 local
   119 
   119 
   120 fun run int tr st =
   120 fun run int tr st =
   121   if Goal.future_enabled () andalso Keyword.is_diag (Toplevel.name_of tr) then
   121   if Goal.future_enabled () andalso Keyword.is_diag (Toplevel.name_of tr) then
   196 fun print_error tr e =
   196 fun print_error tr e =
   197   (Toplevel.setmp_thread_position tr o Runtime.controlled_execution) e () handle exn =>
   197   (Toplevel.setmp_thread_position tr o Runtime.controlled_execution) e () handle exn =>
   198     List.app (Future.error_msg (Toplevel.pos_of tr)) (ML_Compiler.exn_messages_ids exn);
   198     List.app (Future.error_msg (Toplevel.pos_of tr)) (ML_Compiler.exn_messages_ids exn);
   199 
   199 
   200 fun print_persistent (Print {persistent, ...}) = persistent;
   200 fun print_persistent (Print {persistent, ...}) = persistent;
   201 fun print_stable (Print {exec_id, ...}) = Exec.is_stable exec_id;
   201 fun print_stable (Print {exec_id, ...}) = Execution.is_stable exec_id;
   202 fun print_eq (Print {exec_id, ...}, Print {exec_id = exec_id', ...}) = exec_id = exec_id';
   202 fun print_eq (Print {exec_id, ...}, Print {exec_id = exec_id', ...}) = exec_id = exec_id';
   203 
   203 
   204 in
   204 in
   205 
   205 
   206 fun print command_visible command_name eval old_prints =
   206 fun print command_visible command_name eval old_prints =