Documentation ¶
Index ¶
- type Activation
- type Activations
- func (a *Activations[T]) Current() *Activation[T]
- func (a *Activations[T]) CurrentOrNew() *Activation[T]
- func (a *Activations[T]) Depth() int
- func (a *Activations[T]) Find(name string) (_ T)
- func (a *Activations[T]) Pop()
- func (a *Activations[T]) Push(activation *Activation[T])
- func (a *Activations[T]) PushNewWithCurrent()
- func (a *Activations[T]) PushNewWithParent(parent *Activation[T]) *Activation[T]
- func (a *Activations[T]) Set(name string, value T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activation ¶ added in v0.6.0
type Activation[T any] struct { MemoryGauge common.MemoryGauge Parent *Activation[T] Depth int IsFunction bool // contains filtered or unexported fields }
Activation is a map of strings to values. It can be used to represent an active scope in a program, i.e. it can be used as a symbol table during semantic analysis, or as an activation record during interpretation or compilation.
func NewActivation ¶ added in v0.6.0
func NewActivation[T any](memoryGauge common.MemoryGauge, parent *Activation[T]) *Activation[T]
func (*Activation[T]) Find ¶ added in v0.6.0
func (a *Activation[T]) Find(name string) (_ T)
Find returns the value for a given name in the activation. It returns nil if no value is found.
func (*Activation[T]) FunctionValues ¶ added in v0.27.0
func (a *Activation[T]) FunctionValues() map[string]T
FunctionValues returns all values in the current function activation.
func (*Activation[T]) Set ¶ added in v0.12.6
func (a *Activation[T]) Set(name string, value T)
Set sets the given name-value pair in the activation.
type Activations ¶
type Activations[T any] struct { // contains filtered or unexported fields }
Activations is a stack of activation records. Each entry represents a new activation record.
The current / most nested activation record can be found at the top of the stack (see function `Current`).
func NewActivations ¶ added in v0.27.0
func NewActivations[T any](memoryGauge common.MemoryGauge) *Activations[T]
func (*Activations[T]) Current ¶ added in v0.12.6
func (a *Activations[T]) Current() *Activation[T]
Current returns the current / most nested activation, which can be found at the top of the stack. It returns nil if there is no active activation.
func (*Activations[T]) CurrentOrNew ¶
func (a *Activations[T]) CurrentOrNew() *Activation[T]
CurrentOrNew returns the current activation, or if it does not exist, a new activation
func (*Activations[T]) Depth ¶
func (a *Activations[T]) Depth() int
Depth returns the depth (size) of the activation stack.
func (*Activations[T]) Find ¶
func (a *Activations[T]) Find(name string) (_ T)
Find returns the value for a given key in the current activation. It returns nil if no value is found or if there is no current activation.
func (*Activations[T]) Pop ¶
func (a *Activations[T]) Pop()
Pop pops the top-most (current) activation from the top of the activation stack.
func (*Activations[T]) Push ¶
func (a *Activations[T]) Push(activation *Activation[T])
Push pushes the given activation onto the top of the activation stack.
func (*Activations[T]) PushNewWithCurrent ¶ added in v0.12.6
func (a *Activations[T]) PushNewWithCurrent()
PushNewWithCurrent pushes a new empty activation to the top of the activation stack. The new activation has the current activation as its parent.
func (*Activations[T]) PushNewWithParent ¶ added in v0.12.6
func (a *Activations[T]) PushNewWithParent(parent *Activation[T]) *Activation[T]
PushNewWithParent pushes a new empty activation to the top of the activation stack. The new activation has the given parent as its parent.
func (*Activations[T]) Set ¶
func (a *Activations[T]) Set(name string, value T)
Set sets the name-value pair in the current scope.