summaryrefslogtreecommitdiff
path: root/src/Identifiers.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/Identifiers.ml')
-rw-r--r--src/Identifiers.ml11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Identifiers.ml b/src/Identifiers.ml
index 345ce058..d3e5b83e 100644
--- a/src/Identifiers.ml
+++ b/src/Identifiers.ml
@@ -16,6 +16,8 @@ module type Id = sig
val generator_zero : generator
+ val fresh_stateful_generator : unit -> generator ref * (unit -> id)
+
(* TODO: this is stateful! - but we may want to be able to duplicate contexts... *)
val fresh : generator -> id * generator
(* TODO: change the order of the returned types *)
@@ -84,6 +86,15 @@ module IdGen () : Id = struct
* they happen *)
if x == max_int then raise (Errors.IntegerOverflow ()) else x + 1
+ let fresh_stateful_generator () =
+ let g = ref 0 in
+ let fresh () =
+ let id = !g in
+ g := incr id;
+ id
+ in
+ (g, fresh)
+
let fresh gen = (gen, incr gen)
let to_string = string_of_int