expr

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalBool

func EvalBool(expr workflow.Expression, resolve VarResolver) (bool, error)

EvalBool evaluates and returns a bool.

func EvalString

func EvalString(expr workflow.Expression, resolve VarResolver) (string, error)

EvalString is a convenience that evaluates and returns a string.

Types

type Value

type Value struct {
	Type workflow.DataType
	Raw  any // int64, float64, bool, or string
}

Value is the runtime representation of a typed workflow variable.

The workflow has its own type system (int / float / bool / string) that Go's compiler knows nothing about. Value bridges the two: Type carries the declared workflow type, Raw holds the actual storage. Type mismatches are caught at runtime by Cast / AsX, not at compile time.

This is the standard interpreter pattern — the hosted language's type system lives in the interpreter's data structures rather than in the host language's compiler.

func BoolVal

func BoolVal(v bool) Value

func Coerce

func Coerce(dt workflow.DataType, raw any) (Value, error)

Coerce converts any into a typed Value of the declared data type. Nil is treated as absence and returns the zero value without error; any other concrete type that doesn't match dt returns a non-nil error.

func Eval

func Eval(expr workflow.Expression, resolve VarResolver) (Value, error)

Eval evaluates an workflow.Expression against resolved references, returning a typed Value.

func FloatVal

func FloatVal(v float64) Value

func IntVal

func IntVal(v int64) Value

func StringVal

func StringVal(v string) Value

func ZeroValue

func ZeroValue(dt workflow.DataType) Value

ZeroValue returns the zero value for a given data type.

func (Value) AsBool

func (v Value) AsBool() bool

func (Value) AsFloat

func (v Value) AsFloat() float64

func (Value) AsInt

func (v Value) AsInt() int64

func (Value) AsString

func (v Value) AsString() string

func (Value) Cast

func (v Value) Cast(target workflow.DataType) Value

Cast converts a value to the target data type.

type VarResolver

type VarResolver interface {
	Resolve(ref workflow.Reference) (Value, error)
}

VarResolver looks up a variable value by reference. Any type that holds variables (engine.Scope or a test double) can satisfy it.

Jump to

Keyboard shortcuts

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