Signo.Env (Signo v0.0.2)

View Source

Struct holding all variable and function definitions in a certain scope.

Scopes can be nested. Whenever a variable is being looked up, the lookup will walk the scope-chain up until it finds a definition.

Summary

Types

definitions()

@type definitions() :: Enumerable.t({Signo.AST.ref(), Signo.AST.value()})

scope()

@type scope() :: %{required(Signo.AST.ref()) => Signo.AST.value()}

t()

@type t() :: %Signo.Env{parent: t() | nil, scope: scope()}

Functions

assign(env, ref, value, pos \\ %Position{})

@spec assign(t(), Signo.AST.ref(), Signo.AST.value(), Signo.Position.t()) :: t()

import(env, namespace, definitions)

@spec import(t(), Signo.AST.ref(), definitions()) :: t()

lookup!(env, ref, pos \\ %Position{})

@spec lookup!(nil, Signo.AST.ref(), Signo.Position.t()) :: no_return()
@spec lookup!(t(), Signo.AST.ref(), Signo.Position.t()) :: Signo.AST.value()

new(parent, definitions \\ [])

@spec new(t(), definitions()) :: t()