2012-06-27 18:09:30 +02:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon *)
|
|
|
|
(* *)
|
|
|
|
(* Gwenael Delaval, LIG/INRIA, UJF *)
|
|
|
|
(* Leonard Gerard, Parkas, ENS *)
|
|
|
|
(* Adrien Guatto, Parkas, ENS *)
|
|
|
|
(* Cedric Pasteur, Parkas, ENS *)
|
2012-06-29 01:43:15 +02:00
|
|
|
(* Marc Pouzet, Parkas, ENS *)
|
2012-06-27 18:09:30 +02:00
|
|
|
(* *)
|
|
|
|
(* Copyright 2012 ENS, INRIA, UJF *)
|
|
|
|
(* *)
|
|
|
|
(* This file is part of the Heptagon compiler. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is free software: you can redistribute it and/or modify it *)
|
|
|
|
(* under the terms of the GNU General Public License as published by *)
|
|
|
|
(* the Free Software Foundation, either version 3 of the License, or *)
|
|
|
|
(* (at your option) any later version. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is distributed in the hope that it will be useful, *)
|
|
|
|
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
|
|
|
|
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
|
|
|
|
(* GNU General Public License for more details. *)
|
|
|
|
(* *)
|
|
|
|
(* You should have received a copy of the GNU General Public License *)
|
|
|
|
(* along with Heptagon. If not, see <http://www.gnu.org/licenses/> *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
2010-06-15 14:05:26 +02:00
|
|
|
|
2010-12-14 18:29:55 +01:00
|
|
|
open Names
|
2010-06-15 14:05:26 +02:00
|
|
|
|
2010-12-14 18:29:55 +01:00
|
|
|
(** This modules manages unique identifiers,
|
2011-01-20 23:05:18 +01:00
|
|
|
/!\ To be effective, [enter_node] has to be called when entering a node
|
2011-06-30 17:41:25 +02:00
|
|
|
[gen_var] generates a variable identifier
|
2010-12-14 18:29:55 +01:00
|
|
|
[name] returns a unique name (inside its node) from an identifier. *)
|
2010-06-15 14:05:26 +02:00
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
(** The (abstract) type of identifiers*)
|
2010-06-15 14:05:26 +02:00
|
|
|
type ident
|
2010-07-07 15:11:32 +02:00
|
|
|
|
|
|
|
(** Type to be used for local variables *)
|
|
|
|
type var_ident = ident
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2011-01-20 23:05:18 +01:00
|
|
|
(** Comparison on idents with the same properties as [Pervasives.compare] *)
|
2010-09-30 19:13:43 +02:00
|
|
|
val ident_compare : ident -> ident -> int
|
|
|
|
|
2010-06-15 14:05:26 +02:00
|
|
|
(** Get the full name of an identifier (it is guaranteed to be unique) *)
|
2010-06-15 10:49:03 +02:00
|
|
|
val name : ident -> string
|
|
|
|
|
2011-05-09 19:32:12 +02:00
|
|
|
(** Get the source name of an identifier (useful when dealing with signatures *)
|
|
|
|
val source_name : ident -> string
|
|
|
|
|
2010-12-14 18:29:55 +01:00
|
|
|
(** [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. *)
|
2011-05-23 20:42:04 +02:00
|
|
|
val gen_fresh : string -> ('a -> string) -> ?reset:bool -> 'a -> ident
|
2011-01-20 23:05:18 +01:00
|
|
|
|
|
|
|
(** [gen_var pass_name name]
|
|
|
|
generates a fresh ident with a sweet [name] *)
|
2011-05-23 20:42:04 +02:00
|
|
|
val gen_var : string -> ?reset:bool -> string -> ident
|
2010-12-14 18:29:55 +01:00
|
|
|
|
2011-05-09 19:32:12 +02:00
|
|
|
(** [ident_of_name n] returns an fresh identifier corresponding
|
2010-06-15 14:05:26 +02:00
|
|
|
to a _source_ variable (do not use it for generated variables). *)
|
2011-05-23 20:42:04 +02:00
|
|
|
val ident_of_name : ?reset:bool -> string -> ident
|
|
|
|
|
|
|
|
val is_reset : ident -> bool
|
2010-12-14 18:29:55 +01:00
|
|
|
|
2011-06-30 17:41:25 +02:00
|
|
|
(** /!\ [enter_node qualname] should be called every time we enter a node with name [qualname]. *)
|
2010-12-14 18:29:55 +01:00
|
|
|
val enter_node : Names.qualname -> unit
|
2010-06-15 10:49:03 +02:00
|
|
|
|
2012-08-01 17:08:58 +02:00
|
|
|
val copy_node : Names.qualname -> Names.qualname -> unit
|
|
|
|
|
2010-06-15 10:49:03 +02:00
|
|
|
(** Maps taking an identifier as a key. *)
|
|
|
|
module Env :
|
2010-06-15 14:05:26 +02:00
|
|
|
sig
|
|
|
|
include (Map.S with type key = ident)
|
2010-06-26 16:53:25 +02:00
|
|
|
|
2010-06-15 14:05:26 +02:00
|
|
|
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
|
2011-05-10 20:29:01 +02:00
|
|
|
val print_t : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit
|
2010-06-15 14:05:26 +02:00
|
|
|
end
|
2010-06-15 10:49:03 +02:00
|
|
|
|
|
|
|
(** A set of identifiers. *)
|
|
|
|
module IdentSet :
|
2010-06-15 14:05:26 +02:00
|
|
|
sig
|
|
|
|
include (Set.S with type elt = ident)
|
2011-05-10 20:29:01 +02:00
|
|
|
val print_t : Format.formatter -> t -> unit
|
2010-06-15 14:05:26 +02:00
|
|
|
end
|
2012-03-02 17:11:40 +01:00
|
|
|
|
|
|
|
val print_ident : Format.formatter -> ident -> unit
|