Documentation
¶
Index ¶
- Constants
- func AnalyzeSyntax(inputSource string) (bool, string)
- func BatchAppend(base []any, slices ...[]any) []any
- func BatchArrayAppend(target *[]Value, sources ...*[]Value)
- func BatchMapMerge(target map[string]Value, sources ...map[string]Value)
- func CleanupMemoryLayout() error
- func CopyScope(scope map[string]Value) map[string]Value
- func CreateDefaultInterpreter() *interpreter
- func CreateEmptyScope() map[string]Value
- func Evaluate(expr Expression, config *Config) (v Value, stats *Stats, err error)
- func FastHash(funcName string, args []Value) uint64
- func FastSliceAppendMapValue(slice []map[string]Value, elements ...map[string]Value) []map[string]Value
- func FastSliceAppendString(slice []string, elements ...string) []string
- func FastStringEqual(a, b string) bool
- func FormatError(err error, filename string) string
- func FormatExecutionError(err error, source []byte, filename string) string
- func GetByteSlice() []byte
- func GetMemoryLeakDetectionInterval() int
- func GetOptimalArrayCapacity(expectedSize int) int
- func GetOptimalStrategy(expectedSize int) string
- func GetOptimizedStringBuilder() *strings.Builder
- func GetPooledBool() *bool
- func GetPooledFloat() *float64
- func GetPooledInt() *int
- func GetPooledMap() map[string]Value
- func GetPooledStringBuilder() *strings.Builder
- func GetSmartInternerStats() map[string]any
- func GetStringBuilder() *strings.Builder
- func GetStringInternerStats() (hits, misses int64, hitRatio float64)
- func GetVariableLookupCacheSize() int
- func GetVersionInfo() string
- func InitializeBuiltinDispatcher()
- func InternIdentifier(s string) string
- func InternLiteral(s string) string
- func InternOperator(s string) string
- func InternString(s string) string
- func InternStringEnhanced(s string) string
- func IsAutoCleanupMemoryLeaksEnabled() bool
- func IsBuiltinFunction(value Value) bool
- func IsCacheFriendlyStructuresEnabled() bool
- func IsCompactEnvironmentEnabled() bool
- func IsExpression(node any) bool
- func IsFunction(value Value) bool
- func IsMemoryLeakDetectionEnabled() bool
- func IsNumeric(value Value) bool
- func IsStatement(node any) bool
- func IsTaggedValuesEnabled() bool
- func IsTruthy(value Value) bool
- func IsUserDefinedFunction(value Value) bool
- func IsValidFileExtension(filename string) bool
- func IsValidIdentifier(name string) bool
- func IsVariableLookupCacheEnabled() bool
- func OptimizedJoin(arr []Value, separator string) string
- func OptimizedMakeMap(expectedSize int) map[string]Value
- func OptimizedMapCopy(source map[string]Value) map[string]Value
- func OptimizedMapMerge(maps ...map[string]Value) map[string]Value
- func OptimizedMemoKey(funcName string, args []Value) uint64
- func OptimizedStringConcat(strings ...string) string
- func OptimizedStringJoin(arr []Value, separator string) string
- func PrintStats(stats Stats, output io.Writer)
- func PutArenaToPool(aa *ArenaAllocator)
- func PutArrayConcatenator(ac *ArrayConcatenator)
- func PutByteSlice(b []byte)
- func PutCallStack(cs *CallStack)
- func PutExpressionArena(ea *ExpressionArena)
- func PutMapBuilder(mb *MapBuilder)
- func PutOptimizedStringBuilder(sb *strings.Builder)
- func PutPooledArray(arr []Value)
- func PutPooledBool(v *bool)
- func PutPooledFloat(v *float64)
- func PutPooledInt(v *int)
- func PutPooledMap(m map[string]Value)
- func PutPooledStringBuilder(sb *strings.Builder)
- func PutStringBuilder(sb *strings.Builder)
- func PutStringConcatenator(sc *StringConcatenator)
- func ResetGlobalMemoryLayoutConfig()
- func RunProgram(inputSource string) (bool, string)
- func RunProgramWithOptions(inputSource string, options *RunProgramOptions) (bool, string)
- func SetGlobalMemoryLayoutConfig(config *MemoryLayoutConfig)
- func SmartAppendInterface(slice []any, values ...any) []any
- func SmartAppendMapValue(slice []map[string]Value, elements ...map[string]Value) []map[string]Value
- func SmartAppendString(slice []string, values ...string) []string
- func SyntaxAnalyze(inputSource string) (bool, string)
- func ToFloat(value Value) (float64, bool)
- func ToInt(value Value) (int, bool)
- func ToString(value Value) string
- func TrackOperation(operation string)
- func ValidateProgram(program *Program) error
- func WrapError(err error, context string) error
- type ASTNodePool
- func (pool *ASTNodePool) GetBinary() *Binary
- func (pool *ASTNodePool) GetCall() *Call
- func (pool *ASTNodePool) GetList() *List
- func (pool *ASTNodePool) GetLiteral() *Literal
- func (pool *ASTNodePool) GetMap() *Map
- func (pool *ASTNodePool) GetSubscript() *Subscript
- func (pool *ASTNodePool) GetUnary() *Unary
- func (pool *ASTNodePool) GetVariable() *Variable
- func (pool *ASTNodePool) PutBinary(node *Binary)
- func (pool *ASTNodePool) PutCall(node *Call)
- func (pool *ASTNodePool) PutList(node *List)
- func (pool *ASTNodePool) PutLiteral(node *Literal)
- func (pool *ASTNodePool) PutMap(node *Map)
- func (pool *ASTNodePool) PutSubscript(node *Subscript)
- func (pool *ASTNodePool) PutUnary(node *Unary)
- func (pool *ASTNodePool) PutVariable(node *Variable)
- type AllocationInfo
- type ArenaAllocator
- type ArenaPool
- type ArenaSlice
- type ArenaStats
- type ArenaString
- type ArgumentValidationCache
- type ArrayConcatenator
- type Assign
- type AsyncIOPool
- type AsyncIOWorker
- type AsyncManager
- type AsyncOperation
- type BatchArrayProcessor
- type BatchOperation
- type BatchResult
- type Binary
- type BinlogStreamer
- type Block
- type Break
- type BreakException
- type BuiltinFunctionDispatcher
- func (bfd *BuiltinFunctionDispatcher) DispatchBuiltinFunction(name string, interp *interpreter, pos Position, args []Value) (Value, bool)
- func (bfd *BuiltinFunctionDispatcher) GetCallCount(name string) int64
- func (bfd *BuiltinFunctionDispatcher) GetMostCalledFunctions(limit int) []string
- func (bfd *BuiltinFunctionDispatcher) RegisterBuiltinFunction(name string, fn func(*interpreter, Position, []Value) Value, argCount int, ...)
- type BuiltinFunctionEntry
- type CacheFriendlyArray
- type CacheFriendlyMap
- type CachedVariable
- type Call
- type CallFrame
- type CallStack
- func (cs *CallStack) Depth() int
- func (cs *CallStack) Peek() *CallFrame
- func (cs *CallStack) Pop() *CallFrame
- func (cs *CallStack) PopCall()
- func (cs *CallStack) Push(functionName string, args []Value, scope map[string]Value)
- func (cs *CallStack) PushCall(callInfo map[string]any)
- func (cs *CallStack) Release()
- type ChunkedArrayProcessor
- type CommonSubexpressionEliminator
- type CompactEnvironment
- type ComplexOperationPool
- func (cop *ComplexOperationPool) GetArray() []Value
- func (cop *ComplexOperationPool) GetIntSlice() []int
- func (cop *ComplexOperationPool) GetLargeArray() []Value
- func (cop *ComplexOperationPool) GetMap() map[string]Value
- func (cop *ComplexOperationPool) GetSmallArray() []Value
- func (cop *ComplexOperationPool) GetStringBuilder() *strings.Builder
- func (cop *ComplexOperationPool) PutArray(arr *[]Value)
- func (cop *ComplexOperationPool) PutIntSlice(slice *[]int)
- func (cop *ComplexOperationPool) PutLargeArray(arr *[]Value)
- func (cop *ComplexOperationPool) PutMap(m *map[string]Value)
- func (cop *ComplexOperationPool) PutSmallArray(arr *[]Value)
- func (cop *ComplexOperationPool) PutStringBuilder(sb *strings.Builder)
- type ConcurrentExecutor
- func (ce *ConcurrentExecutor) ExecuteIOTask(ioFunc func() (Value, error)) (Value, error)
- func (ce *ConcurrentExecutor) ExecuteTask(taskFunc func() (Value, error), timeout time.Duration) (Value, error)
- func (ce *ConcurrentExecutor) GetStats() ConcurrentStats
- func (ce *ConcurrentExecutor) ParallelFilterOperation(array []Value, filterFunc func(Value) bool) ([]Value, error)
- func (ce *ConcurrentExecutor) ParallelMapOperation(array []Value, mapFunc func(Value) Value) ([]Value, error)
- func (ce *ConcurrentExecutor) ParallelReduceOperation(array []Value, reduceFunc func(Value, Value) Value, initialValue Value) (Value, error)
- func (ce *ConcurrentExecutor) ResetStats()
- func (ce *ConcurrentExecutor) Shutdown()
- type ConcurrentStats
- type Config
- type ConnectionPool
- type ConnectionPoolConfig
- type ConstantFolder
- type Continue
- type ContinueException
- type DatabaseConnection
- type DatabaseStreamer
- type EnhancedStringInterner
- type Environment
- func (env *Environment) Assign(name string, value Value)
- func (env *Environment) AssignOuter(name string, value Value)
- func (env *Environment) GetArgs() []string
- func (env *Environment) GetExit() func(int)
- func (env *Environment) GetStdin() io.Reader
- func (env *Environment) GetStdout() io.Writer
- func (env *Environment) IsUnitTest() bool
- func (env *Environment) Lookup(name string) (Value, bool)
- func (env *Environment) PopScope()
- func (env *Environment) PushScope()
- func (env *Environment) ScopeCount() int
- type Error
- type ErrorInterpreter
- type Evaluator
- type Expression
- type ExpressionArena
- type ExpressionArenaPool
- type ExpressionOptimizer
- type ExpressionStatement
- type FastNumericEvaluator
- func (fne *FastNumericEvaluator) FastEvalDivide(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalEqual(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalLess(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalMinus(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalModulo(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalPlus(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalPower(l, r Value) (Value, bool)
- func (fne *FastNumericEvaluator) FastEvalTimes(l, r Value) (Value, bool)
- type FastSlice
- type FastTypeAssertion
- type For
- type FunctionCallCache
- type FunctionDefinition
- type FunctionExpression
- type GlobalVariableCache
- type HybridAppendStrategy
- type IOTask
- type If
- type Import
- type List
- type Literal
- type Map
- type MapBuilder
- type MapItem
- type MemoizationConfig
- type MemoryError
- type MemoryLayoutConfig
- type MemoryLayoutOptimizer
- func (opt *MemoryLayoutOptimizer) GetMemoryStats() MemoryStats
- func (opt *MemoryLayoutOptimizer) IncrementCacheHits()
- func (opt *MemoryLayoutOptimizer) IncrementCacheMisses()
- func (opt *MemoryLayoutOptimizer) IncrementTaggedValuesCreated()
- func (opt *MemoryLayoutOptimizer) IncrementTaggedValuesReused()
- func (opt *MemoryLayoutOptimizer) ResetStats()
- type MemoryStats
- type MemoryTracker
- type NameError
- type OptimizedMemoCache
- type OuterAssign
- type ParallelArrayProcessor
- type PerformanceMonitor
- type PoolStats
- type PooledStringBuilder
- type Position
- type ProductionMemoCache
- func (pmc *ProductionMemoCache) CleanupExpired() int
- func (pmc *ProductionMemoCache) Clear()
- func (pmc *ProductionMemoCache) Get(key uint64) (Value, bool)
- func (pmc *ProductionMemoCache) IsEnabled() bool
- func (pmc *ProductionMemoCache) Set(key uint64, value Value)
- func (pmc *ProductionMemoCache) SetEnabled(enabled bool)
- func (pmc *ProductionMemoCache) Size() int
- type Program
- type Queue
- type Return
- type RunProgramOptions
- type RuntimeError
- type SafeTaggedValue
- type SafeTaggedValuePool
- func (stvp *SafeTaggedValuePool) GetSafeTaggedValue() (*SafeTaggedValue, error)
- func (stvp *SafeTaggedValuePool) GetStats() PoolStats
- func (stvp *SafeTaggedValuePool) GetTaggedValue() *SafeTaggedValue
- func (stvp *SafeTaggedValuePool) IsAtCapacity() bool
- func (stvp *SafeTaggedValuePool) PutSafeTaggedValue(tv *SafeTaggedValue) error
- func (stvp *SafeTaggedValuePool) PutTaggedValue(tv *SafeTaggedValue)
- type ScopeFlattener
- type Set
- type SmartStringInterner
- type SpecializedBuiltinFunctions
- type Stack
- type Statement
- type Stats
- type StringConcatenator
- type StringInterner
- type StringPool
- type StringType
- type Subscript
- type TableColumnConfig
- type TaggedValueType
- type Task
- type TaskResult
- type Ternary
- type Token
- type TokenCache
- type Tokenizer
- type TryCatch
- type TypeError
- type Unary
- type Value
- func CreateSafeValue(value Value) Value
- func DeepCopy(value Value) Value
- func FastSliceAppendValue(slice []Value, elements ...Value) []Value
- func GetPooledArray(expectedSize int) []Value
- func OptimizedArrayCopy(source []Value) []Value
- func OptimizedArrayFilter(arr []Value, predicate func(Value) bool) []Value
- func OptimizedArrayMap(arr []Value, mapper func(Value) Value) []Value
- func OptimizedLargeArrayFilter(arr []Value, predicate func(Value) bool) []Value
- func OptimizedMakeSlice(length, expectedGrowth int) []Value
- func SmartAppend(slice []Value, values ...Value) []Value
- func WithArena(fn func(*ExpressionArena) Value) Value
- type ValueError
- type ValuePool
- type ValueType
- type Variable
- type VariableLookupCache
- func (vlc *VariableLookupCache) CacheVariable(name string, value Value, scopeLevel int)
- func (vlc *VariableLookupCache) ClearCache()
- func (vlc *VariableLookupCache) FastLookup(name string, env *Environment) (Value, bool)
- func (vlc *VariableLookupCache) GetCacheStats() (hits, misses int64, hitRatio float64)
- func (vlc *VariableLookupCache) InvalidateScope(scopeLevel int)
- func (vlc *VariableLookupCache) InvalidateVariable(name string)
- type While
- type Worker
- type WorkerPool
Constants ¶
const ( // Stop tokens ILLEGAL Token = iota EOF // Single-character tokens (using ASCII values) LPAREN = 40 // '(' RPAREN = 41 // ')' TIMES = 42 // '*' PLUS = 43 // '+' COMMA = 44 // ',' MINUS = 45 // '-' DOT = 46 // '.' DIVIDE = 47 // '/' COLON = 58 // ':' LT = 60 // '<' ASSIGN = 61 // '=' GT = 62 // '>' QUESTION = 63 // '?' LBRACKET = 91 // '[' RBRACKET = 93 // ']' LBRACE = 123 // '{' RBRACE = 125 // '}' MODULO = 37 // '%' // Alternative block tokens (sequential from 200) END = 200 // Two-character tokens (sequential from 300) EQUAL = 300 GTE = 301 LTE = 302 NOTEQUAL = 303 PLUSEQUAL = 304 MINUSEQUAL = 305 TIMESEQUAL = 306 DIVIDEEQUAL = 307 MODULOEQUAL = 308 // Power operator (two-character token) POWER = 309 // Three-character tokens (sequential from 400) ELLIPSIS = 400 // Keywords (sequential from 500) AND = 500 BREAK = 501 CATCH = 502 CONTINUE = 503 ELSE = 504 FALSE = 505 FOR = 506 FUN = 507 IF = 508 IMPORT = 509 IN = 510 NULL = 511 NOT = 512 OR = 513 RETURN = 514 THEN = 515 TRUE = 516 TRY = 517 WHILE = 518 XOR = 519 MEMO = 520 ELIF = 521 // Literals and identifiers (sequential from 600) INT = 600 FLOAT = 601 NAME = 602 STR = 603 )
const ( // Version information LanguageName = "Uddin-Lang" LanguageVersion = "1.0.0" // Default values DefaultFileExtension = ".din" DefaultExamplesDir = "./examples" // Error message constants ErrorTypePrefix = "Type Error" ErrorValuePrefix = "Value Error" ErrorNamePrefix = "Name Error" ErrorRuntimePrefix = "Runtime Error" ErrorSyntaxPrefix = "Syntax Error" )
Language constants and version information
Variables ¶
This section is empty.
Functions ¶
func AnalyzeSyntax ¶
AnalyzeSyntax performs syntax analysis on the given source code without executing it. This function only checks for syntax errors and returns detailed error information if found.
Parameters:
- inputSource: The source code to analyze as a string
Returns:
- bool: true if syntax is valid, false if there are syntax errors
- string: Success message or detailed error information
func BatchAppend ¶
BatchAppend appends multiple slices efficiently
func BatchArrayAppend ¶
BatchArrayAppend efficiently appends multiple arrays
func BatchMapMerge ¶
BatchMapMerge efficiently merges multiple maps
func CreateDefaultInterpreter ¶
func CreateDefaultInterpreter() *interpreter
CreateDefaultInterpreter creates an interpreter with default settings
func CreateEmptyScope ¶
CreateEmptyScope creates an empty variable scope
func Evaluate ¶
func Evaluate(expr Expression, config *Config) (v Value, stats *Stats, err error)
Evaluate takes a parsed Expression and interpreter config and evaluates the expression, returning the Value of the expression, interpreter statistics, and an error which is nil on success or an interpreter.Error if there's an error.
func FastHash ¶
FastHash computes a fast hash for memoization keys Uses FNV-1a hash which is faster than string concatenation
func FastSliceAppendMapValue ¶
func FastSliceAppendString ¶
func FastStringEqual ¶
FastStringEqual performs fast string equality check with interning
func FormatError ¶
FormatError formats an error with position information
func FormatExecutionError ¶
FormatExecutionError formats execution errors with better context
func GetMemoryLeakDetectionInterval ¶
func GetMemoryLeakDetectionInterval() int
GetMemoryLeakDetectionInterval returns the configured memory leak detection interval in seconds
func GetOptimalArrayCapacity ¶
GetOptimalArrayCapacity returns optimal capacity based on expected size
func GetOptimalStrategy ¶
GetOptimalStrategy returns the recommended strategy based on expected data size
func GetOptimizedStringBuilder ¶
GetOptimizedStringBuilder gets a string builder from the global pool
func GetPooledStringBuilder ¶
GetPooledStringBuilder returns a pooled string builder
func GetSmartInternerStats ¶
GetSmartInternerStats returns statistics from the global smart interner
func GetStringBuilder ¶
GetStringBuilder gets a string builder from the global pool
func GetStringInternerStats ¶
GetStringInternerStats returns statistics from the global string interner
func GetVariableLookupCacheSize ¶
func GetVariableLookupCacheSize() int
GetVariableLookupCacheSize returns the configured variable lookup cache size
func GetVersionInfo ¶
func GetVersionInfo() string
GetVersionInfo returns version information about the interpreter
func InitializeBuiltinDispatcher ¶
func InitializeBuiltinDispatcher()
InitializeBuiltinDispatcher initializes the builtin function dispatcher with all builtin functions
func InternIdentifier ¶
InternIdentifier interns an identifier string
func InternOperator ¶
InternOperator interns an operator string
func InternString ¶
InternString provides global string interning
func InternStringEnhanced ¶
InternStringEnhanced interns a string using the global enhanced interner
func IsAutoCleanupMemoryLeaksEnabled ¶
func IsAutoCleanupMemoryLeaksEnabled() bool
IsAutoCleanupMemoryLeaksEnabled returns true if automatic cleanup of memory leaks is enabled
func IsBuiltinFunction ¶
IsBuiltinFunction checks if a value is a builtin function
func IsCacheFriendlyStructuresEnabled ¶
func IsCacheFriendlyStructuresEnabled() bool
IsCacheFriendlyStructuresEnabled returns true if cache-friendly structures are enabled
func IsCompactEnvironmentEnabled ¶
func IsCompactEnvironmentEnabled() bool
IsCompactEnvironmentEnabled returns true if CompactEnvironment optimization is enabled
func IsFunction ¶
IsFunction checks if a value is any kind of function
func IsMemoryLeakDetectionEnabled ¶
func IsMemoryLeakDetectionEnabled() bool
IsMemoryLeakDetectionEnabled returns true if memory leak detection is enabled
func IsTaggedValuesEnabled ¶
func IsTaggedValuesEnabled() bool
IsTaggedValuesEnabled returns true if TaggedValue optimization is enabled
func IsUserDefinedFunction ¶
IsUserDefinedFunction checks if a value is a user-defined function
func IsValidFileExtension ¶
IsValidFileExtension checks if a filename has the correct extension
func IsValidIdentifier ¶
IsValidIdentifier checks if a string is a valid identifier
func IsVariableLookupCacheEnabled ¶
func IsVariableLookupCacheEnabled() bool
IsVariableLookupCacheEnabled returns true if variable lookup cache is enabled
func OptimizedJoin ¶
OptimizedJoin provides efficient string joining for arrays
func OptimizedMakeMap ¶
OptimizedMakeMap creates a map with optimized initial capacity
func OptimizedMapCopy ¶
OptimizedMapCopy creates an optimized copy of a map
func OptimizedMapMerge ¶
OptimizedMapMerge provides efficient map merging
func OptimizedMemoKey ¶
OptimizedMemoKey generates an optimized memo key using hash
func OptimizedStringConcat ¶
OptimizedStringConcat performs optimized string concatenation
func OptimizedStringJoin ¶
OptimizedStringJoin provides efficient string joining with pre-allocation
func PrintStats ¶
PrintStats prints execution statistics in a readable format
func PutArenaToPool ¶
func PutArenaToPool(aa *ArenaAllocator)
PutArenaToPool returns an arena allocator to the global pool
func PutArrayConcatenator ¶
func PutArrayConcatenator(ac *ArrayConcatenator)
PutArrayConcatenator returns an array concatenator to the pool
func PutByteSlice ¶
func PutByteSlice(b []byte)
PutByteSlice returns a byte slice to the global pool
func PutExpressionArena ¶
func PutExpressionArena(ea *ExpressionArena)
PutExpressionArena returns an expression arena to the global pool
func PutMapBuilder ¶
func PutMapBuilder(mb *MapBuilder)
PutMapBuilder returns a map builder to the pool
func PutOptimizedStringBuilder ¶
PutOptimizedStringBuilder returns a string builder to the global pool
func PutPooledArray ¶
func PutPooledArray(arr []Value)
PutPooledArray returns an array to the appropriate pool
func PutPooledFloat ¶
func PutPooledFloat(v *float64)
PutPooledFloat returns a float64 pointer to the pool
func PutPooledStringBuilder ¶
PutPooledStringBuilder returns a string builder to the pool
func PutStringBuilder ¶
PutStringBuilder returns a string builder to the global pool
func PutStringConcatenator ¶
func PutStringConcatenator(sc *StringConcatenator)
PutStringConcatenator returns a string concatenator to the pool
func ResetGlobalMemoryLayoutConfig ¶
func ResetGlobalMemoryLayoutConfig()
ResetGlobalMemoryLayoutConfig resets the global memory layout configuration to default This function should be called in test cleanup to prevent test interference
func RunProgram ¶
RunProgram parses and executes the given program and returns the output. This is the main entry point for running code in the interpreter.
Parameters:
- inputSource: The source code to run as a string
Returns:
- bool: true if execution was successful, false if there was an error
- string: The program output or error message
func RunProgramWithOptions ¶
func RunProgramWithOptions(inputSource string, options *RunProgramOptions) (bool, string)
RunProgramWithOptions parses and executes the given program with custom options. This function allows you to control whether profiling information is displayed.
Parameters:
- inputSource: The source code to run as a string
- options: Options for controlling execution behavior
Returns:
- bool: true if execution was successful, false if there was an error
- string: The program output or error message
func SetGlobalMemoryLayoutConfig ¶
func SetGlobalMemoryLayoutConfig(config *MemoryLayoutConfig)
SetGlobalMemoryLayoutConfig sets the global memory layout configuration
func SmartAppendInterface ¶
SmartAppendInterface is a convenience function for any slices
func SmartAppendMapValue ¶
SmartAppendMapValue uses hybrid strategy for map[string]Value slices
func SmartAppendString ¶
SmartAppendString is a convenience function for string slices
func SyntaxAnalyze ¶
SyntaxAnalyze checks the syntax of the given input source without executing it. This function only validates the syntax correctness of the program.
Parameters:
- inputSource: The source code to analyze as a string
Returns:
- bool: true if syntax is correct, false otherwise
- string: A message describing the result (success message or error details)
func ValidateProgram ¶
ValidateProgram performs basic validation on a program before execution
Types ¶
type ASTNodePool ¶
type ASTNodePool struct {
// contains filtered or unexported fields
}
AST Node Pool for reducing allocation overhead
func GetGlobalASTNodePool ¶
func GetGlobalASTNodePool() *ASTNodePool
GetGlobalASTNodePool returns the global AST node pool
func (*ASTNodePool) GetBinary ¶
func (pool *ASTNodePool) GetBinary() *Binary
GetBinary gets a Binary node from the pool
func (*ASTNodePool) GetCall ¶
func (pool *ASTNodePool) GetCall() *Call
GetCall gets a Call node from the pool
func (*ASTNodePool) GetList ¶
func (pool *ASTNodePool) GetList() *List
GetList gets a List node from the pool
func (*ASTNodePool) GetLiteral ¶
func (pool *ASTNodePool) GetLiteral() *Literal
GetLiteral gets a Literal node from the pool
func (*ASTNodePool) GetMap ¶
func (pool *ASTNodePool) GetMap() *Map
GetMap gets a Map node from the pool
func (*ASTNodePool) GetSubscript ¶
func (pool *ASTNodePool) GetSubscript() *Subscript
GetSubscript gets a Subscript node from the pool
func (*ASTNodePool) GetUnary ¶
func (pool *ASTNodePool) GetUnary() *Unary
GetUnary gets a Unary node from the pool
func (*ASTNodePool) GetVariable ¶
func (pool *ASTNodePool) GetVariable() *Variable
GetVariable gets a Variable node from the pool
func (*ASTNodePool) PutBinary ¶
func (pool *ASTNodePool) PutBinary(node *Binary)
PutBinary returns a Binary node to the pool
func (*ASTNodePool) PutCall ¶
func (pool *ASTNodePool) PutCall(node *Call)
PutCall returns a Call node to the pool
func (*ASTNodePool) PutList ¶
func (pool *ASTNodePool) PutList(node *List)
PutList returns a List node to the pool
func (*ASTNodePool) PutLiteral ¶
func (pool *ASTNodePool) PutLiteral(node *Literal)
PutLiteral returns a Literal node to the pool
func (*ASTNodePool) PutMap ¶
func (pool *ASTNodePool) PutMap(node *Map)
PutMap returns a Map node to the pool
func (*ASTNodePool) PutSubscript ¶
func (pool *ASTNodePool) PutSubscript(node *Subscript)
PutSubscript returns a Subscript node to the pool
func (*ASTNodePool) PutUnary ¶
func (pool *ASTNodePool) PutUnary(node *Unary)
PutUnary returns a Unary node to the pool
func (*ASTNodePool) PutVariable ¶
func (pool *ASTNodePool) PutVariable(node *Variable)
PutVariable returns a Variable node to the pool
type AllocationInfo ¶
type AllocationInfo struct {
// contains filtered or unexported fields
}
AllocationInfo stores information about memory allocations
type ArenaAllocator ¶
type ArenaAllocator struct {
// contains filtered or unexported fields
}
ArenaAllocator provides memory arena allocation for AST nodes to reduce heap fragmentation
func GetArenaFromPool ¶
func GetArenaFromPool() *ArenaAllocator
GetArenaFromPool gets an arena allocator from the global pool
func GetGlobalArenaAllocator ¶
func GetGlobalArenaAllocator() *ArenaAllocator
GetGlobalArenaAllocator returns the global arena allocator
func NewArenaAllocator ¶
func NewArenaAllocator(blockSize int) *ArenaAllocator
NewArenaAllocator creates a new arena allocator
func (*ArenaAllocator) Allocate ¶
func (aa *ArenaAllocator) Allocate(size int) unsafe.Pointer
Allocate allocates memory from the arena
func (*ArenaAllocator) Reset ¶
func (aa *ArenaAllocator) Reset()
Reset resets the arena, making all allocated memory available for reuse
func (*ArenaAllocator) Size ¶
func (aa *ArenaAllocator) Size() int
Size returns the total allocated size
func (*ArenaAllocator) UsedSize ¶
func (aa *ArenaAllocator) UsedSize() int
UsedSize returns the total used size
type ArenaPool ¶
type ArenaPool struct {
// contains filtered or unexported fields
}
ArenaPool provides pooling of arena allocators for different contexts
func NewArenaPool ¶
NewArenaPool creates a new arena pool
func (*ArenaPool) Get ¶
func (ap *ArenaPool) Get() *ArenaAllocator
Get gets an arena allocator from the pool
func (*ArenaPool) Put ¶
func (ap *ArenaPool) Put(aa *ArenaAllocator)
Put returns an arena allocator to the pool
type ArenaSlice ¶
type ArenaSlice struct {
// contains filtered or unexported fields
}
ArenaSlice creates a slice using arena allocation
func NewArenaSlice ¶
func NewArenaSlice(capacity int, arena *ArenaAllocator) *ArenaSlice
NewArenaSlice creates a new arena-allocated slice
func (*ArenaSlice) Append ¶
func (as *ArenaSlice) Append(value Value)
Append appends a value to the arena slice
type ArenaStats ¶
ArenaStats provides statistics about arena usage
func GetArenaStats ¶
func GetArenaStats() ArenaStats
GetArenaStats returns statistics about the global arena allocator
type ArenaString ¶
type ArenaString struct {
// contains filtered or unexported fields
}
ArenaString creates a string using arena allocation
func NewArenaString ¶
func NewArenaString(s string, arena *ArenaAllocator) *ArenaString
NewArenaString creates a new arena-allocated string
type ArgumentValidationCache ¶
type ArgumentValidationCache struct {
// contains filtered or unexported fields
}
ArgumentValidationCache caches argument validation results
func GetGlobalArgumentValidationCache ¶
func GetGlobalArgumentValidationCache() *ArgumentValidationCache
GetGlobalArgumentValidationCache returns the global argument validation cache
func NewArgumentValidationCache ¶
func NewArgumentValidationCache(maxSize int) *ArgumentValidationCache
NewArgumentValidationCache creates a new argument validation cache
func (*ArgumentValidationCache) ValidateArguments ¶
func (avc *ArgumentValidationCache) ValidateArguments(funcName string, argTypes []string) bool
ValidateArguments checks if arguments are valid for a function
type ArrayConcatenator ¶
type ArrayConcatenator struct {
// contains filtered or unexported fields
}
ArrayConcatenator provides optimized array concatenation
func GetArrayConcatenator ¶
func GetArrayConcatenator() *ArrayConcatenator
GetArrayConcatenator gets an array concatenator from the pool
func NewArrayConcatenator ¶
func NewArrayConcatenator(estimatedSize int) *ArrayConcatenator
NewArrayConcatenator creates a new optimized array concatenator
func (*ArrayConcatenator) Append ¶
func (ac *ArrayConcatenator) Append(values ...Value)
Append adds values efficiently without repeated allocations
func (*ArrayConcatenator) AppendArray ¶
func (ac *ArrayConcatenator) AppendArray(arr *[]Value)
AppendArray adds an entire array efficiently
func (*ArrayConcatenator) Reset ¶
func (ac *ArrayConcatenator) Reset()
Reset clears the concatenator for reuse
func (*ArrayConcatenator) Result ¶
func (ac *ArrayConcatenator) Result() *[]Value
Result returns the final concatenated array
func (*ArrayConcatenator) ToArray ¶
func (ac *ArrayConcatenator) ToArray() []Value
ToArray returns the result as an array (alias for Result)
type Assign ¶
type Assign struct { Target Expression // Left-hand side of the assignment Value Expression // Right-hand side of the assignment Operator Token // Assignment operator (ASSIGN, PLUSEQUAL, etc.) // contains filtered or unexported fields }
Assign represents an assignment statement (target = value).
func NewAssign ¶
func NewAssign(pos Position, target Expression, value Expression, operator Token) *Assign
NewAssign creates a new assignment statement
func (*Assign) UnmarshalJSON ¶
String returns a string representation of the assignment. UnmarshalJSON implements custom JSON unmarshaling for Assign
type AsyncIOPool ¶
type AsyncIOPool struct {
// contains filtered or unexported fields
}
AsyncIOPool manages asynchronous I/O operations
func NewAsyncIOPool ¶
func NewAsyncIOPool(numWorkers, queueSize int) *AsyncIOPool
NewAsyncIOPool creates a new async I/O pool
func (*AsyncIOPool) Shutdown ¶
func (aio *AsyncIOPool) Shutdown()
Shutdown gracefully shuts down the async I/O pool
func (*AsyncIOPool) SubmitIOTask ¶
func (aio *AsyncIOPool) SubmitIOTask(task *IOTask) error
SubmitIOTask submits an I/O task to the async I/O pool
type AsyncIOWorker ¶
type AsyncIOWorker struct {
// contains filtered or unexported fields
}
AsyncIOWorker represents a worker for async I/O operations
type AsyncManager ¶
type AsyncManager struct { Operations map[string]*AsyncOperation Mutex sync.RWMutex WorkerPool chan struct{} // Semaphore for limiting concurrent operations }
type AsyncOperation ¶
type AsyncOperation struct { ID string Query string Args []Value Connection *DatabaseConnection Callback Value // Optional callback function StartTime time.Time Status string // "pending", "running", "completed", "failed" Result Value Error string Cancel context.CancelFunc Mutex sync.RWMutex }
Async Processing Implementation
type BatchArrayProcessor ¶
type BatchArrayProcessor struct {
// contains filtered or unexported fields
}
BatchArrayProcessor provides optimized batch processing for large arrays
func NewBatchArrayProcessor ¶
func NewBatchArrayProcessor(estimatedSize, batchSize int, processor func([]Value) []Value) *BatchArrayProcessor
NewBatchArrayProcessor creates a new batch processor
func (*BatchArrayProcessor) ProcessBatch ¶
func (bap *BatchArrayProcessor) ProcessBatch(input []Value) []Value
ProcessBatch processes array in batches to reduce memory pressure
type BatchOperation ¶
BatchOperation represents a single operation in a batch
type BatchResult ¶
BatchResult represents the result of a batch operation
type Binary ¶
type Binary struct { Left Expression // Left operand Operator Token // Operator token Right Expression // Right operand // contains filtered or unexported fields }
Binary represents a binary operation (left operator right).
func NewBinary ¶
func NewBinary(pos Position, left Expression, operator Token, right Expression) *Binary
NewBinary creates a new binary expression
func (*Binary) UnmarshalJSON ¶
String returns a string representation of the binary expression. UnmarshalJSON implements custom JSON unmarshaling for Binary
type BinlogStreamer ¶
type BinlogStreamer struct { Syncer *replication.BinlogSyncer Streamer *replication.BinlogStreamer Config replication.BinlogSyncerConfig Position mysql.Position Tables map[string]bool // Tables to monitor }
BinlogStreamer represents a MySQL binlog streamer for CDC
type Block ¶
type Block []Statement
Block represents a sequence of statements.
func FastSliceAppendBlock ¶
func SmartAppendBlock ¶
SmartAppendBlock uses hybrid strategy for Block (Statement slices)
func (*Block) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshaling for Block
type Break ¶
type Break struct {
// contains filtered or unexported fields
}
Break represents a break statement in loops.
func (*Break) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for Break
func (*Break) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshaling for Break
type BreakException ¶
type BreakException struct {
// contains filtered or unexported fields
}
BreakException is used to implement break control flow in loops. This is not an actual error but uses the exception mechanism to unwind the stack.
func (BreakException) Error ¶
func (e BreakException) Error() string
Error returns the formatted error message including position information.
func (BreakException) Position ¶
func (e BreakException) Position() Position
Position returns the position (line and column) where the break occurred.
type BuiltinFunctionDispatcher ¶
type BuiltinFunctionDispatcher struct {
// contains filtered or unexported fields
}
BuiltinFunctionDispatcher provides optimized dispatch for builtin functions
func GetGlobalBuiltinDispatcher ¶
func GetGlobalBuiltinDispatcher() *BuiltinFunctionDispatcher
GetGlobalBuiltinDispatcher returns the global builtin dispatcher
func NewBuiltinFunctionDispatcher ¶
func NewBuiltinFunctionDispatcher() *BuiltinFunctionDispatcher
NewBuiltinFunctionDispatcher creates a new builtin function dispatcher
func (*BuiltinFunctionDispatcher) DispatchBuiltinFunction ¶
func (bfd *BuiltinFunctionDispatcher) DispatchBuiltinFunction(name string, interp *interpreter, pos Position, args []Value) (Value, bool)
DispatchBuiltinFunction dispatches a builtin function call
func (*BuiltinFunctionDispatcher) GetCallCount ¶
func (bfd *BuiltinFunctionDispatcher) GetCallCount(name string) int64
GetCallCount returns the call count for a specific function
func (*BuiltinFunctionDispatcher) GetMostCalledFunctions ¶
func (bfd *BuiltinFunctionDispatcher) GetMostCalledFunctions(limit int) []string
GetMostCalledFunctions returns the most frequently called functions
func (*BuiltinFunctionDispatcher) RegisterBuiltinFunction ¶
func (bfd *BuiltinFunctionDispatcher) RegisterBuiltinFunction(name string, fn func(*interpreter, Position, []Value) Value, argCount int, fastPath bool)
RegisterBuiltinFunction registers a builtin function with the dispatcher
type BuiltinFunctionEntry ¶
type BuiltinFunctionEntry struct { Name string Function func(*interpreter, Position, []Value) Value ArgCount int // -1 for variadic FastPath bool }
BuiltinFunctionEntry represents a builtin function entry
type CacheFriendlyArray ¶
type CacheFriendlyArray struct {
// contains filtered or unexported fields
}
CacheFriendlyArray represents a cache-optimized array
func NewCacheFriendlyArray ¶
func NewCacheFriendlyArray(capacity int32) *CacheFriendlyArray
NewCacheFriendlyArray creates a new cache-friendly array
func (*CacheFriendlyArray) Append ¶
func (arr *CacheFriendlyArray) Append(value Value)
Append adds a value to the array
func (*CacheFriendlyArray) Get ¶
func (arr *CacheFriendlyArray) Get(index int32) (Value, bool)
Get retrieves a value at the given index
func (*CacheFriendlyArray) Set ¶
func (arr *CacheFriendlyArray) Set(index int32, value Value) bool
Set updates a value at the given index
func (*CacheFriendlyArray) Size ¶
func (arr *CacheFriendlyArray) Size() int32
Size returns the current size of the array
func (*CacheFriendlyArray) ToSlice ¶
func (arr *CacheFriendlyArray) ToSlice() []Value
ToSlice converts the array to a regular slice
type CacheFriendlyMap ¶
type CacheFriendlyMap struct {
// contains filtered or unexported fields
}
CacheFriendlyMap represents a cache-optimized map
func NewCacheFriendlyMap ¶
func NewCacheFriendlyMap(capacity int32) *CacheFriendlyMap
NewCacheFriendlyMap creates a new cache-friendly map
func (*CacheFriendlyMap) Delete ¶
func (m *CacheFriendlyMap) Delete(key string) bool
Delete removes a key-value pair
func (*CacheFriendlyMap) Get ¶
func (m *CacheFriendlyMap) Get(key string) (Value, bool)
Get retrieves a value by key
func (*CacheFriendlyMap) Set ¶
func (m *CacheFriendlyMap) Set(key string, value Value)
Set adds or updates a key-value pair
func (*CacheFriendlyMap) Size ¶
func (m *CacheFriendlyMap) Size() int32
Size returns the current size of the map
func (*CacheFriendlyMap) ToMap ¶
func (m *CacheFriendlyMap) ToMap() map[string]Value
ToMap converts to a regular map
type CachedVariable ¶
CachedVariable represents a cached variable with its scope level
type Call ¶
type Call struct { Function Expression // The function to call Arguments []Expression // Function arguments Ellipsis bool // Whether to unpack the last argument // contains filtered or unexported fields }
Call represents a function call expression.
func NewCall ¶
func NewCall(pos Position, function Expression, args []Expression) *Call
NewCall creates a new function call expression
func (*Call) UnmarshalJSON ¶
String returns a string representation of the function call. UnmarshalJSON implements custom JSON unmarshaling for Call
type CallFrame ¶
CallFrame represents a function call frame
func SmartAppendCallFrame ¶
SmartAppendCallFrame uses hybrid strategy for CallFrame slices
type CallStack ¶
type CallStack struct {
// contains filtered or unexported fields
}
CallStack provides optimized function call stack management
func (*CallStack) PopCall ¶
func (cs *CallStack) PopCall()
PopCall removes the top call from the stack (compatibility version)
type ChunkedArrayProcessor ¶
type ChunkedArrayProcessor struct {
// contains filtered or unexported fields
}
ChunkedArrayProcessor processes large arrays in chunks to reduce memory pressure
func NewChunkedArrayProcessor ¶
func NewChunkedArrayProcessor(chunkSize int) *ChunkedArrayProcessor
NewChunkedArrayProcessor creates a new chunked array processor
func (*ChunkedArrayProcessor) ProcessInChunks ¶
func (cap *ChunkedArrayProcessor) ProcessInChunks(arr []Value, processor func([]Value) []Value) []Value
ProcessInChunks processes a large array in chunks with a given processor function
type CommonSubexpressionEliminator ¶
type CommonSubexpressionEliminator struct {
// contains filtered or unexported fields
}
CommonSubexpressionEliminator eliminates common subexpressions
func NewCommonSubexpressionEliminator ¶
func NewCommonSubexpressionEliminator(optimizer *ExpressionOptimizer) *CommonSubexpressionEliminator
NewCommonSubexpressionEliminator creates a new CSE
func (*CommonSubexpressionEliminator) CacheSubexpression ¶
func (cse *CommonSubexpressionEliminator) CacheSubexpression(expr Expression, result Value)
CacheSubexpression caches a subexpression result
func (*CommonSubexpressionEliminator) EliminateCommonSubexpressions ¶
func (cse *CommonSubexpressionEliminator) EliminateCommonSubexpressions(expr Expression) (Value, bool)
EliminateCommonSubexpressions attempts to eliminate common subexpressions
type CompactEnvironment ¶
type CompactEnvironment struct {
// contains filtered or unexported fields
}
CompactEnvironment represents a memory-optimized environment for variable storage
func NewCompactEnvironment ¶
func NewCompactEnvironment() *CompactEnvironment
NewCompactEnvironment creates a new compact environment
func (*CompactEnvironment) Assign ¶
func (env *CompactEnvironment) Assign(name string, value Value)
Assign sets a variable in the current scope
func (*CompactEnvironment) GetScopeCount ¶
func (env *CompactEnvironment) GetScopeCount() int
GetScopeCount returns the number of scopes
func (*CompactEnvironment) Lookup ¶
func (env *CompactEnvironment) Lookup(name string) (Value, bool)
Lookup finds a variable in any scope (from current to global)
func (*CompactEnvironment) PopScope ¶
func (env *CompactEnvironment) PopScope()
PopScope removes the top scope from the environment
func (*CompactEnvironment) PushScope ¶
func (env *CompactEnvironment) PushScope()
PushScope adds a new scope to the environment
type ComplexOperationPool ¶
type ComplexOperationPool struct {
// contains filtered or unexported fields
}
ComplexOperationPool provides pooled resources for complex operations
func NewComplexOperationPool ¶
func NewComplexOperationPool() *ComplexOperationPool
NewComplexOperationPool creates a new complex operation pool
func (*ComplexOperationPool) GetArray ¶
func (cop *ComplexOperationPool) GetArray() []Value
GetArray gets a pooled array
func (*ComplexOperationPool) GetIntSlice ¶
func (cop *ComplexOperationPool) GetIntSlice() []int
GetIntSlice gets a pooled int slice
func (*ComplexOperationPool) GetLargeArray ¶
func (cop *ComplexOperationPool) GetLargeArray() []Value
GetLargeArray gets a pooled large array (capacity > 1024)
func (*ComplexOperationPool) GetMap ¶
func (cop *ComplexOperationPool) GetMap() map[string]Value
GetMap gets a pooled map
func (*ComplexOperationPool) GetSmallArray ¶
func (cop *ComplexOperationPool) GetSmallArray() []Value
GetSmallArray gets a pooled small array (capacity <= 16)
func (*ComplexOperationPool) GetStringBuilder ¶
func (cop *ComplexOperationPool) GetStringBuilder() *strings.Builder
GetStringBuilder gets a pooled string builder
func (*ComplexOperationPool) PutArray ¶
func (cop *ComplexOperationPool) PutArray(arr *[]Value)
PutArray returns an array to the pool
func (*ComplexOperationPool) PutIntSlice ¶
func (cop *ComplexOperationPool) PutIntSlice(slice *[]int)
PutIntSlice returns an int slice to the pool
func (*ComplexOperationPool) PutLargeArray ¶
func (cop *ComplexOperationPool) PutLargeArray(arr *[]Value)
PutLargeArray returns a large array to the pool
func (*ComplexOperationPool) PutMap ¶
func (cop *ComplexOperationPool) PutMap(m *map[string]Value)
PutMap returns a map to the pool
func (*ComplexOperationPool) PutSmallArray ¶
func (cop *ComplexOperationPool) PutSmallArray(arr *[]Value)
PutSmallArray returns a small array to the pool
func (*ComplexOperationPool) PutStringBuilder ¶
func (cop *ComplexOperationPool) PutStringBuilder(sb *strings.Builder)
PutStringBuilder returns a string builder to the pool
type ConcurrentExecutor ¶
type ConcurrentExecutor struct {
// contains filtered or unexported fields
}
ConcurrentExecutor provides concurrent execution capabilities
func GetGlobalConcurrentExecutor ¶
func GetGlobalConcurrentExecutor() *ConcurrentExecutor
GetGlobalConcurrentExecutor returns the global concurrent executor
func NewConcurrentExecutor ¶
func NewConcurrentExecutor(maxWorkers, maxQueueSize int) *ConcurrentExecutor
NewConcurrentExecutor creates a new concurrent executor
func (*ConcurrentExecutor) ExecuteIOTask ¶
func (ce *ConcurrentExecutor) ExecuteIOTask(ioFunc func() (Value, error)) (Value, error)
ExecuteIOTask executes an I/O task asynchronously
func (*ConcurrentExecutor) ExecuteTask ¶
func (ce *ConcurrentExecutor) ExecuteTask(taskFunc func() (Value, error), timeout time.Duration) (Value, error)
ExecuteTask executes a task using the concurrent executor
func (*ConcurrentExecutor) GetStats ¶
func (ce *ConcurrentExecutor) GetStats() ConcurrentStats
GetStats returns current concurrent execution statistics
func (*ConcurrentExecutor) ParallelFilterOperation ¶
func (ce *ConcurrentExecutor) ParallelFilterOperation(array []Value, filterFunc func(Value) bool) ([]Value, error)
ParallelFilterOperation performs a filter operation on an array in parallel
func (*ConcurrentExecutor) ParallelMapOperation ¶
func (ce *ConcurrentExecutor) ParallelMapOperation(array []Value, mapFunc func(Value) Value) ([]Value, error)
ParallelMapOperation performs a map operation on an array in parallel
func (*ConcurrentExecutor) ParallelReduceOperation ¶
func (ce *ConcurrentExecutor) ParallelReduceOperation(array []Value, reduceFunc func(Value, Value) Value, initialValue Value) (Value, error)
ParallelReduceOperation performs a reduce operation on an array in parallel
func (*ConcurrentExecutor) ResetStats ¶
func (ce *ConcurrentExecutor) ResetStats()
ResetStats resets all concurrent execution statistics
func (*ConcurrentExecutor) Shutdown ¶
func (ce *ConcurrentExecutor) Shutdown()
Shutdown gracefully shuts down the concurrent executor
type ConcurrentStats ¶
type ConcurrentStats struct { TasksExecuted int64 TasksQueued int64 TasksFailed int64 ParallelOpsCount int64 AsyncIOOpsCount int64 WorkerUtilization float64 }
ConcurrentStats tracks concurrent execution statistics
type Config ¶
type Config struct { // Vars is a map of pre-defined variables to pass into the interpreter. // These variables will be available to the interpreted code. Vars map[string]Value // Args is the list of command-line arguments for the interpreter's args() // builtin function. This simulates command-line arguments passed to a program. Args []string // Stdin is the interpreter's standard input, used by the read() builtin function. // If nil, it defaults to os.Stdin. Stdin io.Reader // Stdout is the interpreter's standard output, used by the print() builtin function. // If nil, it defaults to os.Stdout. Stdout io.Writer // Exit is a function to call when the exit() builtin is called. // If nil, it defaults to os.Exit. Exit func(int) // IsUnitTest menandakan bahwa interpreter sedang berjalan dalam konteks unit test // Jika true, fungsi main() tidak akan dijalankan secara otomatis IsUnitTest bool // DirectOutput controls whether print() writes directly to os.Stdout (true) or to configured Stdout (false) // When true, print() bypasses the configured Stdout and writes directly to os.Stdout // This is useful for CLI applications where you want immediate output without capturing DirectOutput bool // MemoryLayout configures memory layout optimizations // If nil, defaults to DefaultMemoryLayoutConfig() MemoryLayout *MemoryLayoutConfig // Memoization configures memoization behavior // If nil, defaults to DefaultMemoizationConfig() Memoization *MemoizationConfig }
Config allows you to configure the interpreter's interaction with the outside world. This provides a way to customize the environment in which the interpreted code runs.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a configuration with sensible defaults
func ExperimentalConfig ¶
func ExperimentalConfig() *Config
ExperimentalConfig returns a configuration with experimental memory layout optimizations enabled EXPERIMENTAL: This is experimental and may have stability issues WARNING: Not compatible with concurrent functions - use only for sequential processing NOTE: This configuration should not be used in production environments
func StableConfig ¶
func StableConfig() *Config
StableConfig returns a configuration with stable memory layout optimizations enabled These optimizations are production-ready and safe for concurrent use
func ValidateConfig ¶
ValidateConfig checks if a configuration is valid and sets defaults
type ConnectionPool ¶
type ConnectionPool struct { DB *sql.DB Config ConnectionPoolConfig DSN string Driver string Mutex sync.RWMutex }
ConnectionPool manages a pool of database connections
func NewConnectionPool ¶
func NewConnectionPool(driver, dsn string, config ConnectionPoolConfig) (*ConnectionPool, error)
NewConnectionPool creates a new connection pool
func (*ConnectionPool) Close ¶
func (cp *ConnectionPool) Close() error
Close closes the connection pool
func (*ConnectionPool) GetConnection ¶
func (cp *ConnectionPool) GetConnection() *sql.DB
GetConnection returns the underlying database connection
type ConnectionPoolConfig ¶
type ConnectionPoolConfig struct { MaxOpenConns int // Maximum number of open connections MaxIdleConns int // Maximum number of idle connections ConnMaxLifetime time.Duration // Maximum lifetime of a connection ConnMaxIdleTime time.Duration // Maximum idle time of a connection }
ConnectionPoolConfig holds configuration for database connection pool
type ConstantFolder ¶
type ConstantFolder struct {
// contains filtered or unexported fields
}
ConstantFolder performs constant folding optimization
func NewConstantFolder ¶
func NewConstantFolder(optimizer *ExpressionOptimizer) *ConstantFolder
NewConstantFolder creates a new constant folder
func (*ConstantFolder) FoldConstants ¶
func (cf *ConstantFolder) FoldConstants(expr Expression) (Value, bool)
FoldConstants attempts to fold constant expressions
type Continue ¶
type Continue struct {
// contains filtered or unexported fields
}
Continue represents a continue statement in loops.
func (*Continue) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for Continue
func (*Continue) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshaling for Continue
type ContinueException ¶
type ContinueException struct {
// contains filtered or unexported fields
}
ContinueException is used to implement continue control flow in loops. This is not an actual error but uses the exception mechanism to unwind the stack.
func (ContinueException) Error ¶
func (e ContinueException) Error() string
Error returns the formatted error message including position information.
func (ContinueException) Position ¶
func (e ContinueException) Position() Position
Position returns the position (line and column) where the continue occurred.
type DatabaseConnection ¶
type DatabaseConnection struct { ID string DB *sql.DB Driver string Host string Port int Database string Username string Password string }
DatabaseConnection represents a database connection object
type DatabaseStreamer ¶
type DatabaseStreamer struct { ID string DB *sql.DB Listener *pq.Listener Binlog *BinlogStreamer TableName string Callback Value // UDDIN-LANG function to call on data change Active bool Cancel context.CancelFunc Mutex sync.RWMutex Driver string LastID int64 BinlogPos string // For MySQL binary log position UseBinlog bool // Whether to use binlog streaming instead of polling ServerID uint32 // MySQL server ID for binlog replication TableColumns map[string][]string // Selected columns per table (empty means all columns) }
DatabaseStreamer represents a real-time database streamer using LISTEN/NOTIFY or Binlog
type EnhancedStringInterner ¶
type EnhancedStringInterner struct {
// contains filtered or unexported fields
}
EnhancedStringInterner provides advanced string interning with LRU eviction
func NewEnhancedStringInterner ¶
func NewEnhancedStringInterner(maxSize int) *EnhancedStringInterner
NewEnhancedStringInterner creates a new enhanced string interner
func (*EnhancedStringInterner) Clear ¶
func (esi *EnhancedStringInterner) Clear()
Clear clears the cache
func (*EnhancedStringInterner) Contains ¶
func (esi *EnhancedStringInterner) Contains(s string) bool
Contains checks if a string is already interned
func (*EnhancedStringInterner) Intern ¶
func (esi *EnhancedStringInterner) Intern(s string) string
Intern interns a string, returning the canonical instance
func (*EnhancedStringInterner) Size ¶
func (esi *EnhancedStringInterner) Size() int
Size returns the current cache size
func (*EnhancedStringInterner) Stats ¶
func (esi *EnhancedStringInterner) Stats() (hits, misses int64, hitRatio float64)
Stats returns cache statistics
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment manages the execution environment of the interpreter
func NewEnvironment ¶
func NewEnvironment(config *Config) *Environment
NewEnvironment creates a new execution environment
func (*Environment) Assign ¶
func (env *Environment) Assign(name string, value Value)
Assign sets a variable in the most local scope
func (*Environment) AssignOuter ¶
func (env *Environment) AssignOuter(name string, value Value)
AssignOuter sets a variable in the global scope
func (*Environment) GetArgs ¶
func (env *Environment) GetArgs() []string
GetArgs returns the command line arguments
func (*Environment) GetExit ¶
func (env *Environment) GetExit() func(int)
GetExit returns the exit function
func (*Environment) GetStdin ¶
func (env *Environment) GetStdin() io.Reader
GetStdin returns the input stream
func (*Environment) GetStdout ¶
func (env *Environment) GetStdout() io.Writer
GetStdout returns the output stream
func (*Environment) IsUnitTest ¶
func (env *Environment) IsUnitTest() bool
IsUnitTest returns whether we're in unit test mode
func (*Environment) Lookup ¶
func (env *Environment) Lookup(name string) (Value, bool)
Lookup retrieves a variable value, searching from local to global scope
func (*Environment) PopScope ¶
func (env *Environment) PopScope()
PopScope removes the most local variable scope
func (*Environment) PushScope ¶
func (env *Environment) PushScope()
PushScope creates a new variable scope
func (*Environment) ScopeCount ¶
func (env *Environment) ScopeCount() int
ScopeCount returns the number of active scopes
type Error ¶
Error is the error type returned by ParseExpression and ParseProgram when they encounter a syntax error. You can use this to get the location (line and column) of where the error occurred, as well as the error message.
type ErrorInterpreter ¶
ErrorInterpreter is the interface for all error types in the interpreter. It extends the standard error interface and adds a Position method to get the location where the error occurred in the source code.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator handles expression evaluation
func NewEvaluator ¶
func NewEvaluator(env *Environment, stats *Stats, interp *interpreter) *Evaluator
NewEvaluator creates a new expression evaluator
func (*Evaluator) EvaluateExpression ¶
func (e *Evaluator) EvaluateExpression(expr Expression) Value
Optimized EvaluateExpression with type-specific fast paths
type Expression ¶
type Expression interface { // Position returns the source code position of the expression. Position() Position // String returns a string representation of the expression. String() string }
Expression is an interface that all expression nodes in the AST must implement.
func AsExpression ¶
func AsExpression(node any) (Expression, bool)
AsExpression safely converts to Expression
func FastSliceAppendExpression ¶
func FastSliceAppendExpression(slice []Expression, items ...Expression) []Expression
func ParseExpression ¶
func ParseExpression(input []byte) (e Expression, err error)
ParseExpression parses a single expression into an Expression interface (can be one of many expression types). If the expression parses correctly, return an Expression and nil. If there's a syntax error, return nil and a parser.Error value.
func SmartAppendExpression ¶
func SmartAppendExpression(slice []Expression, elements ...Expression) []Expression
SmartAppendExpression uses hybrid strategy for Expression slices
type ExpressionArena ¶
type ExpressionArena struct {
// contains filtered or unexported fields
}
ExpressionArena provides arena allocation specifically for expression evaluation
func GetExpressionArena ¶
func GetExpressionArena() *ExpressionArena
GetExpressionArena gets an expression arena from the global pool
func NewExpressionArena ¶
func NewExpressionArena() *ExpressionArena
NewExpressionArena creates a new expression arena
func (*ExpressionArena) AddTempValue ¶
func (ea *ExpressionArena) AddTempValue(value Value)
AddTempValue adds a temporary value for cleanup
func (*ExpressionArena) AllocateSlice ¶
func (ea *ExpressionArena) AllocateSlice(capacity int) []Value
AllocateSlice allocates a slice in the arena
func (*ExpressionArena) AllocateString ¶
func (ea *ExpressionArena) AllocateString(s string) string
AllocateString allocates a string in the arena
func (*ExpressionArena) Release ¶
func (ea *ExpressionArena) Release()
Release releases the expression arena back to the pool
func (*ExpressionArena) Reset ¶
func (ea *ExpressionArena) Reset()
Reset resets the expression arena
type ExpressionArenaPool ¶
type ExpressionArenaPool struct {
// contains filtered or unexported fields
}
ExpressionArenaPool provides pooling for expression arenas
func NewExpressionArenaPool ¶
func NewExpressionArenaPool() *ExpressionArenaPool
NewExpressionArenaPool creates a new expression arena pool
func (*ExpressionArenaPool) Get ¶
func (eap *ExpressionArenaPool) Get() *ExpressionArena
Get gets an expression arena from the pool
func (*ExpressionArenaPool) Put ¶
func (eap *ExpressionArenaPool) Put(ea *ExpressionArena)
Put returns an expression arena to the pool
type ExpressionOptimizer ¶
type ExpressionOptimizer struct {
// contains filtered or unexported fields
}
ExpressionOptimizer provides optimization for expressions EXPERIMENTAL: This optimizer is experimental and part of memory optimization features WARNING: Caching behavior may not be suitable for all use cases
func GetGlobalExpressionOptimizer ¶
func GetGlobalExpressionOptimizer() *ExpressionOptimizer
GetGlobalExpressionOptimizer returns the global expression optimizer
func NewExpressionOptimizer ¶
func NewExpressionOptimizer(maxCacheSize int) *ExpressionOptimizer
NewExpressionOptimizer creates a new expression optimizer
func (*ExpressionOptimizer) ClearCaches ¶
func (eo *ExpressionOptimizer) ClearCaches()
ClearCaches clears all optimization caches
func (*ExpressionOptimizer) GetOptimizationStats ¶
func (eo *ExpressionOptimizer) GetOptimizationStats() (hits, misses int64, hitRatio float64)
GetOptimizationStats returns optimization statistics
type ExpressionStatement ¶
type ExpressionStatement struct { Expression Expression // The expression // contains filtered or unexported fields }
ExpressionStatement represents a statement that consists of just an expression.
func (*ExpressionStatement) Position ¶
func (s *ExpressionStatement) Position() Position
func (*ExpressionStatement) String ¶
func (s *ExpressionStatement) String() string
func (*ExpressionStatement) UnmarshalJSON ¶
func (s *ExpressionStatement) UnmarshalJSON(data []byte) error
String returns a string representation of the expression statement. UnmarshalJSON implements custom JSON unmarshaling for ExpressionStatement
type FastNumericEvaluator ¶
type FastNumericEvaluator struct {
// contains filtered or unexported fields
}
FastNumericEvaluator provides specialized evaluation for numeric operations to reduce any boxing/unboxing and heap allocations
func GetFastEvaluator ¶
func GetFastEvaluator() *FastNumericEvaluator
GetFastEvaluator returns the global fast evaluator instance
func NewFastNumericEvaluator ¶
func NewFastNumericEvaluator() *FastNumericEvaluator
NewFastNumericEvaluator creates a new fast numeric evaluator
func (*FastNumericEvaluator) FastEvalDivide ¶
func (fne *FastNumericEvaluator) FastEvalDivide(l, r Value) (Value, bool)
FastEvalDivide provides optimized division
func (*FastNumericEvaluator) FastEvalEqual ¶
func (fne *FastNumericEvaluator) FastEvalEqual(l, r Value) (Value, bool)
FastEvalEqual provides optimized equality comparison
func (*FastNumericEvaluator) FastEvalLess ¶
func (fne *FastNumericEvaluator) FastEvalLess(l, r Value) (Value, bool)
FastEvalLess provides optimized less-than comparison
func (*FastNumericEvaluator) FastEvalMinus ¶
func (fne *FastNumericEvaluator) FastEvalMinus(l, r Value) (Value, bool)
FastEvalMinus provides optimized subtraction
func (*FastNumericEvaluator) FastEvalModulo ¶
func (fne *FastNumericEvaluator) FastEvalModulo(l, r Value) (Value, bool)
FastEvalModulo provides optimized modulo operation for numeric types
func (*FastNumericEvaluator) FastEvalPlus ¶
func (fne *FastNumericEvaluator) FastEvalPlus(l, r Value) (Value, bool)
FastEvalPlus provides optimized addition without any boxing for common cases
func (*FastNumericEvaluator) FastEvalPower ¶
func (fne *FastNumericEvaluator) FastEvalPower(l, r Value) (Value, bool)
FastEvalPower provides optimized power operation for numeric types
func (*FastNumericEvaluator) FastEvalTimes ¶
func (fne *FastNumericEvaluator) FastEvalTimes(l, r Value) (Value, bool)
FastEvalTimes provides optimized multiplication
type FastSlice ¶
type FastSlice struct {
// contains filtered or unexported fields
}
FastSlice provides optimized append operations with pre-allocation and pooling
func NewFastSlice ¶
NewFastSlice creates a new FastSlice with initial capacity
func (*FastSlice) FastAppend ¶
FastAppend appends elements with optimized memory allocation
type FastTypeAssertion ¶
type FastTypeAssertion struct {
// contains filtered or unexported fields
}
FastTypeAssertion provides optimized type assertions with caching
func (*FastTypeAssertion) GetTypeName ¶
func (fta *FastTypeAssertion) GetTypeName(v any) string
GetTypeName returns the cached type name
type For ¶
type For struct { Name string // Loop variable name Iterable Expression // The collection to iterate over Body Block // The block to execute for each item // contains filtered or unexported fields }
For represents a for-in loop statement.
func (*For) UnmarshalJSON ¶
String returns a string representation of the for statement. UnmarshalJSON implements custom JSON unmarshaling for For
type FunctionCallCache ¶
type FunctionCallCache struct {
// contains filtered or unexported fields
}
FunctionCallCache provides caching for pure function calls
func NewFunctionCallCache ¶
func NewFunctionCallCache(maxSize int) *FunctionCallCache
NewFunctionCallCache creates a new function call cache
func (*FunctionCallCache) Get ¶
func (fcc *FunctionCallCache) Get(key string) (Value, bool)
Get retrieves a cached function result
func (*FunctionCallCache) Set ¶
func (fcc *FunctionCallCache) Set(key string, value Value)
Set stores a function result in cache
type FunctionDefinition ¶
type FunctionDefinition struct { Name string // Function name Parameters []string // Parameter names Ellipsis bool // Whether the function accepts variable arguments Body Block // Function body // EXPERIMENTAL: Whether the function should use memoization (experimental feature) // WARNING: May consume significant memory and is not thread-safe Memoized bool // contains filtered or unexported fields }
FunctionDefinition represents a function declaration statement. EXPERIMENTAL: Memoization feature is experimental and not recommended for production
func (*FunctionDefinition) Position ¶
func (s *FunctionDefinition) Position() Position
func (*FunctionDefinition) String ¶
func (s *FunctionDefinition) String() string
String returns a string representation of the function definition.
type FunctionExpression ¶
type FunctionExpression struct { Parameters []string // Parameter names Ellipsis bool // Whether the function accepts variable arguments Body Block // Function body // contains filtered or unexported fields }
FunctionExpression represents an anonymous function expression.
func (*FunctionExpression) Position ¶
func (e *FunctionExpression) Position() Position
func (*FunctionExpression) String ¶
func (e *FunctionExpression) String() string
String returns a string representation of the function expression.
type GlobalVariableCache ¶
type GlobalVariableCache struct {
// contains filtered or unexported fields
}
GlobalVariableCache provides fast access to frequently used global variables EXPERIMENTAL: This cache is experimental and part of memory optimization
func GetGlobalVariableCache ¶
func GetGlobalVariableCache() *GlobalVariableCache
GetGlobalVariableCache returns the global variable cache instance
func NewGlobalVariableCache ¶
func NewGlobalVariableCache() *GlobalVariableCache
NewGlobalVariableCache creates a new global variable cache
func (*GlobalVariableCache) GetGlobalVariable ¶
func (gvc *GlobalVariableCache) GetGlobalVariable(name string) (Value, bool)
GetGlobalVariable retrieves a global variable from cache
func (*GlobalVariableCache) InvalidateGlobalVariable ¶
func (gvc *GlobalVariableCache) InvalidateGlobalVariable(name string)
InvalidateGlobalVariable removes a global variable from cache
func (*GlobalVariableCache) SetGlobalVariable ¶
func (gvc *GlobalVariableCache) SetGlobalVariable(name string, value Value)
SetGlobalVariable caches a global variable
type HybridAppendStrategy ¶
type HybridAppendStrategy struct {
// contains filtered or unexported fields
}
HybridAppendStrategy implements a smart append strategy that chooses between built-in append and FastSliceAppend based on data size
func NewHybridAppendStrategy ¶
func NewHybridAppendStrategy(threshold int) *HybridAppendStrategy
NewHybridAppendStrategy creates a new hybrid append strategy with the specified threshold (default: 1000)
func (*HybridAppendStrategy) AppendInterface ¶
func (h *HybridAppendStrategy) AppendInterface(slice []any, values ...any) []any
AppendInterface appends any values using the optimal strategy
func (*HybridAppendStrategy) AppendStrings ¶
func (h *HybridAppendStrategy) AppendStrings(slice []string, values ...string) []string
AppendStrings appends strings to a slice using the optimal strategy
func (*HybridAppendStrategy) AppendValues ¶
func (h *HybridAppendStrategy) AppendValues(slice []Value, values ...Value) []Value
AppendValues appends values to a slice using the optimal strategy
type IOTask ¶
type IOTask struct { ID string Function func() (Value, error) Result chan TaskResult Context context.Context }
IOTask represents an I/O task
type If ¶
type If struct { Condition Expression // The condition to evaluate Body Block // The block to execute if condition is true Else Block // The block to execute if condition is false (optional) // contains filtered or unexported fields }
If represents an if-else conditional statement.
func NewIf ¶
func NewIf(pos Position, condition Expression, body Block, elseBlock Block) *If
NewIf creates a new if statement
func (*If) UnmarshalJSON ¶
String returns a string representation of the if statement. UnmarshalJSON implements custom JSON unmarshaling for If
type Import ¶
type Import struct { Filename string // The filename to import (as a string literal) // contains filtered or unexported fields }
Import represents an import statement for importing .din files.
type List ¶
type List struct { Values []Expression // List elements // contains filtered or unexported fields }
List represents a list literal [value1, value2, ...].
func (*List) UnmarshalJSON ¶
String returns a string representation of the list. UnmarshalJSON implements custom JSON unmarshaling for List
type Literal ¶
type Literal struct { Value any // The literal value // contains filtered or unexported fields }
Literal represents a literal value (number, string, boolean, nil).
func NewLiteral ¶
NewLiteral creates a new literal expression
type Map ¶
type Map struct { Items []MapItem // Map entries // contains filtered or unexported fields }
Map represents a map literal {key1: value1, key2: value2, ...}.
func (*Map) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshaling for Map
type MapBuilder ¶
type MapBuilder struct {
// contains filtered or unexported fields
}
MapBuilder provides optimized map creation with pre-allocation
func GetMapBuilder ¶
func GetMapBuilder() *MapBuilder
GetMapBuilder gets a map builder from the pool
func NewMapBuilder ¶
func NewMapBuilder(estimatedSize int) *MapBuilder
NewMapBuilder creates a new optimized map builder
func (*MapBuilder) Release ¶
func (mb *MapBuilder) Release()
Release returns the map to the pool for reuse
func (*MapBuilder) Result ¶
func (mb *MapBuilder) Result() map[string]Value
Result returns the final map and releases it to the pool when done
func (*MapBuilder) Set ¶
func (mb *MapBuilder) Set(key string, value Value)
Set adds a key-value pair efficiently
func (*MapBuilder) SetAll ¶
func (mb *MapBuilder) SetAll(source map[string]Value)
SetAll adds multiple key-value pairs from another map
func (*MapBuilder) ToMap ¶
func (mb *MapBuilder) ToMap() map[string]Value
ToMap returns the result as a map (alias for Result)
type MapItem ¶
type MapItem struct { Key Expression // Map key Value Expression // Map value }
MapItem represents a key-value pair in a map literal.
func FastSliceAppendMapItem ¶
func SmartAppendMapItem ¶
SmartAppendMapItem uses hybrid strategy for MapItem slices
func (*MapItem) UnmarshalJSON ¶
String returns a string representation of the map. UnmarshalJSON implements custom JSON unmarshaling for MapItem
type MemoizationConfig ¶
type MemoizationConfig struct { // EnableMemoization enables or disables memoization globally EnableMemoization bool // CacheSize is the maximum number of entries in the memoization cache CacheSize int // TTL is the time-to-live for cache entries (0 means no expiration) TTL time.Duration // UseProductionCache determines whether to use ProductionMemoCache (true) or OptimizedMemoCache (false) UseProductionCache bool // CleanupInterval is the interval for cleaning up expired cache entries CleanupInterval time.Duration }
MemoizationConfig configures memoization behavior
func DefaultMemoizationConfig ¶
func DefaultMemoizationConfig() *MemoizationConfig
DefaultMemoizationConfig returns default memoization configuration
func ExperimentalMemoizationConfig ¶
func ExperimentalMemoizationConfig() *MemoizationConfig
ExperimentalMemoizationConfig returns experimental memoization configuration
func StableMemoizationConfig ¶
func StableMemoizationConfig() *MemoizationConfig
StableMemoizationConfig returns stable memoization configuration for production
type MemoryError ¶
type MemoryError struct {
// contains filtered or unexported fields
}
MemoryError represents memory-related errors
func (*MemoryError) Error ¶
func (e *MemoryError) Error() string
type MemoryLayoutConfig ¶
type MemoryLayoutConfig struct { // EnableTaggedValues enables the use of TaggedValue instead of Value EnableTaggedValues bool // EnableCompactEnvironment enables the use of CompactEnvironment instead of regular Environment EnableCompactEnvironment bool // EnableCacheFriendlyStructures enables the use of CacheFriendlyArray and CacheFriendlyMap EnableCacheFriendlyStructures bool // EnableVariableLookupCache enables variable lookup caching for performance EnableVariableLookupCache bool // EnableMemoryLeakDetection enables automatic memory leak detection EnableMemoryLeakDetection bool // MemoryLeakDetectionInterval sets the interval (in seconds) for periodic memory leak detection MemoryLeakDetectionInterval int // AutoCleanupMemoryLeaks enables automatic cleanup of detected memory leaks AutoCleanupMemoryLeaks bool // TaggedValuePoolSize sets the initial size of the TaggedValue pool TaggedValuePoolSize int // MaxStringCacheSize sets the maximum number of strings to cache globally MaxStringCacheSize int // VariableLookupCacheSize sets the maximum size of the variable lookup cache VariableLookupCacheSize int }
MemoryLayoutConfig controls the memory layout optimization features EXPERIMENTAL: This configuration is experimental and may have stability issues
func DefaultMemoryLayoutConfig ¶
func DefaultMemoryLayoutConfig() *MemoryLayoutConfig
DefaultMemoryLayoutConfig returns the default memory layout configuration By default, memory layout optimizations are disabled for backward compatibility
func ExperimentalMemoryLayoutConfig ¶
func ExperimentalMemoryLayoutConfig() *MemoryLayoutConfig
ExperimentalMemoryLayoutConfig returns a configuration with all memory layout optimizations enabled EXPERIMENTAL: This is for testing and experimental use only - not recommended for production WARNING: Not compatible with concurrent functions and may cause thread safety issues
func GetGlobalMemoryLayoutConfig ¶
func GetGlobalMemoryLayoutConfig() *MemoryLayoutConfig
GetGlobalMemoryLayoutConfig returns the global memory layout configuration
func StableMemoryLayoutConfig ¶
func StableMemoryLayoutConfig() *MemoryLayoutConfig
StableMemoryLayoutConfig returns a configuration with stable memory layout optimizations enabled These optimizations are production-ready and thread-safe
type MemoryLayoutOptimizer ¶
type MemoryLayoutOptimizer struct {
// contains filtered or unexported fields
}
MemoryLayoutOptimizer manages memory layout optimizations
func NewMemoryLayoutOptimizer ¶
func NewMemoryLayoutOptimizer() *MemoryLayoutOptimizer
NewMemoryLayoutOptimizer creates a new memory layout optimizer
func (*MemoryLayoutOptimizer) GetMemoryStats ¶
func (opt *MemoryLayoutOptimizer) GetMemoryStats() MemoryStats
GetMemoryStats returns a copy of the current memory statistics
func (*MemoryLayoutOptimizer) IncrementCacheHits ¶
func (opt *MemoryLayoutOptimizer) IncrementCacheHits()
IncrementCacheHits increments the cache hits counter
func (*MemoryLayoutOptimizer) IncrementCacheMisses ¶
func (opt *MemoryLayoutOptimizer) IncrementCacheMisses()
IncrementCacheMisses increments the cache misses counter
func (*MemoryLayoutOptimizer) IncrementTaggedValuesCreated ¶
func (opt *MemoryLayoutOptimizer) IncrementTaggedValuesCreated()
IncrementTaggedValuesCreated increments the tagged values created counter
func (*MemoryLayoutOptimizer) IncrementTaggedValuesReused ¶
func (opt *MemoryLayoutOptimizer) IncrementTaggedValuesReused()
IncrementTaggedValuesReused increments the tagged values reused counter
func (*MemoryLayoutOptimizer) ResetStats ¶
func (opt *MemoryLayoutOptimizer) ResetStats()
ResetStats resets all statistics to zero
type MemoryStats ¶
type MemoryStats struct { TaggedValuesCreated int64 TaggedValuesReused int64 CacheHits int64 CacheMisses int64 }
MemoryStats represents memory usage statistics
type MemoryTracker ¶
type MemoryTracker struct {
// contains filtered or unexported fields
}
MemoryTracker tracks allocated memory for leak detection
func GetGlobalMemoryTracker ¶
func GetGlobalMemoryTracker() *MemoryTracker
GetGlobalMemoryTracker returns the global memory tracker
func (*MemoryTracker) GetMemoryStats ¶
func (mt *MemoryTracker) GetMemoryStats() MemoryStats
GetMemoryStats returns current memory statistics
type NameError ¶
type NameError struct { Message string // contains filtered or unexported fields }
NameError is returned when a variable or function name is not found in the current scope. This error occurs when trying to access a variable that hasn't been defined.
type OptimizedMemoCache ¶
type OptimizedMemoCache struct {
// contains filtered or unexported fields
}
OptimizedMemoCache provides hash-based memoization to reduce string allocation overhead EXPERIMENTAL: This memoization cache is experimental and part of memory optimization WARNING: May consume significant memory and not suitable for all function types
func GetGlobalOptimizedMemoCache ¶
func GetGlobalOptimizedMemoCache() *OptimizedMemoCache
GetGlobalOptimizedMemoCache returns the global optimized memo cache
func NewOptimizedMemoCache ¶
func NewOptimizedMemoCache(maxSize int) *OptimizedMemoCache
NewOptimizedMemoCache creates a new optimized memo cache
func (*OptimizedMemoCache) Get ¶
func (omc *OptimizedMemoCache) Get(key uint64) (Value, bool)
Get retrieves a cached value by hash key
func (*OptimizedMemoCache) Set ¶
func (omc *OptimizedMemoCache) Set(key uint64, value Value)
Set stores a value with hash key
func (*OptimizedMemoCache) Size ¶
func (omc *OptimizedMemoCache) Size() int
Size returns the current cache size
type OuterAssign ¶
type OuterAssign struct { Name string // Name of the variable Value Expression // Value to assign // contains filtered or unexported fields }
OuterAssign represents an assignment to an outer scope variable.
func (*OuterAssign) Position ¶
func (s *OuterAssign) Position() Position
func (*OuterAssign) String ¶
func (s *OuterAssign) String() string
String returns a string representation of the outer assignment.
type ParallelArrayProcessor ¶
type ParallelArrayProcessor struct {
// contains filtered or unexported fields
}
ParallelArrayProcessor processes arrays in parallel
func NewParallelArrayProcessor ¶
func NewParallelArrayProcessor(executor *ConcurrentExecutor, chunkSize, maxParallel int) *ParallelArrayProcessor
NewParallelArrayProcessor creates a new parallel array processor
func (*ParallelArrayProcessor) ProcessArray ¶
func (pap *ParallelArrayProcessor) ProcessArray(array []Value, processor func(Value) Value) ([]Value, error)
ProcessArray processes an array in parallel using the given function
type PerformanceMonitor ¶
type PerformanceMonitor struct {
// contains filtered or unexported fields
}
PerformanceMonitor tracks operation performance
func (*PerformanceMonitor) GetAllCounts ¶
func (pm *PerformanceMonitor) GetAllCounts() map[string]int64
GetAllCounts returns all operation counts
func (*PerformanceMonitor) GetOperationCount ¶
func (pm *PerformanceMonitor) GetOperationCount(operation string) int64
GetOperationCount returns the count for an operation
func (*PerformanceMonitor) IncrementOperation ¶
func (pm *PerformanceMonitor) IncrementOperation(operation string)
IncrementOperation increments the count for an operation
type PooledStringBuilder ¶
type PooledStringBuilder struct {
// contains filtered or unexported fields
}
PooledStringBuilder provides a pooled string builder for temporary string operations
func NewPooledStringBuilder ¶
func NewPooledStringBuilder() *PooledStringBuilder
NewPooledStringBuilder creates a new pooled string builder
func (*PooledStringBuilder) Get ¶
func (psb *PooledStringBuilder) Get() *strings.Builder
Get gets a string builder from the pool
func (*PooledStringBuilder) Put ¶
func (psb *PooledStringBuilder) Put(sb *strings.Builder)
Put returns a string builder to the pool
type Position ¶
Position stores the line and column where a token starts in the source code This is used for error reporting and debugging purposes
type ProductionMemoCache ¶
type ProductionMemoCache struct {
// contains filtered or unexported fields
}
ProductionMemoCache provides a production-ready memoization cache with LRU eviction and TTL support
func GetGlobalProductionMemoCache ¶
func GetGlobalProductionMemoCache() *ProductionMemoCache
GetGlobalProductionMemoCache returns the global production memo cache
func NewProductionMemoCache ¶
func NewProductionMemoCache(maxSize int, ttl time.Duration) *ProductionMemoCache
NewProductionMemoCache creates a new production-ready memo cache
func (*ProductionMemoCache) CleanupExpired ¶
func (pmc *ProductionMemoCache) CleanupExpired() int
CleanupExpired removes all expired entries from the cache
func (*ProductionMemoCache) Clear ¶
func (pmc *ProductionMemoCache) Clear()
Clear clears all entries from the cache
func (*ProductionMemoCache) Get ¶
func (pmc *ProductionMemoCache) Get(key uint64) (Value, bool)
Get retrieves a value from the cache with TTL check
func (*ProductionMemoCache) IsEnabled ¶
func (pmc *ProductionMemoCache) IsEnabled() bool
IsEnabled returns whether the cache is enabled
func (*ProductionMemoCache) Set ¶
func (pmc *ProductionMemoCache) Set(key uint64, value Value)
Set stores a value in the cache with proper LRU eviction
func (*ProductionMemoCache) SetEnabled ¶
func (pmc *ProductionMemoCache) SetEnabled(enabled bool)
SetEnabled enables or disables the cache
func (*ProductionMemoCache) Size ¶
func (pmc *ProductionMemoCache) Size() int
Size returns the current number of entries in the cache
type Program ¶
type Program struct {
Statements Block
}
Program represents the root node of the abstract syntax tree (AST). It contains a block of statements that make up the program.
func ParseProgram ¶
ParseProgram parses an entire program and returns a *Program (which is basically a list of statements). If the program parses correctly, return a *Program and nil. If there's a syntax error, return nil and a parser.Error value.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implementation using slice
type Return ¶
type Return struct { Result Expression // The value to return // contains filtered or unexported fields }
Return represents a return statement.
func (*Return) UnmarshalJSON ¶
String returns a string representation of the return statement. UnmarshalJSON implements custom JSON unmarshaling for Return
type RunProgramOptions ¶
type RunProgramOptions struct { ShowProfiling bool // Whether to show execution profiling information // Whether to enable stable memory layout optimizations (production-ready) MemoryOptimizeStable bool // EXPERIMENTAL: Whether to enable experimental memory layout optimizations // WARNING: Not recommended for production use, may have stability issues MemoryOptimizeExperimental bool // DEPRECATED: Use MemoryOptimizeStable or MemoryOptimizeExperimental instead // This field is kept for backward compatibility and maps to MemoryOptimizeExperimental MemoryOptimize bool // DirectOutput controls whether output goes directly to stdout (true) or is captured and returned (false) // When true, print() writes directly to os.Stdout and the returned output string will be empty // When false (default), print() output is captured and returned in the output string DirectOutput bool }
RunProgramOptions defines options for running a program
type RuntimeError ¶
type RuntimeError struct { Message string // contains filtered or unexported fields }
RuntimeError is returned for other or internal runtime errors that don't fit into the other error categories. This is a general-purpose error type for the interpreter.
func (RuntimeError) Error ¶
func (e RuntimeError) Error() string
Error returns the formatted error message including position information.
func (RuntimeError) Position ¶
func (e RuntimeError) Position() Position
Position returns the position (line and column) where the error occurred in the source.
type SafeTaggedValue ¶
type SafeTaggedValue struct { Type TaggedValueType Data uintptr // Pointer to actual data or small value storage // contains filtered or unexported fields }
SafeTaggedValue represents a thread-safe version of TaggedValue Production-ready implementation with comprehensive safety checks and memory management
func CreateSafeTaggedValue ¶
func CreateSafeTaggedValue(value Value) (*SafeTaggedValue, error)
CreateSafeTaggedValue creates a thread-safe tagged value with proper error handling
func CreateTaggedValue ¶
func CreateTaggedValue(value Value) *SafeTaggedValue
CreateTaggedValue creates a tagged value (compatibility wrapper)
func (*SafeTaggedValue) IsSmallValue ¶
func (tv *SafeTaggedValue) IsSmallValue() bool
IsSmallValue checks if the tagged value stores a small value directly (compatibility method)
func (*SafeTaggedValue) ToValue ¶
func (tv *SafeTaggedValue) ToValue() (Value, error)
ToValue converts a SafeTaggedValue back to a regular value with safety checks
func (*SafeTaggedValue) ToValueCompat ¶
func (tv *SafeTaggedValue) ToValueCompat() Value
Compatibility wrapper for ToValue that returns single value
type SafeTaggedValuePool ¶
type SafeTaggedValuePool struct {
// contains filtered or unexported fields
}
SafeTaggedValuePool manages a pool of SafeTaggedValue instances with full thread safety Production-ready pool implementation with statistics and capacity management
func GetGlobalSafeTaggedValuePool ¶
func GetGlobalSafeTaggedValuePool() *SafeTaggedValuePool
GetGlobalSafeTaggedValuePool returns the global safe tagged value pool
func GetGlobalTaggedValuePool ¶
func GetGlobalTaggedValuePool() *SafeTaggedValuePool
GetGlobalTaggedValuePool returns the global tagged value pool (compatibility wrapper)
func NewSafeTaggedValuePool ¶
func NewSafeTaggedValuePool(maxSize int32) *SafeTaggedValuePool
NewSafeTaggedValuePool creates a new thread-safe tagged value pool
func NewTaggedValuePool ¶
func NewTaggedValuePool() *SafeTaggedValuePool
Compatibility functions for existing tests NewTaggedValuePool creates a new tagged value pool (compatibility wrapper)
func (*SafeTaggedValuePool) GetSafeTaggedValue ¶
func (stvp *SafeTaggedValuePool) GetSafeTaggedValue() (*SafeTaggedValue, error)
GetSafeTaggedValue gets a SafeTaggedValue from the pool with proper error handling
func (*SafeTaggedValuePool) GetStats ¶
func (stvp *SafeTaggedValuePool) GetStats() PoolStats
GetStats returns thread-safe statistics for the pool
func (*SafeTaggedValuePool) GetTaggedValue ¶
func (stvp *SafeTaggedValuePool) GetTaggedValue() *SafeTaggedValue
GetTaggedValue gets a tagged value from the pool (compatibility wrapper)
func (*SafeTaggedValuePool) IsAtCapacity ¶
func (stvp *SafeTaggedValuePool) IsAtCapacity() bool
IsAtCapacity checks if the pool is at maximum capacity
func (*SafeTaggedValuePool) PutSafeTaggedValue ¶
func (stvp *SafeTaggedValuePool) PutSafeTaggedValue(tv *SafeTaggedValue) error
PutSafeTaggedValue returns a SafeTaggedValue to the pool with proper cleanup
func (*SafeTaggedValuePool) PutTaggedValue ¶
func (stvp *SafeTaggedValuePool) PutTaggedValue(tv *SafeTaggedValue)
PutTaggedValue returns a tagged value to the pool (compatibility wrapper)
type ScopeFlattener ¶
type ScopeFlattener struct {
// contains filtered or unexported fields
}
ScopeFlattener optimizes deep scope lookups by flattening variable access EXPERIMENTAL: This flattener is experimental and part of memory optimization
func NewScopeFlattener ¶
func NewScopeFlattener(maxDepth int) *ScopeFlattener
NewScopeFlattener creates a new scope flattener
func (*ScopeFlattener) FlattenScope ¶
func (sf *ScopeFlattener) FlattenScope(env *Environment) map[string]Value
FlattenScope creates a flattened view of variables for deep scopes
func (*ScopeFlattener) LookupFlattened ¶
func (sf *ScopeFlattener) LookupFlattened(name string) (Value, bool)
LookupFlattened performs lookup in flattened scope
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set implementation using map[string]Value for uniqueness
type SmartStringInterner ¶
type SmartStringInterner struct {
// contains filtered or unexported fields
}
SmartStringInterner provides context-aware string interning
func NewSmartStringInterner ¶
func NewSmartStringInterner() *SmartStringInterner
NewSmartStringInterner creates a new smart string interner
func (*SmartStringInterner) InternByType ¶
func (ssi *SmartStringInterner) InternByType(s string, stringType StringType) string
InternByType interns a string based on its type
func (*SmartStringInterner) Stats ¶
func (ssi *SmartStringInterner) Stats() map[string]any
Stats returns combined statistics
type SpecializedBuiltinFunctions ¶
type SpecializedBuiltinFunctions struct{}
SpecializedBuiltinFunctions provides fast implementations for commonly used functions
func GetGlobalSpecializedBuiltins ¶
func GetGlobalSpecializedBuiltins() *SpecializedBuiltinFunctions
GetGlobalSpecializedBuiltins returns the global specialized builtin functions
func (*SpecializedBuiltinFunctions) FastLen ¶
func (sbf *SpecializedBuiltinFunctions) FastLen(value Value) (int, bool)
FastLen provides optimized length calculation
func (*SpecializedBuiltinFunctions) FastStr ¶
func (sbf *SpecializedBuiltinFunctions) FastStr(value Value) string
FastStr provides optimized string conversion
func (*SpecializedBuiltinFunctions) FastTypeof ¶
func (sbf *SpecializedBuiltinFunctions) FastTypeof(value Value) string
FastTypeof provides optimized type checking
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack implementation using slice
type Statement ¶
type Statement interface { // Position returns the source code position of the statement. Position() Position // String returns a string representation of the statement. String() string }
Statement is an interface that all statement nodes in the AST must implement.
func AsStatement ¶
AsStatement safely converts to Statement
type Stats ¶
type Stats struct { // Ops counts the total number of operations executed Ops int // UserCalls counts the number of user-defined function calls UserCalls int // BuiltinCalls counts the number of builtin function calls BuiltinCalls int }
Stats collects statistics about the interpreter's execution. These statistics are returned from Evaluate or Execute calls.
func Execute ¶
Execute takes a parsed Program and interpreter config and interprets the program. Return interpreter statistics, and an error which is nil on success or an interpreter.Error if there's an error.
func SafeExecute ¶
SafeExecute executes code with error recovery
type StringConcatenator ¶
type StringConcatenator struct {
// contains filtered or unexported fields
}
StringConcatenator provides optimized string concatenation using sync.Pool
func GetStringConcatenator ¶
func GetStringConcatenator() *StringConcatenator
GetStringConcatenator gets a string concatenator from the pool
func NewStringConcatenator ¶
func NewStringConcatenator() *StringConcatenator
NewStringConcatenator creates a new optimized string concatenator
func (*StringConcatenator) Append ¶
func (sc *StringConcatenator) Append(s string)
Append adds a string efficiently
func (*StringConcatenator) AppendByte ¶
func (sc *StringConcatenator) AppendByte(b byte)
AppendByte adds a byte efficiently
func (*StringConcatenator) AppendRune ¶
func (sc *StringConcatenator) AppendRune(r rune)
AppendRune adds a rune efficiently
func (*StringConcatenator) Result ¶
func (sc *StringConcatenator) Result() string
Result returns the final concatenated string and releases the builder
func (*StringConcatenator) String ¶
func (sc *StringConcatenator) String() string
String returns the concatenated string
func (*StringConcatenator) WriteString ¶
func (sc *StringConcatenator) WriteString(s string)
WriteString writes a string to the concatenator
type StringInterner ¶
type StringInterner struct {
// contains filtered or unexported fields
}
StringInterner provides string interning to reduce memory usage
func (*StringInterner) Intern ¶
func (si *StringInterner) Intern(s string) string
Intern returns an interned version of the string
type StringPool ¶
type StringPool struct {
// contains filtered or unexported fields
}
StringPool provides pooling for string builders and byte slices
func (*StringPool) GetBuilder ¶
func (sp *StringPool) GetBuilder() *strings.Builder
GetBuilder gets a string builder from the pool
func (*StringPool) GetBytes ¶
func (sp *StringPool) GetBytes() []byte
GetBytes gets a byte slice from the pool
func (*StringPool) PutBuilder ¶
func (sp *StringPool) PutBuilder(sb *strings.Builder)
PutBuilder returns a string builder to the pool
func (*StringPool) PutBytes ¶
func (sp *StringPool) PutBytes(b []byte)
PutBytes returns a byte slice to the pool
type StringType ¶
type StringType int
StringType represents the type of string for smart interning
const ( StringTypeIdentifier StringType = iota StringTypeLiteral StringTypeOperator StringTypeGeneral )
type Subscript ¶
type Subscript struct { Container Expression // The container to index into (list, map, etc.) Subscript Expression // The index expression // contains filtered or unexported fields }
Subscript represents a container subscript expression (container[index]).
func (*Subscript) UnmarshalJSON ¶
String returns a string representation of the subscript expression. UnmarshalJSON implements custom JSON unmarshaling for Subscript
type TableColumnConfig ¶
TableColumnConfig represents column configuration for a specific table
type TaggedValueType ¶
type TaggedValueType uint8
TaggedValueType represents the type of a value for tagged union optimization
const ( TaggedNull TaggedValueType = iota TaggedBool TaggedInt TaggedFloat TaggedString TaggedArray TaggedMap TaggedFunction TaggedOther )
type Task ¶
type Task struct { ID string Function func() (Value, error) Result chan TaskResult Context context.Context Timeout time.Duration }
Task represents a unit of work to be executed
type TaskResult ¶
TaskResult represents the result of a task execution
type Ternary ¶
type Ternary struct { Condition Expression // The condition to evaluate TrueExpr Expression // Expression to return if condition is true FalseExpr Expression // Expression to return if condition is false // contains filtered or unexported fields }
Ternary represents a ternary conditional expression (condition ? true_expr : false_expr).
func NewTernary ¶
func NewTernary(pos Position, condition Expression, trueExpr Expression, falseExpr Expression) *Ternary
NewTernary creates a new ternary expression
func (*Ternary) UnmarshalJSON ¶
String returns a string representation of the ternary expression. UnmarshalJSON implements custom JSON unmarshaling for Ternary
type Token ¶
type Token int
Token represents the type of lexical token in the language Each token corresponds to a specific language element like operators, keywords, identifiers, etc.
type TokenCache ¶
type TokenCache struct {
// contains filtered or unexported fields
}
TokenCache provides caching for frequently used tokens to reduce parsing overhead
func GetGlobalTokenCache ¶
func GetGlobalTokenCache() *TokenCache
GetGlobalTokenCache returns the global token cache instance
func NewTokenCache ¶
func NewTokenCache(maxSize int) *TokenCache
NewTokenCache creates a new token cache with specified maximum size
func (*TokenCache) ClearCache ¶
func (tc *TokenCache) ClearCache()
ClearCache clears all cached tokens
func (*TokenCache) GetCacheSize ¶
func (tc *TokenCache) GetCacheSize() int
GetCacheSize returns the current cache size
func (*TokenCache) GetCachedToken ¶
func (tc *TokenCache) GetCachedToken(tokenStr string) (Token, bool)
GetCachedToken retrieves a token from cache or computes and caches it
func (*TokenCache) SetCachedToken ¶
func (tc *TokenCache) SetCachedToken(tokenStr string, token Token)
SetCachedToken stores a token in the cache
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
Tokenizer parses input source code to a stream of tokens. Use NewTokenizer() to create a tokenizer instance, and Next() to get the next token in the input stream.
func NewTokenizer ¶
NewTokenizer creates and initializes a new tokenizer for the given input. It sets up the initial position and reads the first character. Parameters:
- input: The source code as a byte array
Returns a pointer to the initialized Tokenizer
func (*Tokenizer) Next ¶
Next returns the position, token type, and token value of the next token in the source. For ordinary tokens (like operators and keywords), the token value is empty. For INT, FLOAT, NAME, and STR tokens, it contains the actual value. For an ILLEGAL token, it contains the error message.
Returns:
- Position: The position (line and column) where the token starts
- Token: The type of the token
- string: The token value (if applicable)
type TryCatch ¶
type TryCatch struct { TryBlock Block // The block to try executing ErrVar string // The variable name to hold the caught error CatchBlock Block // The block to execute if an error occurs // contains filtered or unexported fields }
TryCatch represents a try-catch statement for error handling.
type TypeError ¶
type TypeError struct { Message string // contains filtered or unexported fields }
TypeError is returned for invalid types and wrong number of arguments. This error occurs when operations are performed on incompatible types or when functions are called with incorrect argument types or counts.
type Unary ¶
type Unary struct { Operator Token // Operator token Operand Expression // The operand // contains filtered or unexported fields }
Unary represents a unary operation (operator operand).
func (*Unary) UnmarshalJSON ¶
String returns a string representation of the unary expression. UnmarshalJSON implements custom JSON unmarshaling for Unary
type Value ¶
type Value any
Value represents any runtime value in the language. This includes nil, boolean, integer, float, string, array, object, and function values.
func CreateSafeValue ¶
CreateSafeValue creates a safe copy of a value for use in different contexts
func FastSliceAppendValue ¶
FastSlice-based wrapper functions for better performance
func GetPooledArray ¶
GetPooledArray returns an appropriately sized pooled array
func OptimizedArrayCopy ¶
OptimizedArrayCopy creates an optimized copy of an array
func OptimizedArrayFilter ¶
OptimizedArrayFilter provides efficient array filtering
func OptimizedArrayMap ¶
OptimizedArrayMap provides efficient array mapping
func OptimizedLargeArrayFilter ¶
OptimizedLargeArrayFilter filters large arrays efficiently using chunking
func OptimizedMakeSlice ¶
OptimizedMakeSlice creates a slice with optimized capacity
func SmartAppend ¶
SmartAppend is a convenience function that automatically chooses the best append strategy based on data size
func WithArena ¶
func WithArena(fn func(*ExpressionArena) Value) Value
WithArena executes a function with an expression arena
type ValueError ¶
type ValueError struct { Message string // contains filtered or unexported fields }
ValueError is returned for invalid values (out of bounds index, etc). This error occurs when a value is valid in type but invalid in context, such as accessing an array with an index that is out of bounds.
func (ValueError) Error ¶
func (e ValueError) Error() string
Error returns the formatted error message including position information.
func (ValueError) Position ¶
func (e ValueError) Position() Position
Position returns the position (line and column) where the error occurred in the source.
type ValuePool ¶
type ValuePool struct {
// contains filtered or unexported fields
}
ValuePool provides pooling for common Value types to reduce allocations
type ValueType ¶
type ValueType string
ValueType represents the type of a runtime value
func GetValueType ¶
GetValueType returns the type of a runtime value
type Variable ¶
type Variable struct { Name string // Variable name // contains filtered or unexported fields }
Variable represents a variable reference.
func NewVariable ¶
NewVariable creates a new variable reference
type VariableLookupCache ¶
type VariableLookupCache struct {
// contains filtered or unexported fields
}
VariableLookupCache provides optimized variable lookup with caching EXPERIMENTAL: This cache is part of experimental memory optimization features WARNING: May not be thread-safe and could have compatibility issues
func GetGlobalVariableLookupCache ¶
func GetGlobalVariableLookupCache() *VariableLookupCache
GetGlobalVariableLookupCache returns the global variable lookup cache
func NewVariableLookupCache ¶
func NewVariableLookupCache(maxSize int) *VariableLookupCache
NewVariableLookupCache creates a new variable lookup cache
func (*VariableLookupCache) CacheVariable ¶
func (vlc *VariableLookupCache) CacheVariable(name string, value Value, scopeLevel int)
CacheVariable stores a variable in the cache
func (*VariableLookupCache) ClearCache ¶
func (vlc *VariableLookupCache) ClearCache()
ClearCache clears all cached variables
func (*VariableLookupCache) FastLookup ¶
func (vlc *VariableLookupCache) FastLookup(name string, env *Environment) (Value, bool)
FastLookup performs optimized variable lookup with caching
func (*VariableLookupCache) GetCacheStats ¶
func (vlc *VariableLookupCache) GetCacheStats() (hits, misses int64, hitRatio float64)
GetCacheStats returns cache performance statistics
func (*VariableLookupCache) InvalidateScope ¶
func (vlc *VariableLookupCache) InvalidateScope(scopeLevel int)
InvalidateScope removes all variables from a specific scope level
func (*VariableLookupCache) InvalidateVariable ¶
func (vlc *VariableLookupCache) InvalidateVariable(name string)
InvalidateVariable removes a variable from the cache
type While ¶
type While struct { Condition Expression // The condition to evaluate Body Block // The block to execute while condition is true // contains filtered or unexported fields }
While represents a while loop statement.
func (*While) UnmarshalJSON ¶
String returns a string representation of the while statement. UnmarshalJSON implements custom JSON unmarshaling for While
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker represents a single worker in the pool
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool manages a pool of workers for parallel execution
func NewWorkerPool ¶
func NewWorkerPool(numWorkers, queueSize int) *WorkerPool
NewWorkerPool creates a new worker pool
func (*WorkerPool) Shutdown ¶
func (wp *WorkerPool) Shutdown()
Shutdown gracefully shuts down the worker pool
func (*WorkerPool) SubmitTask ¶
func (wp *WorkerPool) SubmitTask(task *Task) error
SubmitTask submits a task to the worker pool
Source Files
¶
- append.go
- arena.go
- ast.go
- builders.go
- builtin_dispatch.go
- concurrent_executor.go
- config.go
- environment.go
- errors.go
- evaluator.go
- expression_optimizer.go
- fn_array_collection.go
- fn_cep.go
- fn_concurrent.go
- fn_core.go
- fn_database.go
- fn_datastructure.go
- fn_datetime.go
- fn_fact_database.go
- fn_file_system.go
- fn_math.go
- fn_memory.go
- fn_network.go
- fn_regex.go
- fn_serialization.go
- fn_string.go
- fn_type_convertion.go
- functions.go
- helpers.go
- interpreter.go
- memo.go
- memory_layout.go
- memory_layout_config.go
- numeric_evaluator.go
- parser.go
- parser_cache.go
- pools.go
- program.go
- string_interning.go
- tokenizer.go
- utils.go
- value.go
- variable_lookup.go