jon.recoil.org

Module Flambda2_nominal.Name_occurrences

A structure for counting name-like entities that occur free in terms or types.

type t
val empty : t
val is_empty : t -> bool
val print : Format.formatter -> t -> unit
val equal : t -> t -> bool
val apply_renaming : t -> Renaming.t -> t
include Contains_ids.S with type t := t
val ids_for_export : t -> Ids_for_export.t

Gather all table identifiers to export them.

val affected_by_renaming : t -> Renaming.t -> bool

True if and only if not (equal (apply_renaming t renaming) t)

val singleton_continuation : Flambda2_identifiers.Continuation.t -> t
val singleton_continuation_in_trap_action : Flambda2_identifiers.Continuation.t -> t
val add_continuation : t -> Flambda2_identifiers.Continuation.t -> has_traps:bool -> t
val continuation_is_applied_with_traps : t -> Flambda2_identifiers.Continuation.t -> bool
val count_variable_normal_mode : t -> Flambda2_identifiers.Variable.t -> Num_occurrences.t
val singleton_variable : Flambda2_identifiers.Variable.t -> Name_mode.t -> t
val add_variable : t -> Flambda2_identifiers.Variable.t -> Name_mode.t -> t
val add_symbol : t -> Flambda2_identifiers.Symbol.t -> Name_mode.t -> t
val add_name : t -> Flambda2_identifiers.Name.t -> Name_mode.t -> t
val add_function_slot_in_projection : t -> Flambda2_identifiers.Function_slot.t -> Name_mode.t -> t
val add_value_slot_in_projection : t -> Flambda2_identifiers.Value_slot.t -> Name_mode.t -> t
val add_function_slot_in_declaration : t -> Flambda2_identifiers.Function_slot.t -> Name_mode.t -> t
val add_value_slot_in_declaration : t -> Flambda2_identifiers.Value_slot.t -> Name_mode.t -> t
val add_function_slot_in_types : t -> Flambda2_identifiers.Function_slot.t -> t

Closure_variables and function slots in types count as both projection and declaration

val add_value_slot_in_types : t -> Flambda2_identifiers.Value_slot.t -> t
val singleton_code_id : Flambda2_identifiers.Code_id.t -> Name_mode.t -> t
val add_code_id : t -> Flambda2_identifiers.Code_id.t -> Name_mode.t -> t

If the use of the code ID is in a "newer version of" field, use add_newer_version_of_code_id, not this function -- see below.

val add_newer_version_of_code_id : t -> Flambda2_identifiers.Code_id.t -> Name_mode.t -> t

add_newer_version_of_code_id registers a use of a code ID occurring in a "newer version of" field (e.g. in Flambda_static.Static_part.code).

val singleton_name : Flambda2_identifiers.Name.t -> Name_mode.t -> t
val singleton_symbol : Flambda2_identifiers.Symbol.t -> Name_mode.t -> t
val diff : t -> without:t -> t

diff t1 ~without:t2 removes from t1 all those names that occur in t2.

The number of occurrences of any names in the return value will be exactly the same as in t1.

Note that a code ID in t2 will not only be removed from the code ID set in t1 but also the newer-version-of code ID set in t1.

val union : t -> t -> t
val union_list : t list -> t
val subset_domain : t -> t -> bool

subset_domain t1 t2 is the usual "set subset" test on the names occurring in t1 and t2. The numbers of occurrences and the name_modes of those occurrences are ignored.

val inter_domain_is_non_empty : t -> t -> bool
val no_variables : t -> bool
val no_continuations : t -> bool
val continuations_with_traps : t -> Flambda2_identifiers.Continuation.Set.t
val continuations_including_in_trap_actions : t -> Flambda2_identifiers.Continuation.Set.t
val function_slots_in_normal_projections : t -> Flambda2_identifiers.Function_slot.Set.t
val all_function_slots_at_normal_mode : t -> Flambda2_identifiers.Function_slot.Set.t
val value_slots_in_normal_projections : t -> Flambda2_identifiers.Value_slot.Set.t
val all_value_slots_at_normal_mode : t -> Flambda2_identifiers.Value_slot.Set.t
val newer_version_of_code_ids : t -> Flambda2_identifiers.Code_id.Set.t
val restrict_to_value_slots_and_function_slots : t -> t
val code_ids_and_newer_version_of_code_ids : t -> Flambda2_identifiers.Code_id.Set.t
val without_code_ids : t -> t
val with_only_variables : t -> t
val with_only_names : t -> t
val with_only_names_and_code_ids_promoting_newer_version_of : t -> t

The value returned by this function only records occurrences in two fields:

  • names, as per the input
  • code IDs, containing *both* the code IDs and the "newer version of" code IDs from the input.

The "newer version of" code IDs field in the returned value will always be empty.

val without_names_or_continuations : t -> t
val mem_var : t -> Flambda2_identifiers.Variable.t -> bool
val mem_symbol : t -> Flambda2_identifiers.Symbol.t -> bool
val mem_name : t -> Flambda2_identifiers.Name.t -> bool
val mem_code_id : t -> Flambda2_identifiers.Code_id.t -> bool
val mem_continuation : t -> Flambda2_identifiers.Continuation.t -> bool
val value_slot_is_used_or_imported : t -> Flambda2_identifiers.Value_slot.t -> bool
val remove_var : t -> var:Flambda2_identifiers.Variable.t -> t
val remove_var_opt : t -> var:Flambda2_identifiers.Variable.t option -> t
val remove_code_id_or_symbol : t -> code_id_or_symbol:Flambda2_identifiers.Code_id_or_symbol.t -> t
val remove_continuation : t -> continuation:Flambda2_identifiers.Continuation.t -> t
val greatest_name_mode_var : t -> Flambda2_identifiers.Variable.t -> Name_mode.Or_absent.t
val downgrade_occurrences_at_strictly_greater_name_mode : t -> Name_mode.t -> t
val fold_names : t -> init:'a -> f:('a -> Flambda2_identifiers.Name.t -> 'a) -> 'a
val fold_variables : t -> init:'a -> f:('a -> Flambda2_identifiers.Variable.t -> 'a) -> 'a
val fold_continuations_including_in_trap_actions : t -> init:'a -> f:('a -> Flambda2_identifiers.Continuation.t -> 'a) -> 'a
val fold_code_ids : t -> init:'a -> f:('a -> Flambda2_identifiers.Code_id.t -> 'a) -> 'a
val increase_counts : t -> t