{t with vals = Map.set t.vals ~k ~v}
let loop_begin t =
- let loop = Sym.new_of_string "loop" in
+ let loop = Sym.unique_of_string "loop" in
let t = {t with loop = Some loop} in
(loop, t)
let symbols = H.create 16
-let next name =
+let unique_of_string name =
incr counter;
let symbol = !counter in
{name; symbol}
-let new_of_string name =
- let t = next name in
- H.replace symbols ~key:t.name ~data:t.symbol;
- t
-
let of_string name =
match H.find_opt symbols name with
- | Some s -> {name; symbol=s}
- | None -> new_of_string name
+ | Some symbol ->
+ {name; symbol}
+ | None ->
+ let t = unique_of_string name in
+ H.replace symbols ~key:t.name ~data:t.symbol;
+ t
let to_string {name; _} =
name