Documentation
¶
Index ¶
- Variables
- func CanConvert(sourceType, targetType TypeInfo) bool
- func ConvertToGo(value Value) interface{}
- type BoolValue
- type FieldInfo
- type FloatValue
- type FuncValue
- func (f *FuncValue) Body() interface{}
- func (f *FuncValue) Closure() map[string]Value
- func (f *FuncValue) Equal(other Value) bool
- func (f *FuncValue) Hash() uint64
- func (f *FuncValue) Name() string
- func (f *FuncValue) Parameters() []string
- func (f *FuncValue) String() string
- func (f *FuncValue) Type() TypeInfo
- type IntValue
- type MapValue
- func (m *MapValue) Equal(other Value) bool
- func (m *MapValue) Get(key string) (Value, bool)
- func (m *MapValue) Has(key string) bool
- func (m *MapValue) Hash() uint64
- func (m *MapValue) Keys() []string
- func (m *MapValue) Len() int
- func (m *MapValue) String() string
- func (m *MapValue) Type() TypeInfo
- func (m *MapValue) ValueType() TypeInfo
- func (m *MapValue) Values() map[string]Value
- type MethodInfo
- type NilValue
- type OptimizedValue
- func AddOptimized(left, right *OptimizedValue) (OptimizedValue, error)
- func CompareOptimized(left, right *OptimizedValue, op string) (OptimizedValue, error)
- func NewOptimizedBool(v bool) OptimizedValue
- func NewOptimizedFloat(v float64) OptimizedValue
- func NewOptimizedInt(v int64) OptimizedValue
- func NewOptimizedNil() OptimizedValue
- func NewOptimizedString(v string) OptimizedValue
- func (v *OptimizedValue) Equal(other *OptimizedValue) bool
- func (v *OptimizedValue) GetBool() bool
- func (v *OptimizedValue) GetFloat() float64
- func (v *OptimizedValue) GetInt() int64
- func (v *OptimizedValue) GetString() string
- func (v *OptimizedValue) GetType() TypeInfo
- func (v *OptimizedValue) Hash() uint64
- func (v *OptimizedValue) IsBool() bool
- func (v *OptimizedValue) IsFloat() bool
- func (v *OptimizedValue) IsInt() bool
- func (v *OptimizedValue) IsNil() bool
- func (v *OptimizedValue) IsNumeric() bool
- func (v *OptimizedValue) IsString() bool
- func (v *OptimizedValue) String() string
- func (v *OptimizedValue) ToBool() bool
- func (v *OptimizedValue) ToFloat64() (float64, bool)
- func (v *OptimizedValue) ToInt64() (int64, bool)
- type PlaceholderExprValue
- func (p *PlaceholderExprValue) Constants() []Value
- func (p *PlaceholderExprValue) Equal(other Value) bool
- func (p *PlaceholderExprValue) Hash() uint64
- func (p *PlaceholderExprValue) Instructions() []byte
- func (p *PlaceholderExprValue) Operand() Value
- func (p *PlaceholderExprValue) Operator() string
- func (p *PlaceholderExprValue) String() string
- func (p *PlaceholderExprValue) Type() TypeInfo
- type SliceValue
- func (s *SliceValue) ElementType() TypeInfo
- func (s *SliceValue) Equal(other Value) bool
- func (s *SliceValue) Get(index int) Value
- func (s *SliceValue) Hash() uint64
- func (s *SliceValue) Len() int
- func (s *SliceValue) String() string
- func (s *SliceValue) Type() TypeInfo
- func (s *SliceValue) Values() []Value
- type StringValue
- type TypeInfo
- func (t TypeInfo) Assignable(other TypeInfo) bool
- func (t TypeInfo) Compatible(other TypeInfo) bool
- func (t TypeInfo) IsComparable() bool
- func (t TypeInfo) IsFloat() bool
- func (t TypeInfo) IsInteger() bool
- func (t TypeInfo) IsNumeric() bool
- func (t TypeInfo) IsOrdered() bool
- func (t TypeInfo) String() string
- type TypeKind
- type Value
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var ( BoolType = TypeInfo{ Kind: KindBool, Name: "bool", Size: 1, } IntType = TypeInfo{ Kind: KindInt64, Name: "int", Size: 8, } FloatType = TypeInfo{ Kind: KindFloat64, Name: "float", Size: 8, } StringType = TypeInfo{ Kind: KindString, Name: "string", Size: -1, } NilType = TypeInfo{ Kind: KindNil, Name: "nil", Size: 0, } )
Predefined type info instances
Functions ¶
func CanConvert ¶
CanConvert returns true if a value can be converted to the target type
func ConvertToGo ¶
func ConvertToGo(value Value) interface{}
ConvertToGo converts a Value to a native Go value
Types ¶
type BoolValue ¶
type BoolValue struct {
// contains filtered or unexported fields
}
BoolValue represents a boolean value
type FloatValue ¶
type FloatValue struct {
// contains filtered or unexported fields
}
FloatValue represents a floating-point value (float64)
func NewFloat ¶
func NewFloat(v float64) *FloatValue
func (*FloatValue) Equal ¶
func (f *FloatValue) Equal(other Value) bool
func (*FloatValue) Hash ¶
func (f *FloatValue) Hash() uint64
func (*FloatValue) String ¶
func (f *FloatValue) String() string
func (*FloatValue) Type ¶
func (f *FloatValue) Type() TypeInfo
func (*FloatValue) Value ¶
func (f *FloatValue) Value() float64
type FuncValue ¶
type FuncValue struct {
// contains filtered or unexported fields
}
FuncValue represents a function/lambda value
func (*FuncValue) Parameters ¶
type IntValue ¶
type IntValue struct {
// contains filtered or unexported fields
}
IntValue represents an integer value (int64)
type MapValue ¶
type MapValue struct {
// contains filtered or unexported fields
}
MapValue represents a map value
type MethodInfo ¶
MethodInfo contains information about a method
type OptimizedValue ¶
type OptimizedValue struct {
Type ValueType
IntVal int64
FloatVal float64
StringVal string
BoolVal bool
// For complex types, we use a pointer to avoid copying large data
ComplexVal unsafe.Pointer
}
OptimizedValue is a union type that eliminates interface overhead This is the P0 optimization suggested in PERFORMANCE_SUMMARY.md
func AddOptimized ¶
func AddOptimized(left, right *OptimizedValue) (OptimizedValue, error)
AddOptimized performs optimized addition for union types
func CompareOptimized ¶
func CompareOptimized(left, right *OptimizedValue, op string) (OptimizedValue, error)
CompareOptimized performs optimized comparison for union types
func NewOptimizedBool ¶
func NewOptimizedBool(v bool) OptimizedValue
NewOptimizedBool creates an optimized boolean value
func NewOptimizedFloat ¶
func NewOptimizedFloat(v float64) OptimizedValue
NewOptimizedFloat creates an optimized float value
func NewOptimizedInt ¶
func NewOptimizedInt(v int64) OptimizedValue
NewOptimizedInt creates an optimized integer value
func NewOptimizedNil ¶
func NewOptimizedNil() OptimizedValue
NewOptimizedNil creates an optimized nil value
func NewOptimizedString ¶
func NewOptimizedString(v string) OptimizedValue
NewOptimizedString creates an optimized string value
func (*OptimizedValue) Equal ¶
func (v *OptimizedValue) Equal(other *OptimizedValue) bool
Equal compares two optimized values for equality
func (*OptimizedValue) GetBool ¶
func (v *OptimizedValue) GetBool() bool
GetBool returns the boolean value (assumes IsBool() is true)
func (*OptimizedValue) GetFloat ¶
func (v *OptimizedValue) GetFloat() float64
GetFloat returns the float value (assumes IsFloat() is true)
func (*OptimizedValue) GetInt ¶
func (v *OptimizedValue) GetInt() int64
GetInt returns the integer value (assumes IsInt() is true)
func (*OptimizedValue) GetString ¶
func (v *OptimizedValue) GetString() string
GetString returns the string value (assumes IsString() is true)
func (*OptimizedValue) GetType ¶
func (v *OptimizedValue) GetType() TypeInfo
GetType returns the TypeInfo for this value
func (*OptimizedValue) Hash ¶
func (v *OptimizedValue) Hash() uint64
Hash returns a hash value for this value
func (*OptimizedValue) IsBool ¶
func (v *OptimizedValue) IsBool() bool
IsBool returns true if this is a boolean value
func (*OptimizedValue) IsFloat ¶
func (v *OptimizedValue) IsFloat() bool
IsFloat returns true if this is a float value
func (*OptimizedValue) IsInt ¶
func (v *OptimizedValue) IsInt() bool
IsInt returns true if this is an integer value
func (*OptimizedValue) IsNil ¶
func (v *OptimizedValue) IsNil() bool
IsNil returns true if this is a nil value
func (*OptimizedValue) IsNumeric ¶
func (v *OptimizedValue) IsNumeric() bool
IsNumeric returns true if this value is numeric (int or float)
func (*OptimizedValue) IsString ¶
func (v *OptimizedValue) IsString() bool
IsString returns true if this is a string value
func (*OptimizedValue) String ¶
func (v *OptimizedValue) String() string
String returns string representation
func (*OptimizedValue) ToBool ¶
func (v *OptimizedValue) ToBool() bool
ToBool converts an optimized value to boolean for truthiness testing
func (*OptimizedValue) ToFloat64 ¶
func (v *OptimizedValue) ToFloat64() (float64, bool)
ToFloat64 converts numeric values to float64
func (*OptimizedValue) ToInt64 ¶
func (v *OptimizedValue) ToInt64() (int64, bool)
ToInt64 converts numeric values to int64
type PlaceholderExprValue ¶
type PlaceholderExprValue struct {
// contains filtered or unexported fields
}
PlaceholderExprValue represents a compiled placeholder expression that can be evaluated later
func NewPlaceholderExpr ¶
func NewPlaceholderExpr(instructions []byte, constants []Value, operator string, operand Value) *PlaceholderExprValue
func (*PlaceholderExprValue) Constants ¶
func (p *PlaceholderExprValue) Constants() []Value
func (*PlaceholderExprValue) Equal ¶
func (p *PlaceholderExprValue) Equal(other Value) bool
func (*PlaceholderExprValue) Hash ¶
func (p *PlaceholderExprValue) Hash() uint64
func (*PlaceholderExprValue) Instructions ¶
func (p *PlaceholderExprValue) Instructions() []byte
func (*PlaceholderExprValue) Operand ¶
func (p *PlaceholderExprValue) Operand() Value
func (*PlaceholderExprValue) Operator ¶
func (p *PlaceholderExprValue) Operator() string
func (*PlaceholderExprValue) String ¶
func (p *PlaceholderExprValue) String() string
func (*PlaceholderExprValue) Type ¶
func (p *PlaceholderExprValue) Type() TypeInfo
type SliceValue ¶
type SliceValue struct {
// contains filtered or unexported fields
}
SliceValue represents a slice/array value
func NewSlice ¶
func NewSlice(values []Value, elemType TypeInfo) *SliceValue
func (*SliceValue) ElementType ¶
func (s *SliceValue) ElementType() TypeInfo
ElementType returns the element type of the slice
func (*SliceValue) Equal ¶
func (s *SliceValue) Equal(other Value) bool
func (*SliceValue) Get ¶
func (s *SliceValue) Get(index int) Value
func (*SliceValue) Hash ¶
func (s *SliceValue) Hash() uint64
func (*SliceValue) Len ¶
func (s *SliceValue) Len() int
func (*SliceValue) String ¶
func (s *SliceValue) String() string
func (*SliceValue) Type ¶
func (s *SliceValue) Type() TypeInfo
func (*SliceValue) Values ¶
func (s *SliceValue) Values() []Value
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
StringValue represents a string value
func NewString ¶
func NewString(v string) *StringValue
func (*StringValue) Equal ¶
func (s *StringValue) Equal(other Value) bool
func (*StringValue) Hash ¶
func (s *StringValue) Hash() uint64
func (*StringValue) String ¶
func (s *StringValue) String() string
func (*StringValue) Type ¶
func (s *StringValue) Type() TypeInfo
func (*StringValue) Value ¶
func (s *StringValue) Value() string
type TypeInfo ¶
type TypeInfo struct {
Kind TypeKind
Name string
Size int // -1 for variable size
Methods []MethodInfo
Fields []FieldInfo
ElemType *TypeInfo // for arrays, slices, pointers
KeyType *TypeInfo // for maps
ValType *TypeInfo // for maps
}
TypeInfo contains static information about a type
func (TypeInfo) Assignable ¶
Assignable returns true if a value of 'other' type can be assigned to this type
func (TypeInfo) Compatible ¶
Compatible returns true if this type is compatible with another type
func (TypeInfo) IsComparable ¶
IsComparable returns true if values of this type can be compared
type TypeKind ¶
type TypeKind uint8
TypeKind represents the kind of a type
const ( KindBool TypeKind = iota KindInt KindInt8 KindInt16 KindInt32 KindInt64 KindUint KindUint8 KindUint16 KindUint32 KindUint64 KindFloat32 KindFloat64 KindString KindArray KindSlice KindMap KindStruct KindInterface KindPointer KindFunc KindNil KindUnknown // Added for type inference when type cannot be determined )
type Value ¶
Value represents any value that can be processed by expressions
func ConvertFromGo ¶
func ConvertFromGo(v interface{}) Value
ConvertFromGo converts a native Go value to a Value