Documentation
¶
Index ¶
- func CheckType[T any](value interface{}) error
- func ConvertType[T any](value interface{}) (T, error)
- func Eval(expression string, environment interface{}) (interface{}, error)
- func EvalWithEnv(expression string, env interface{}) (interface{}, error)
- func FastRunSimple(program *Program) (interface{}, error)
- func GetType(value interface{}) string
- func IsNil(value interface{}) bool
- func NewEnv() map[string]interface{}
- func ResetStatistics()
- func Run(program *Program, environment interface{}) (interface{}, error)
- func RunWithEnv(program *Program, env interface{}) (interface{}, error)
- func StructToMap(fields map[string]interface{}) map[string]interface{}
- func ToMap(v interface{}) map[string]interface{}
- type AsKind
- type CompileError
- type Config
- type FastExecution
- type Function
- type Mappable
- type Operator
- type Option
- func AllowUndefinedVariables() Option
- func As(kind AsKind) Option
- func AsBool() Option
- func AsFloat64() Option
- func AsInt() Option
- func AsInt64() Option
- func AsString() Option
- func ConstExpr(name string) Option
- func DisableAllBuiltins() Option
- func DisableCache() Option
- func DisableOptimization() Option
- func EnableCache() Option
- func EnableDebug() Option
- func EnableOptimization() Option
- func EnableProfiling() Option
- func EnableSandbox() Option
- func Env(env interface{}) Option
- func Functions(funcs map[string]interface{}) Option
- func Operators(ops map[string]Operator) Option
- func Optimize(enabled bool) Option
- func Patches(patches ...Patch) Option
- func Tags(tag Tag) Option
- func WithBuiltin(name string, fn interface{}) Option
- func WithMaxExecutionTime(duration time.Duration) Option
- func WithOperator(op string, precedence int) Option
- func WithSandbox(sandbox *security.Sandbox) Option
- func WithTimeout(timeout time.Duration) Option
- type Patch
- type Program
- type Result
- type RuntimeError
- type Statistics
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertType ¶
ConvertType attempts to convert a value to the expected type using generics
func EvalWithEnv ¶
EvalWithEnv evaluates an expression with an environment (deprecated)
func FastRunSimple ¶
FastRunSimple is optimized for simple constant expressions
func GetType ¶
func GetType(value interface{}) string
GetType returns the type name of a value using type assertions
func IsNil ¶
func IsNil(value interface{}) bool
IsNil checks if a value is nil using type assertions
func NewEnv ¶
func NewEnv() map[string]interface{}
NewEnv creates a new environment (deprecated, use Env() instead)
func RunWithEnv ¶
RunWithEnv runs a program with an environment (deprecated)
func StructToMap ¶
Example implementation helper for structs
Types ¶
type AsKind ¶
type AsKind int
AsKind represents the different types that can be used in As() function
type CompileError ¶
CompileError represents a compilation error
func NewCompileError ¶
func NewCompileError(message string, line, column int) *CompileError
NewCompileError creates a new compile error
func (*CompileError) Error ¶
func (e *CompileError) Error() string
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds configuration options for the expression engine
type FastExecution ¶
type FastExecution struct {
// contains filtered or unexported fields
}
FastExecution provides ultra-fast execution for simple expressions
func NewFastExecution ¶
func NewFastExecution() *FastExecution
NewFastExecution creates a reusable fast execution engine
func (*FastExecution) FastRun ¶
func (fe *FastExecution) FastRun(program *Program, environment interface{}) (interface{}, error)
FastRun executes a pre-compiled program with minimal overhead
type Mappable ¶
type Mappable interface {
ToMap() map[string]interface{}
}
Mappable interface for types that can convert themselves to maps
type Option ¶
type Option func(*Config)
Option represents a configuration option function
func AllowUndefinedVariables ¶
func AllowUndefinedVariables() Option
AllowUndefinedVariables allows undefined variables to be used
func DisableAllBuiltins ¶
func DisableAllBuiltins() Option
DisableAllBuiltins disables all built-in functions
func DisableOptimization ¶
func DisableOptimization() Option
DisableOptimization disables bytecode optimization
func EnableOptimization ¶
func EnableOptimization() Option
EnableOptimization enables bytecode optimization
func EnableSandbox ¶
func EnableSandbox() Option
EnableSandbox enables security sandbox with default settings
func WithBuiltin ¶
WithBuiltin adds a custom built-in function
func WithMaxExecutionTime ¶
WithMaxExecutionTime sets the maximum execution time (also configures sandbox)
func WithOperator ¶
WithOperator adds a custom operator with precedence
func WithSandbox ¶
WithSandbox sets a custom security sandbox
func WithTimeout ¶
WithTimeout sets the maximum execution time
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program represents a compiled expression program
func CompileWithEnv ¶
CompileWithEnv compiles an expression with an environment (deprecated)
func (*Program) BytecodeSize ¶
BytecodeSize returns the size of the compiled bytecode
func (*Program) CompileTime ¶
CompileTime returns the compilation time
func (*Program) ConstantsCount ¶
ConstantsCount returns the number of constants in the program
type Result ¶
type Result struct {
Value interface{}
Type string
// Performance metrics
ExecutionTime time.Duration
MemoryUsed int64
}
Result represents the result of expression evaluation
func EvalWithResult ¶
EvalWithResult is like Eval but returns detailed result information
func RunWithResult ¶
RunWithResult executes a program and returns detailed result information
type RuntimeError ¶
RuntimeError represents a runtime error
func NewRuntimeError ¶
func NewRuntimeError(message string, cause error) *RuntimeError
NewRuntimeError creates a new runtime error
func (*RuntimeError) Error ¶
func (e *RuntimeError) Error() string
func (*RuntimeError) Unwrap ¶
func (e *RuntimeError) Unwrap() error
Unwrap returns the underlying cause
type Statistics ¶
type Statistics struct {
TotalCompilations int64
TotalExecutions int64
AverageCompileTime time.Duration
AverageExecTime time.Duration
CacheHitRate float64
MemoryUsage int64
}
Statistics holds performance statistics
func GetStatistics ¶
func GetStatistics() *Statistics
GetStatistics returns global performance statistics
Directories
¶
| Path | Synopsis |
|---|---|
|
advanced_builtins_example
command
|
|
|
api_example
command
|
|
|
as_example
command
|
|
|
builtins_example
command
|
|
|
checker_example
command
|
|
|
collections_example
command
|
|
|
collections_simple_test
command
|
|
|
compiler_example
command
|
|
|
comprehensive_features_demo
command
|
|
|
comprehensive_test
command
|
|
|
debug_opcode
command
|
|
|
debug_pipeline
command
|
|
|
debug_test
command
|
|
|
env_example
command
|
|
|
final_demo
command
|
|
|
generic_test
command
|
|
|
improvements_demo
command
|
|
|
lambda_demo
command
|
|
|
new_builtins_demo
command
|
|
|
not_test
command
|
|
|
performance_example
command
|
|
|
pipeline_placeholder_demo
command
|
|
|
simple_env_example
command
|
|
|
vm_example
command
|
|
|
week9_demo
command
|
|