53 lines
1.6 KiB
OCaml
53 lines
1.6 KiB
OCaml
|
|
open Names
|
|
|
|
(** This modules manages unique identifiers,
|
|
/!\ To be effective, [enter_node] has to be called when entering a node
|
|
[gen_fresh] generates an identifier
|
|
[name] returns a unique name (inside its node) from an identifier. *)
|
|
|
|
(** The (abstract) type of identifiers*)
|
|
type ident
|
|
|
|
(** Type to be used for local variables *)
|
|
type var_ident = ident
|
|
|
|
(** Comparison on idents with the same properties as [Pervasives.compare] *)
|
|
val ident_compare : ident -> ident -> int
|
|
|
|
(** Get the full name of an identifier (it is guaranteed to be unique) *)
|
|
val name : ident -> string
|
|
|
|
(** [gen_fresh pass_name kind_to_string kind]
|
|
generate a fresh ident with a sweet [name].
|
|
It should be used to define a [fresh] function specific to a pass. *)
|
|
val gen_fresh : string -> ('a -> string) -> 'a -> ident
|
|
|
|
(** [gen_var pass_name name]
|
|
generates a fresh ident with a sweet [name] *)
|
|
val gen_var : string -> string -> ident
|
|
|
|
(** [ident_of_name n] returns an identifier corresponding
|
|
to a _source_ variable (do not use it for generated variables). *)
|
|
val ident_of_name : string -> ident
|
|
|
|
(** /!\ This function should be called every time we enter a node *)
|
|
val enter_node : Names.qualname -> unit
|
|
|
|
(** Maps taking an identifier as a key. *)
|
|
module Env :
|
|
sig
|
|
include (Map.S with type key = ident)
|
|
|
|
val append : 'a t -> 'a t -> 'a t
|
|
val union : 'a t -> 'a t -> 'a t
|
|
val diff : 'a t -> 'b t -> 'a t
|
|
val partition : (key -> bool) -> 'a t -> 'a t * 'a t
|
|
end
|
|
|
|
(** A set of identifiers. *)
|
|
module IdentSet :
|
|
sig
|
|
include (Set.S with type elt = ident)
|
|
val fprint_t : Format.formatter -> t -> unit
|
|
end
|