package herdtools7

  1. Overview
  2. Docs

Internal representation for subprograms.

Parameters

module C : RunTimeConf

Signature

Types and constructors.

type func = int ref * AST.func

A function has an index that keeps a unique calling index.

type global = {
  1. static : StaticEnv.global;
    (*

    References the static environment.

    *)
  2. storage : C.v Storage.t;
    (*

    Binds global variables to their names.

    *)
  3. funcs : func ASTUtils.IMap.t;
    (*

    Declared subprograms, maps called identifier to their code.

    *)
}

The global part of an environment.

type local

The local part of an environment.

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

The environment type.

val empty_local : local

An empty local environment.

val to_static : env -> StaticEnv.env

Builds a static environment, with an empty local part.

val empty_scoped : AST.scope -> local

empty_scoped scope is an empty local environment in the scope scope.

Accessors

type 'a env_result =
  1. | Local of 'a
  2. | Global of 'a
  3. | NotFound
    (*

    Indicates if the value returned was bound in the global or local namespace.

    *)
val find : AST.identifier -> env -> C.v env_result

Fetches an identifier from the environment.

val mem : AST.identifier -> env -> bool

mem x env is true iff x is bound in env.

val declare_local : AST.identifier -> C.v -> env -> env

declare_local x v env is env where x is now bound to v. This binding will be discarded by the call to pop_scope corresponding to the last call to push_scope before this declaration.

val assign_local : AST.identifier -> C.v -> env -> env

assign_local x v env is env where x is now bound to v. It is assumed to be already bound in env.

val declare_global : AST.identifier -> C.v -> env -> env

declare_global x v env is env where x is now bound to v. It is supposed that x is not bound in env.

val assign_global : AST.identifier -> C.v -> env -> env

assign_global x v env is env where x is now bound to v. It is assumed to be already bound in env.

val remove_local : AST.identifier -> env -> env

remove_local x env is env where x is not bound.

val assign : AST.identifier -> C.v -> env -> env env_result

assign x v env assigns x to v in env, and returns if x was declared as a local or global identifier.

Loop unrolling

val tick_push : env -> env

Push a new unrolling counter on the stack. The associated loop will be unrolled C.unroll times.

val tick_push_bis : env -> env

Push a new unrolling counter on the stack. The associated loop will be unrolled C.unroll - 1 times.

val tick_pop : env -> env

Discards the last unrolling counter of the stack.

val tick_decr : env -> bool * env

tick_decr env is (stop, env') where

  • if the last counter is lower or equal to 1, stop is true and the last counter is discarded.
  • if the last counter is bigger or equal to 2, stop is false and the counter is decremented of 1.

Scope handling

val get_scope : env -> AST.scope

Returns the local scope of that environment.

val same_scope : env -> env -> bool

same_scope env1 env2 is true iff env1's scope and env2'scope are equal.

val push_scope : env -> env

Push a new scope on the declaration stack. Variables declared here will be stored until the corresponding pop_scope.

val pop_scope : env -> env -> env

pop_scope old new restores the variable bindings of old, with the updated values of new.

OCaml

Innovation. Community. Security.