src/Pure/Concurrent/thread_position.ML
author wenzelm
Mon, 20 May 2024 15:43:51 +0200
changeset 80182 29f2b8ff84f3
parent 78021 ce6e3bc34343
permissions -rw-r--r--
proper support for "isabelle update -D DIR": avoid accidental exclusion of select_dirs (amending e5dafe9e120f);

(*  Title:      Pure/Concurrent/thread_position.ML
    Author:     Makarius

Thread-local position information.
*)

signature THREAD_POSITION =
sig
  type T = {line: int, offset: int, end_offset: int, props: {label: string, file: string, id: string}}
  val none: T
  val get: unit -> T
  val setmp: T -> ('a -> 'b) -> 'a -> 'b
end;

structure Thread_Position: THREAD_POSITION =
struct

type T = {line: int, offset: int, end_offset: int, props: {label: string, file: string, id: string}};

val var = Thread_Data.var () : T Thread_Data.var;

val none: T = {line = 0, offset = 0, end_offset = 0, props = {label = "", file = "", id = ""}};

fun get () = (case Thread_Data.get var of NONE => none | SOME pos => pos);
fun setmp pos f x = Thread_Data.setmp var (if pos = none then NONE else SOME pos) f x;

end;