package ocaml-base-compiler

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Freshening of various identifiers.

type t

A table used for freshening variables and static exception identifiers.

type subst = t
val empty : t

The freshening that does nothing. This is the unique inactive freshening.

val is_empty : t -> bool
val activate : t -> t

Activate the freshening. Without activation, operations to request freshenings have no effect (cf. the documentation below for add_variable). As such, the inactive renaming is unique.

val empty_preserving_activation_state : t -> t

Given the inactive freshening, return the same; otherwise, return an empty active freshening.

val add_variable : t -> Variable.t -> Variable.t * t

add_variable t var If t is active: It returns a fresh variable new_var and adds var -> new_var to the freshening. If a renaming other_var -> var or symbol -> var was already present in t, it will also add other_var -> new_var and symbol -> new_var. If t is inactive, this is the identity.

val add_variables' : t -> Variable.t list -> Variable.t list * t

Like add_variable, but for multiple variables, each freshened separately.

val add_variables : t -> (Variable.t * 'a) list -> (Variable.t * 'a) list * t

Like add_variables', but passes through the second component of the input list unchanged.

val add_mutable_variable : t -> Mutable_variable.t -> Mutable_variable.t * t

Like add_variable, but for mutable variables.

val add_static_exception : t -> Static_exception.t -> Static_exception.t * t

As for add_variable, but for static exception identifiers.

val apply_variable : t -> Variable.t -> Variable.t

apply_variable t var applies the freshening t to var. If no renaming is specified in t for var it is returned unchanged.

val apply_mutable_variable : t -> Mutable_variable.t -> Mutable_variable.t

As for apply_variable, but for mutable variables.

val apply_static_exception : t -> Static_exception.t -> Static_exception.t

As for apply_variable, but for static exception identifiers.

val rewrite_recursive_calls_with_symbols : t -> Flambda.function_declarations -> make_closure_symbol:(Closure_id.t -> Symbol.t) -> Flambda.function_declarations

Replace recursive accesses to the closures in the set through Symbol by the corresponding Var. This is used to recover the recursive call when importing code from another compilation unit.

If the renaming is inactive, this is the identity.

module Project_var : sig ... end
val apply_function_decls_and_free_vars : t -> (Flambda.specialised_to * 'a) Variable.Map.t -> Flambda.function_declarations -> only_freshen_parameters:bool -> (Flambda.specialised_to * 'a) Variable.Map.t * Flambda.function_declarations * t * Project_var.t
val does_not_freshen : t -> Variable.t list -> bool
val print : Format.formatter -> t -> unit
val freshen_projection_relation : Flambda.specialised_to Variable.Map.t -> freshening:t -> closure_freshening:Project_var.t -> Flambda.specialised_to Variable.Map.t

N.B. This does not freshen the domain of the supplied map, only the range.

val freshen_projection_relation' : (Flambda.specialised_to * 'a) Variable.Map.t -> freshening:t -> closure_freshening:Project_var.t -> (Flambda.specialised_to * 'a) Variable.Map.t
OCaml

Innovation. Community. Security.