Documentation
¶
Overview ¶
Package vm provides an Alloy syntax expression evaluator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator evaluates Alloy syntax AST nodes into Go values. Each Evaluator is bound to a single AST node. To evaluate the node, call Evaluate.
func New ¶
New creates a new Evaluator for the given AST node. The given node must be either an *ast.File, *ast.BlockStmt, ast.Body, or assignable to an ast.Expr.
func (*Evaluator) Evaluate ¶
Evaluate evaluates the Evaluator's node into a Alloy syntax value and decodes that value into the Go value v.
Each call to Evaluate may provide a different scope with new values for available variables. If a variable used by the Evaluator's node isn't defined in scope, Evaluate will return an error.
type Scope ¶
type Scope struct {
// Variables holds the list of available variable names that can be used when
// evaluating a node.
//
// Values in the Variables map should be considered immutable after passed to
// Evaluate; maps and slices will be copied by reference for performance
// optimizations.
Variables map[string]any
}
A Scope exposes a set of variables available to use during evaluation.
func (*Scope) IsStdlibDeprecated ¶ added in v0.1.1
IsStdlibDeprecated returns true if the identifier exists and is deprecated.
func (*Scope) IsStdlibExperimental ¶ added in v0.1.1
IsStdlibExperimental returns true if the scoped identifier is experimental.
func (*Scope) IsStdlibIdentifiers ¶ added in v0.1.1
IsStdlibIdentifiers returns true if the identifier exists.