Module Mlsem_lang.MVariable

module SA = Mlsem_system.Ast
type kind =
  1. | Immut
  2. | AnnotMut of Mlsem_types.GTy.t
  3. | Mut
val create : kind -> string option -> t
val refresh : kind -> t -> t
val is_mutable : Mlsem_common.Variable.t -> bool
val kind_equal : kind -> kind -> bool
val kind_compat : kind -> kind -> bool

Binds a top-level variable, giving a mutable one the type its declaration fixes rather than the type inferred for its initializer.

  • raises Invalid_argument

    if the variable is mutable and its declared type contains type variables, or if the inferred type does not match it.

The four operations a mutable variable is encoded with, on an abstract reference type. Each raises Invalid_argument if the variable is not mutable.

val ref_uninit : Mlsem_common.Variable.t -> SA.e

Creation of an uninitialized cell.

  • raises Invalid_argument

    if the variable is not mutable.

val ref_cons : Mlsem_common.Variable.t -> SA.t -> SA.e

Creation of a cell holding the given expression.

  • raises Invalid_argument

    if the variable is not mutable.

val ref_get : Mlsem_common.Variable.t -> SA.e

Read of the cell.

  • raises Invalid_argument

    if the variable is not mutable.

val ref_assign : Mlsem_common.Variable.t -> SA.t -> SA.e

Write of the given expression into the cell.

  • raises Invalid_argument

    if the variable is not mutable.

val as_ref_assign : SA.e -> Mlsem_common.Variable.t option

Recognizes an expression produced by ref_assign, returning the variable being assigned.

content_ty v ty is the type of the values that can be assigned to v, given the type ty of its cell (as produced by the encoding), if it can be determined (i.e. if v is annotated, or if ty is a single ref atom).

  • raises Invalid_argument

    if the variable is not mutable.