package herdtools7

  1. Overview
  2. Docs

Static Environment used for type-checking (cf Typing.

type global = {
  1. declared_types : (AST.ty * SideEffect.TimeFrame.t) ASTUtils.IMap.t;
    (*

    Maps a type name t to its declaration and its time-frame.

    As expressions on which a type depends need to be statically evaluable, the only effects allowed in a type are statically evaluable, so need to be reading immutable (global) storage elements. This makes it possible only to store the time-frame of the type, and not the whole side-effect set.

    *)
  2. constant_values : AST.literal Storage.t;
    (*

    Maps a global constant name to its value.

    *)
  3. storage_types : (AST.ty * AST.global_decl_keyword) ASTUtils.IMap.t;
    (*

    Maps global declared storage elements to their types.

    *)
  4. subtypes : AST.identifier ASTUtils.IMap.t;
    (*

    Maps an identifier s to its parent in the subtype relation.

    *)
  5. subprograms : (AST.func * SideEffect.SES.t) ASTUtils.IMap.t;
    (*

    Maps each subprogram runtime name to its signature and the side-effects inferred for it.

    *)
  6. overloaded_subprograms : ASTUtils.ISet.t ASTUtils.IMap.t;
    (*

    Maps the name of each declared subprogram to the equivalence class of all the subprogram runtime names that were declared with this name.

    *)
  7. expr_equiv : AST.expr ASTUtils.IMap.t;
    (*

    Maps every expression to a reduced immutable form.

    *)
}

Store all the global environment information at compile-time.

type local = {
  1. constant_values : AST.literal Storage.t;
    (*

    Maps a local constant to its value.

    *)
  2. storage_types : (AST.ty * AST.local_decl_keyword) ASTUtils.IMap.t;
    (*

    Maps an locally declared names to their type.

    *)
  3. expr_equiv : AST.expr ASTUtils.IMap.t;
    (*

    Maps immutable storage to their oldest equivalent expression.

    *)
  4. return_type : AST.ty option;
    (*

    Local return type, None for procedures, global constants, or setters.

    *)
}

Store all the local environment information at compile-time.

type env = {
  1. global : global;
  2. local : local;
}

The static environment type.

val pp_env : Format.formatter -> env -> unit
val pp_global : Format.formatter -> global -> unit
val pp_local : Format.formatter -> local -> unit
val empty_global : global
val empty_local : local
val empty_local_return_type : AST.ty option -> local
val empty : env
val with_empty_local : global -> env
val lookup_constants : env -> AST.identifier -> AST.literal

lookup x env is the value of x as defined in environment.

  • raises Not_found

    if it is not defined inside.

val lookup_constants_opt : env -> AST.identifier -> AST.literal option
val type_of : env -> AST.identifier -> AST.ty

type_of env "x" is the type of "x" in the environment env.

val type_of_opt : env -> AST.identifier -> AST.ty option
val lookup_immutable_expr : env -> AST.identifier -> AST.expr
val lookup_immutable_expr_opt : env -> AST.identifier -> AST.expr option
val mem_constants : env -> AST.identifier -> bool
val add_subprogram : AST.identifier -> AST.func -> SideEffect.SES.t -> env -> env
val set_renamings : AST.identifier -> ASTUtils.ISet.t -> env -> env
val add_global_storage : AST.identifier -> AST.ty -> AST.global_decl_keyword -> global -> global
val add_global_constant : AST.identifier -> AST.literal -> global -> global
val add_local_constant : AST.identifier -> AST.literal -> env -> env
val add_local_immutable_expr : AST.identifier -> AST.expr -> env -> env

add_local_immutable_expr x e env binds x to e in env. x is assumed to name an immutable local storage element. e is supposed to be the oldest expression corresponding to x.

val add_global_immutable_expr : AST.identifier -> AST.expr -> env -> env

add_global_immutable_expr x e env binds x to e in env. x is assumed to name an immutable global storage element. e is supposed to be the oldest expression corresponding to x.

val add_local : AST.identifier -> AST.ty -> AST.local_decl_keyword -> env -> env
val add_subtype : AST.identifier -> AST.identifier -> env -> env
val is_local_undefined : AST.identifier -> local -> bool
val is_global_undefined : AST.identifier -> global -> bool
val is_undefined : AST.identifier -> env -> bool
val is_subprogram : AST.identifier -> env -> bool
OCaml

Innovation. Community. Security.