Documentation
¶
Overview ¶
Package script implements script environments for engine steps and predicates
Index ¶
- Variables
- type AleEnv
- func (c AleEnv) Compile(step *api.Step, cfg *api.ScriptConfig) (Compiled, error)
- func (e *AleEnv) EvaluatePredicate(c Compiled, step *api.Step, inputs api.Args) (bool, error)
- func (e *AleEnv) ExecuteScript(c Compiled, step *api.Step, inputs api.Args) (api.Args, error)
- func (c AleEnv) Validate(step *api.Step, script string) error
- type Compiled
- type CompiledLua
- type Environment
- type JPathEnv
- func (c JPathEnv) Compile(step *api.Step, cfg *api.ScriptConfig) (Compiled, error)
- func (e *JPathEnv) EvaluatePredicate(c Compiled, _ *api.Step, inputs api.Args) (bool, error)
- func (e *JPathEnv) ExecuteScript(c Compiled, _ *api.Step, inputs api.Args) (api.Args, error)
- func (c JPathEnv) Validate(step *api.Step, script string) error
- type LuaEnv
- func (c LuaEnv) Compile(step *api.Step, cfg *api.ScriptConfig) (Compiled, error)
- func (e *LuaEnv) EvaluatePredicate(c Compiled, _ *api.Step, inputs api.Args) (bool, error)
- func (e *LuaEnv) ExecuteScript(c Compiled, _ *api.Step, inputs api.Args) (api.Args, error)
- func (c LuaEnv) Validate(step *api.Step, script string) error
- type Registry
Constants ¶
This section is empty.
Variables ¶
var ( ErrAleCompile = errors.New("script compile error") ErrAleCall = errors.New("error calling procedure") )
var ( ErrJPathCompile = errors.New("jpath compile error") ErrJPathNoMatch = errors.New("jpath produced no matches") )
var ( ErrLuaLoad = errors.New("lua load error") ErrLuaExecution = errors.New("lua execution error") )
Functions ¶
This section is empty.
Types ¶
type AleEnv ¶
type AleEnv struct {
// contains filtered or unexported fields
}
AleEnv provides an Ale script execution environment
func NewAleEnv ¶
func NewAleEnv() *AleEnv
NewAleEnv creates a new Ale script execution environment with the standard library bootstrapped
func (*AleEnv) EvaluatePredicate ¶
EvaluatePredicate executes a compiled Ale predicate with the provided inputs and returns the boolean result
func (*AleEnv) ExecuteScript ¶
ExecuteScript runs a compiled Ale procedure with the provided inputs and returns the output arguments
type CompiledLua ¶
type CompiledLua struct {
// contains filtered or unexported fields
}
CompiledLua represents a compiled Lua script
type Environment ¶
type Environment interface {
// Validate checks if a script is syntactically valid
Validate(step *api.Step, script string) error
// Compile compiles a script and returns the compiled form
Compile(step *api.Step, cfg *api.ScriptConfig) (Compiled, error)
// ExecuteScript executes a compiled script with the given inputs
ExecuteScript(
c Compiled, step *api.Step, inputs api.Args,
) (api.Args, error)
// EvaluatePredicate evaluates a compiled predicate with given inputs
EvaluatePredicate(
c Compiled, step *api.Step, inputs api.Args,
) (bool, error)
}
Environment defines the interface for script environments
type JPathEnv ¶
type JPathEnv struct {
// contains filtered or unexported fields
}
JPathEnv provides JPath predicate evaluation
func NewJPathEnv ¶
func NewJPathEnv() *JPathEnv
NewJPathEnv creates a JPath predicate evaluation environment
func (*JPathEnv) EvaluatePredicate ¶
EvaluatePredicate applies the compiled JPath expression and treats any match as predicate success, including explicit null matches
func (*JPathEnv) ExecuteScript ¶
ExecuteScript evaluates a compiled JPath expression against mapping inputs
type LuaEnv ¶
type LuaEnv struct {
// contains filtered or unexported fields
}
LuaEnv provides a Lua script execution environment with state pooling
func NewLuaEnv ¶
func NewLuaEnv() *LuaEnv
NewLuaEnv creates a new Lua script execution environment with a state pool for efficient script reuse
func (*LuaEnv) EvaluatePredicate ¶
EvaluatePredicate executes a compiled Lua predicate with the provided inputs and returns the boolean result
func (*LuaEnv) ExecuteScript ¶
ExecuteScript runs a compiled Lua script with the provided inputs and returns the output arguments
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages script environments for different languages
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new registry with Ale, JPath and Lua environments
func (*Registry) Get ¶
func (r *Registry) Get(language string) (Environment, error)
Get returns the script environment for the given language
func (*Registry) Register ¶
func (r *Registry) Register(language string, env Environment)