runtime

package
v6.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

README

Contains state for the CST executor.

Documentation

Overview

Package runtime contains state for the concrete-syntax-tree executor which runs user-specifed statements in the Miller domain-specific language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack() *Stack

func (*Stack) DefineTypedAtScope

func (stack *Stack) DefineTypedAtScope(
	stackVariable *StackVariable,
	typeName string,
	mlrval *mlrval.Mlrval,
) error

For 'num a = 2', setting a variable at the current frame regardless of outer scope. It's an error to define it again in the same scope, whether the type is the same or not.

func (*Stack) Dump

func (stack *Stack) Dump()

func (*Stack) Get

func (stack *Stack) Get(
	stackVariable *StackVariable,
) *mlrval.Mlrval

Returns nil on no-such

func (*Stack) PopStackFrame

func (stack *Stack) PopStackFrame()

For when an if/for/etc block is being exited

func (*Stack) PopStackFrameSet

func (stack *Stack) PopStackFrameSet()

For when a user-defined function/subroutine is being exited

func (*Stack) PushStackFrame

func (stack *Stack) PushStackFrame()

For when an if/for/etc block is being entered

func (*Stack) PushStackFrameSet

func (stack *Stack) PushStackFrameSet()

For when a user-defined function/subroutine is being entered

func (*Stack) Set

func (stack *Stack) Set(
	stackVariable *StackVariable,
	mlrval *mlrval.Mlrval,
) error

For 'a = 2', checking for outer-scoped to maybe reuse, else insert new in current frame. If the variable is entirely new it's set in the current frame with no type-checking. If it's not new the assignment is subject to type-checking for wherever the variable was defined. E.g. if it was previously defined with 'str a = "hello"' then this Set returns an error. However if it waa previously assigned untyped with 'a = "hello"' then the assignment is OK.

func (*Stack) SetAtScope

func (stack *Stack) SetAtScope(
	stackVariable *StackVariable,
	mlrval *mlrval.Mlrval,
) error

For untyped declarations at the current scope -- these are in binds of for-loop variables, except for triple-for. E.g. 'for (k, v in $*)' uses SetAtScope. E.g. 'for (int i = 0; i < 10; i += 1)' uses DefineTypedAtScope E.g. 'for (i = 0; i < 10; i += 1)' uses Set.

func (*Stack) SetIndexed

func (stack *Stack) SetIndexed(
	stackVariable *StackVariable,
	indices []*mlrval.Mlrval,
	mlrval *mlrval.Mlrval,
) error

E.g. 'x[1] = 2' where the variable x may or may not have been already set.

func (*Stack) Unset

func (stack *Stack) Unset(
	stackVariable *StackVariable,
)

E.g. 'unset x'

func (*Stack) UnsetIndexed

func (stack *Stack) UnsetIndexed(
	stackVariable *StackVariable,
	indices []*mlrval.Mlrval,
)

E.g. 'unset x[1]'

type StackFrame

type StackFrame struct {
	// contains filtered or unexported fields
}

type StackFrameSet

type StackFrameSet struct {
	// contains filtered or unexported fields
}

type StackVariable

type StackVariable struct {
	// contains filtered or unexported fields
}

StackVariable is an opaque handle which a callsite can hold onto, which keeps stack-offset information in it that is private to us.

func NewStackVariable

func NewStackVariable(name string) *StackVariable

func NewStackVariableAux

func NewStackVariableAux(name string, cacheable bool) *StackVariable

TODO: comment re function literals

func (*StackVariable) GetName

func (sv *StackVariable) GetName() string

type State

type State struct {
	Inrec                    *mlrval.Mlrmap
	Context                  *types.Context
	Oosvars                  *mlrval.Mlrmap
	FilterExpression         *mlrval.Mlrval
	Stack                    *Stack
	OutputRecordsAndContexts *list.List // list of *types.RecordAndContext

	Options *cli.TOptions

	// StrictMode allows for runtime handling of absent-reads and untyped assignments.
	StrictMode bool
	// contains filtered or unexported fields
}

func NewEmptyState

func NewEmptyState(options *cli.TOptions, strictMode bool) *State

func (*State) GetRegexCaptures

func (state *State) GetRegexCaptures() []string

func (*State) PopRegexCapturesFrame

func (state *State) PopRegexCapturesFrame()

func (*State) PushRegexCapturesFrame

func (state *State) PushRegexCapturesFrame()

func (*State) SetRegexCaptures

func (state *State) SetRegexCaptures(
	captures []string,
)

func (*State) Update

func (state *State) Update(
	inrec *mlrval.Mlrmap,
	context *types.Context,
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL