Documentation
¶
Index ¶
- Constants
- Variables
- func Const2Hook[C1 any, C2 any](c1 C1, c2 C2) func(Value) (C1, C2)
- func ConstHook[C any](c C) func(Value) C
- func EncodeString(b []byte, val string) []byte
- func NormalizeIndex(index int64, length int64) (int64, bool)
- func NormalizeSliceBounds(start int64, hasStart bool, end int64, hasEnd bool, length int64) (int64, int64)
- func NormalizeSliceBoundsStep(si int64, hasStart bool, ei int64, hasEnd bool, step int64, length int64) (int64, int64)
- func SeqAccessHook[T any](t2v func(T) Value, resolve func(Value) *Seq[T]) func(Value, Value, bc.Opcode) (Value, error)
- func SeqAssignHook[T any](resolve func(Value) *Seq[T], as func(Value) (T, bool), tn string) func(Value, Value, Value) error
- func SeqIterKeyHook[T any](resolve func(v Value) *SeqIter[T]) func(Value) (Value, error)
- func SeqIterNextHook[T any](resolve func(v Value) *SeqIter[T]) func(Value) bool
- func SeqIterStringHook[T any](tn string, resolve func(v Value) *SeqIter[T]) func(Value) string
- func SeqIterValueHook[T any](t2v func(T) Value, resolve func(v Value) *SeqIter[T]) func(Value) (Value, error)
- func SeqNameHook(name string, immutableName string) func(Value) string
- func SeqSliceHook[T any](alloc func([]T, bool) Value, resolve func(Value) *Seq[T]) func(Value, Value, Value) (Value, error)
- func SeqSliceStepHook[T any](alloc func([]T, bool) Value, resolve func(Value) *Seq[T]) func(Value, Value, Value, Value) (Value, error)
- func SetValueType(t uint8, f ValueTypeDescr) error
- func ValueHook(v Value, e error) func(Value) (Value, error)
- type Array
- type ArrayIterator
- type BuiltinClosure
- type BuiltinFunction
- type Bytes
- type BytesIterator
- type CompiledFunction
- func (o *CompiledFunction) DecodeBinary(data []byte) error
- func (o *CompiledFunction) EncodeBinary() ([]byte, error)
- func (o *CompiledFunction) GobDecode(data []byte) error
- func (o CompiledFunction) GobEncode() ([]byte, error)
- func (o *CompiledFunction) HasNamedResult() bool
- func (o *CompiledFunction) NamedResultSlot() int
- func (o *CompiledFunction) Set(instructions bc.Instructions, free []*Value, sourceMap map[int]Pos, ...)
- func (o *CompiledFunction) Size() int64
- func (o *CompiledFunction) SourcePos(ip int) Pos
- type Dict
- type DictIterator
- type Error
- type FormatSpec
- type IntRange
- type IntRangeIterator
- type NativeFunc
- type Pos
- type Primitive
- type Record
- type Runes
- type RunesIterator
- type Seq
- type SeqIter
- type Static
- type VM
- type Value
- func BoolValue(b bool) Value
- func BuiltinFunctionValue(id uint64) Value
- func ByteValue(v byte) Value
- func FloatValue(f float64) Value
- func ForEachCallback(args []Value) (Value, error)
- func IntValue(i int64) Value
- func NewArrayIteratorValue(arr []Value) Value
- func NewArrayValue(arr []Value, immutable bool) Value
- func NewBuiltinClosureValue(name string, fn NativeFunc, arity int, variadic bool) Value
- func NewBytesIteratorValue(b []byte) Value
- func NewBytesValue(b []byte, immutable bool) Value
- func NewCompiledFunctionValue(instructions bc.Instructions, free []*Value, sourceMap map[int]Pos, ...) Value
- func NewDecimalValue(d dec128.Dec128) Value
- func NewDictIteratorValue(m map[string]Value) Value
- func NewDictValue(m map[string]Value, immutable bool) Value
- func NewErrorValue(payload Value, kind string, fatal bool) Value
- func NewIntRangeIteratorValue(start, stop, step int64) Value
- func NewIntRangeValue(start, stop, step int64) Value
- func NewRecordValue(m map[string]Value, immutable bool) Value
- func NewRunesIteratorValue(s []rune) Value
- func NewRunesValue(r []rune, immutable bool) Value
- func NewRuntimeErrorValue(kind string, fatal bool, message string) Value
- func NewStaticBytesValue(b *Bytes) Value
- func NewStaticCompiledFunctionValue(cf *CompiledFunction) Value
- func NewStaticDecimalValue(d *dec128.Dec128) Value
- func NewStaticFormatSpecValue(fs *FormatSpec) Value
- func NewStaticRunesValue(r *Runes) Value
- func NewStaticStringValue(s *string) Value
- func NewStaticTimeValue(t *time.Time) Value
- func NewStringValue(s string) Value
- func NewTimeValue(t time.Time) Value
- func NewValuePtrValue(p *Value) Value
- func RefValue(v Value) Value
- func RuneValue(c rune) Value
- func SeqAll[T any](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func SeqAny[T any](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func SeqChunk[T any](v Value, args []Value, alloc func([]T, bool) Value, ...) (Value, error)
- func SeqCount[T comparable](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func SeqFilter[T comparable](vm VM, v Value, args []Value, t2v func(T) Value, alloc func([]T, bool) Value, ...) (Value, error)
- func SeqFind[T any](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func SeqForEach[T any](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func SeqMap[T any](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func SeqReduce[T any](vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T]) (Value, error)
- func (v Value) Access(index Value, mode bc.Opcode) (Value, error)
- func (v Value) Append(args []Value) (Value, error)
- func (v Value) Arity() int
- func (v Value) AsArray() ([]Value, bool)
- func (v Value) AsBool() (bool, bool)
- func (v Value) AsByte() (byte, bool)
- func (v Value) AsBytes() ([]byte, bool)
- func (v Value) AsDecimal() (dec128.Dec128, bool)
- func (v Value) AsDict() (map[string]Value, bool)
- func (v Value) AsFloat() (float64, bool)
- func (v Value) AsInt() (int64, bool)
- func (v Value) AsRune() (rune, bool)
- func (v Value) AsRunes() ([]rune, bool)
- func (v Value) AsString() (string, bool)
- func (v Value) AsTime() (time.Time, bool)
- func (v Value) AsValue() (Value, bool)
- func (v Value) Assign(idx Value, val Value) error
- func (v Value) BinaryOp(op token.Token, rhs Value) (Value, error)
- func (v Value) Call(vm VM, args []Value) (Value, error)
- func (v *Value) Clone() (Value, error)
- func (v Value) Contains(e Value) bool
- func (v *Value) DecodeBinary(data []byte) error
- func (v Value) Delete(key Value) (Value, error)
- func (v Value) EncodeBinary() ([]byte, error)
- func (v Value) EncodeJSON() ([]byte, error)
- func (v Value) Equal(rhs Value) bool
- func (v Value) Format(sp fspec.FormatSpec) (string, error)
- func (v *Value) GobDecode(data []byte) error
- func (v Value) GobEncode() ([]byte, error)
- func (v Value) Interface() any
- func (v Value) IsCallable() bool
- func (v Value) IsIterable() bool
- func (v Value) IsPrimitive() bool
- func (v Value) IsTrue() bool
- func (v Value) IsUserDefined() bool
- func (v Value) IsVariadic() bool
- func (v Value) Iterator() (Value, error)
- func (v Value) Key() (Value, error)
- func (v Value) Len() int64
- func (v Value) MethodCall(vm VM, name string, args []Value) (Value, error)
- func (v Value) Next() bool
- func (v *Value) Set(val Value)
- func (v Value) Slice(s Value, e Value) (Value, error)
- func (v Value) SliceStep(s Value, e Value, step Value) (Value, error)
- func (v Value) String() string
- func (v Value) ToImmutable() (Value, error)
- func (v Value) TypeName() string
- func (v Value) UnaryOp(op token.Token) (Value, error)
- func (v Value) Value() (Value, error)
- type ValueTypeDescr
Constants ¶
const ( // Pos constants NoPos Pos = 0 // Builtin module/function slot constants ModuleSlotSize = 128 MaxModules = 32 )
const KindUser = "user"
Variables ¶
var ( Undefined = Value{} True = Value{Type: value.Bool, Immutable: true, Data: 1} False = Value{Type: value.Bool, Immutable: true, Data: 0} EmptyString = Value{Type: value.String, Immutable: true, Ptr: unsafe.Pointer(&emptyString)} )
var BuiltinFunctions [MaxModules * ModuleSlotSize]*BuiltinFunction
Builtin module/function registry
var DefaultValueType = ValueTypeDescr{ Name: func(v Value) string { return fmt.Sprintf("<unknown:%d>", v.Type) }, String: func(v Value) string { return v.TypeName() }, Format: defaultFormat, Interface: func(_ Value) any { return nil }, EncodeJSON: func(v Value) ([]byte, error) { return nil, errs.NewJSONEncodingError(v.TypeName()) }, EncodeBinary: func(v Value) ([]byte, error) { return nil, errs.NewBinaryEncodingError(v.TypeName()) }, DecodeBinary: func(v *Value, _ []byte) error { return errs.NewBinaryEncodingError(v.TypeName()) }, IsTrue: ConstHook(false), Clone: func(v Value) (Value, error) { return v, nil }, Equal: func(v Value, r Value) bool { return v == r }, UnaryOp: defaultUnaryOp, BinaryOp: defaultBinaryOp, MethodCall: defaultMethodCall, IsIterable: ConstHook(false), Contains: func(Value, Value) bool { return false }, Len: ConstHook(int64(0)), Iterator: ValueHook(Undefined, nil), Assign: func(v Value, _, _ Value) error { return errs.NewNotAssignableError(v.TypeName()) }, Delete: defaultDelete, Access: defaultAccess, Append: defaultAppend, Slice: defaultSlice, SliceStep: defaultSliceStep, IsCallable: ConstHook(false), IsVariadic: ConstHook(false), Arity: ConstHook(0), Call: defaultCall, Next: ConstHook(false), Key: ValueHook(Undefined, nil), Value: ValueHook(Undefined, nil), AsBool: Const2Hook(false, false), AsByte: Const2Hook(byte(0), false), AsRune: Const2Hook(rune(0), false), AsInt: Const2Hook(int64(0), false), AsFloat: Const2Hook(float64(0), false), AsDecimal: Const2Hook(dec128.Decimal0, false), AsTime: Const2Hook(time.Time{}, false), AsString: Const2Hook("", false), AsBytes: Const2Hook[[]byte](nil, false), AsArray: func(Value) ([]Value, bool) { return nil, false }, AsDict: func(Value) (map[string]Value, bool) { return nil, false }, AsRunes: defaultAsRunes, IsMethodPure: func(string) bool { return false }, }
DefaultValueType provides default implementations for all ValueType hooks.
var TypeArray = ValueTypeDescr{ Name: SeqNameHook(arrayTypeName, immutableArrayTypeName), String: arrayTypeString, Format: arrayTypeFormat, Interface: arrayTypeInterface, EncodeJSON: arrayTypeEncodeJSON, EncodeBinary: arrayTypeEncodeBinary, DecodeBinary: arrayTypeDecodeBinary, IsTrue: func(v Value) bool { return len((*Array)(v.Ptr).Elements) > 0 }, IsIterable: ConstHook(true), Iterator: arrayTypeIterator, Equal: arrayTypeEqual, Clone: arrayTypeClone, Len: func(v Value) int64 { return int64(len((*Array)(v.Ptr).Elements)) }, BinaryOp: arrayTypeBinaryOp, MethodCall: arrayTypeMethodCall, Access: SeqAccessHook(RefValue, arrayTypeResolve), Assign: SeqAssignHook(arrayTypeResolve, Value.AsValue, anyTypeName), Contains: arrayTypeContains, Append: arrayTypeAppend, Slice: SeqSliceHook(NewArrayValue, arrayTypeResolve), SliceStep: SeqSliceStepHook(NewArrayValue, arrayTypeResolve), AsBool: func(v Value) (bool, bool) { return len((*Array)(v.Ptr).Elements) > 0, true }, AsString: arrayTypeAsString, AsRunes: arrayTypeAsRunes, AsBytes: arrayTypeAsBytes, AsArray: func(v Value) ([]Value, bool) { return (*Array)(v.Ptr).Elements, true }, IsMethodPure: func(string) bool { return true }, }
var TypeArrayIterator = ValueTypeDescr{ Name: ConstHook(arrayIteratorTypeName), String: SeqIterStringHook[Value](arrayIteratorTypeName, arrayIteratorResolve), Next: SeqIterNextHook[Value](arrayIteratorResolve), Key: SeqIterKeyHook[Value](arrayIteratorResolve), Value: SeqIterValueHook(RefValue, arrayIteratorResolve), }
var TypeBool = ValueTypeDescr{ Name: ConstHook(boolTypeName), String: boolTypeString, Format: boolTypeFormat, Interface: func(v Value) any { return v.Data != 0 }, EncodeJSON: boolTypeEncodeJSON, EncodeBinary: boolTypeEncodeBinary, DecodeBinary: boolTypeDecodeBinary, IsTrue: func(v Value) bool { return v.Data != 0 }, Equal: boolTypeEqual, MethodCall: boolTypeMethodCall, Len: ConstHook(int64(1)), AsString: boolTypeAsString, AsInt: boolTypeAsInt, AsBool: func(v Value) (bool, bool) { return v.Data != 0, true }, AsByte: boolTypeAsByte, IsMethodPure: func(string) bool { return true }, }
var TypeBuiltinClosure = ValueTypeDescr{ Name: builtinClosureTypeName, String: func(v Value) string { return builtinClosureTypeName(v) }, IsTrue: ConstHook(true), IsCallable: ConstHook(true), IsVariadic: builtinClosureTypeIsVariadic, Arity: builtinClosureTypeArity, Call: builtinClosureTypeCall, MethodCall: builtinClosureTypeMethodCall, IsMethodPure: func(string) bool { return true }, }
var TypeBuiltinFunction = ValueTypeDescr{ Name: builtinFunctionTypeName, String: func(v Value) string { return builtinFunctionTypeName(v) }, EncodeBinary: builtinFunctionTypeEncodeBinary, DecodeBinary: builtinFunctionTypeDecodeBinary, IsTrue: ConstHook(true), IsCallable: ConstHook(true), IsVariadic: builtinFunctionTypeIsVariadic, Arity: builtinFunctionTypeArity, Call: builtinFunctionTypeCall, MethodCall: builtinFunctionTypeMethodCall, IsMethodPure: func(string) bool { return true }, }
var TypeByte = ValueTypeDescr{ Name: ConstHook(byteTypeName), String: func(v Value) string { return fmt.Sprintf("byte(%d)", v.Data) }, Format: byteTypeFormat, Interface: func(v Value) any { return byte(v.Data) }, EncodeJSON: byteTypeEncodeJSON, EncodeBinary: byteTypeEncodeBinary, DecodeBinary: byteTypeDecodeBinary, IsTrue: func(v Value) bool { return v.Data != 0 }, Equal: byteTypeEqual, Len: ConstHook(int64(1)), UnaryOp: byteTypeUnaryOp, BinaryOp: byteTypeBinaryOp, MethodCall: byteTypeMethodCall, AsString: func(v Value) (string, bool) { return strconv.FormatInt(int64(v.Data), 10), true }, AsInt: func(v Value) (int64, bool) { return int64(v.Data), true }, AsBool: func(v Value) (bool, bool) { return v.Data != 0, true }, AsRune: func(v Value) (rune, bool) { return rune(v.Data), true }, AsByte: func(v Value) (byte, bool) { return byte(v.Data), true }, AsFloat: func(v Value) (float64, bool) { return float64(int64(v.Data)), true }, AsDecimal: func(v Value) (dec128.Dec128, bool) { return dec128.FromInt64(int64(v.Data)), true }, IsMethodPure: func(string) bool { return true }, }
var TypeBytes = ValueTypeDescr{ Name: SeqNameHook(bytesTypeName, immutableBytesTypeName), String: bytesTypeString, Format: bytesTypeFormat, Interface: func(v Value) any { return (*Bytes)(v.Ptr).Elements }, EncodeJSON: bytesTypeEncodeJSON, EncodeBinary: bytesTypeEncodeBinary, DecodeBinary: bytesTypeDecodeBinary, IsTrue: func(v Value) bool { return len((*Bytes)(v.Ptr).Elements) > 0 }, IsIterable: ConstHook(true), Iterator: bytesTypeIterator, Equal: bytesTypeEqual, Clone: bytesTypeClone, Len: func(v Value) int64 { return int64(len((*Bytes)(v.Ptr).Elements)) }, BinaryOp: bytesTypeBinaryOp, MethodCall: bytesTypeMethodCall, Access: SeqAccessHook(ByteValue, bytesTypeResolve), Assign: SeqAssignHook(bytesTypeResolve, Value.AsByte, byteTypeName), Append: bytesTypeAppend, Contains: bytesTypeContains, Slice: SeqSliceHook(NewBytesValue, bytesTypeResolve), SliceStep: SeqSliceStepHook(NewBytesValue, bytesTypeResolve), AsBool: func(v Value) (bool, bool) { return conv.ParseBool(string((*Bytes)(v.Ptr).Elements)) }, AsString: func(v Value) (string, bool) { return string((*Bytes)(v.Ptr).Elements), true }, AsBytes: func(v Value) ([]byte, bool) { return (*Bytes)(v.Ptr).Elements, true }, AsArray: bytesTypeAsArray, IsMethodPure: func(string) bool { return true }, }
var TypeBytesIterator = ValueTypeDescr{ Name: ConstHook(bytesIteratorTypeName), String: SeqIterStringHook[byte](bytesIteratorTypeName, bytesIteratorResolve), Next: SeqIterNextHook[byte](bytesIteratorResolve), Key: SeqIterKeyHook[byte](bytesIteratorResolve), Value: SeqIterValueHook(ByteValue, bytesIteratorResolve), }
var TypeCompiledFunction = ValueTypeDescr{ Name: compiledFunctionTypeName, String: func(v Value) string { return compiledFunctionTypeName(v) }, EncodeBinary: compiledFunctionTypeEncodeBinary, DecodeBinary: compiledFunctionTypeDecodeBinary, IsTrue: ConstHook(true), IsCallable: ConstHook(true), IsVariadic: compiledFunctionTypeIsVariadic, Equal: compiledFunctionTypeEqual, Arity: compiledFunctionTypeArity, Call: compiledFunctionTypeCall, MethodCall: compiledFunctionTypeMethodCall, IsMethodPure: func(string) bool { return true }, }
var TypeDecimal = ValueTypeDescr{ Name: ConstHook(decimalTypeName), String: decimalTypeString, Format: decimalTypeFormat, Interface: func(v Value) any { return *(*dec128.Dec128)(v.Ptr) }, EncodeJSON: func(v Value) ([]byte, error) { return (*dec128.Dec128)(v.Ptr).MarshalJSON() }, EncodeBinary: decimalTypeEncodeBinary, DecodeBinary: decimalTypeDecodeBinary, IsTrue: func(v Value) bool { return !(*dec128.Dec128)(v.Ptr).IsZero() }, Equal: decimalTypeEqual, Len: ConstHook(int64(1)), UnaryOp: decimalTypeUnaryOp, BinaryOp: decimalTypeBinaryOp, MethodCall: decimalTypeMethodCall, AsString: func(v Value) (string, bool) { return (*dec128.Dec128)(v.Ptr).String(), true }, AsInt: decimalTypeAsInt, AsFloat: decimalTypeAsFloat, AsDecimal: func(v Value) (dec128.Dec128, bool) { return *(*dec128.Dec128)(v.Ptr), true }, AsBool: func(v Value) (bool, bool) { return !(*dec128.Dec128)(v.Ptr).IsZero(), true }, IsMethodPure: func(string) bool { return true }, }
var TypeDict = ValueTypeDescr{ Name: SeqNameHook(dictTypeName, immutableDictTypeName), String: dictTypeString, Format: dictTypeFormat, Interface: dictTypeInterface, EncodeJSON: dictTypeEncodeJSON, EncodeBinary: dictTypeEncodeBinary, DecodeBinary: dictTypeDecodeBinary, IsTrue: dictTypeIsTrue, IsIterable: ConstHook(true), Iterator: dictTypeIterator, Equal: dictTypeEqual, Clone: dictTypeClone, Len: dictTypeLen, MethodCall: dictTypeMethodCall, Access: dictTypeAccess, Assign: dictTypeAssign, Contains: dictTypeContains, Delete: dictTypeDelete, AsBool: dictTypeAsBool, AsString: dictTypeAsString, AsDict: dictTypeAsDict, IsMethodPure: func(string) bool { return true }, }
var TypeDictIterator = ValueTypeDescr{ Name: ConstHook(dictIteratorTypeName), String: dictIteratorTypeString, Equal: dictIteratorTypeEqual, Next: dictIteratorTypeNext, Key: dictIteratorTypeKey, Value: dictIteratorTypeValue, }
var TypeError = ValueTypeDescr{ Name: ConstHook(errorTypeName), String: errorTypeString, Format: errorTypeFormat, Interface: func(v Value) any { return errors.New(v.String()) }, EncodeJSON: errorTypeEncodeJSON, EncodeBinary: errorTypeEncodeBinary, DecodeBinary: errorTypeDecodeBinary, IsTrue: ConstHook(false), Equal: errorTypeEqual, Clone: errorTypeClone, MethodCall: errorTypeMethodCall, AsString: errorTypeAsString, AsBool: Const2Hook(false, true), IsMethodPure: func(string) bool { return true }, }
var TypeFloat = ValueTypeDescr{ Name: ConstHook(floatTypeName), String: floatTypeString, Format: floatTypeFormat, Interface: func(v Value) any { return math.Float64frombits(v.Data) }, EncodeJSON: floatTypeEncodeJSON, EncodeBinary: floatTypeEncodeBinary, DecodeBinary: floatTypeDecodeBinary, IsTrue: func(v Value) bool { return !math.IsNaN(math.Float64frombits(v.Data)) }, Equal: floatTypeEqual, Len: ConstHook(int64(1)), UnaryOp: floatTypeUnaryOp, BinaryOp: floatTypeBinaryOp, MethodCall: floatTypeMethodCall, AsInt: floatTypeAsInt, AsFloat: floatTypeAsFloat, AsDecimal: floatTypeAsDecimal, AsBool: floatTypeAsBool, AsString: floatTypeAsString, IsMethodPure: func(string) bool { return true }, }
var TypeFormatSpec = ValueTypeDescr{ Name: ConstHook(formatSpecTypeName), String: formatSpecTypeString, Equal: formatSpecTypeEqual, }
var TypeInt = ValueTypeDescr{ Name: ConstHook(intTypeName), String: func(v Value) string { return strconv.FormatInt(int64(v.Data), 10) }, Format: intTypeFormat, Interface: func(v Value) any { return int64(v.Data) }, EncodeJSON: intTypeEncodeJSON, EncodeBinary: intTypeEncodeBinary, DecodeBinary: intTypeDecodeBinary, IsTrue: func(v Value) bool { return v.Data != 0 }, Equal: intTypeEqual, Len: ConstHook(int64(1)), UnaryOp: intTypeUnaryOp, BinaryOp: intTypeBinaryOp, MethodCall: intTypeMethodCall, AsString: func(v Value) (string, bool) { return strconv.FormatInt(int64(v.Data), 10), true }, AsInt: func(v Value) (int64, bool) { return int64(v.Data), true }, AsFloat: func(v Value) (float64, bool) { return float64(int64(v.Data)), true }, AsDecimal: func(v Value) (dec128.Dec128, bool) { return dec128.FromInt64(int64(v.Data)), true }, AsBool: func(v Value) (bool, bool) { return v.Data != 0, true }, AsRune: intTypeAsRune, AsTime: func(v Value) (time.Time, bool) { return time.Unix(int64(v.Data), 0).UTC(), true }, AsByte: intTypeAsByte, IsMethodPure: func(string) bool { return true }, }
var TypeIntRange = ValueTypeDescr{ Name: ConstHook(intRangeTypeName), EncodeBinary: intRangeTypeEncodeBinary, DecodeBinary: intRangeTypeDecodeBinary, String: intRangeTypeString, Format: intRangeTypeFormat, IsTrue: intRangeTypeIsTrue, IsIterable: ConstHook(true), Iterator: intRangeTypeIterator, Equal: intRangeTypeEqual, Len: intRangeTypeLen, MethodCall: intRangeTypeMethodCall, Access: intRangeTypeAccess, Contains: intRangeTypeContains, AsBool: intRangeTypeAsBool, AsArray: intRangeTypeAsArray, IsMethodPure: func(string) bool { return true }, }
var TypeIntRangeIterator = ValueTypeDescr{ Name: ConstHook(intRangeIteratorTypeName), String: intRangeIteratorTypeString, Equal: intRangeIteratorTypeEqual, Next: intRangeIteratorTypeNext, Key: intRangeIteratorTypeKey, Value: intRangeIteratorTypeValue, }
var TypeRecord = ValueTypeDescr{ Name: SeqNameHook(recordTypeName, immutableRecordTypeName), String: recordTypeString, Format: recordTypeFormat, Interface: recordTypeInterface, EncodeJSON: recordTypeEncodeJSON, EncodeBinary: recordTypeEncodeBinary, DecodeBinary: recordTypeDecodeBinary, IsTrue: recordTypeIsTrue, IsIterable: ConstHook(true), Iterator: recordTypeIterator, Equal: recordTypeEqual, Clone: recordTypeClone, Len: recordTypeLen, MethodCall: recordTypeMethodCall, Access: recordTypeAccess, Assign: recordTypeAssign, Contains: recordTypeContains, Delete: recordTypeDelete, AsBool: recordTypeAsBool, AsString: recordTypeAsString, AsDict: recordTypeAsDict, IsMethodPure: func(string) bool { return false }, }
var TypeRune = ValueTypeDescr{ Name: ConstHook(runeTypeName), String: func(v Value) string { return fmt.Sprintf("%q", rune(v.Data)) }, Format: runeTypeFormat, Interface: func(v Value) any { return rune(v.Data) }, EncodeJSON: runeTypeEncodeJSON, EncodeBinary: runeTypeEncodeBinary, DecodeBinary: runeTypeDecodeBinary, IsTrue: func(v Value) bool { return v.Data != 0 }, Equal: runeTypeEqual, Len: ConstHook(int64(1)), BinaryOp: runeTypeBinaryOp, MethodCall: runeTypeMethodCall, AsString: func(v Value) (string, bool) { return string(rune(v.Data)), true }, AsInt: func(v Value) (int64, bool) { return int64(v.Data), true }, AsBool: func(v Value) (bool, bool) { return v.Data != 0, true }, AsRune: func(v Value) (rune, bool) { return rune(v.Data), true }, AsByte: runeTypeAsByte, IsMethodPure: func(string) bool { return true }, }
var TypeRunes = ValueTypeDescr{ Name: SeqNameHook(runesTypeName, immutableRunesTypeName), String: func(v Value) string { return "u" + strconv.Quote(string((*Runes)(v.Ptr).Elements)) }, Format: runesTypeFormat, Interface: func(v Value) any { return (*Runes)(v.Ptr).Elements }, EncodeJSON: runesTypeEncodeJSON, EncodeBinary: runesTypeEncodeBinary, DecodeBinary: runesTypeDecodeBinary, IsTrue: func(v Value) bool { return len((*Runes)(v.Ptr).Elements) > 0 }, IsIterable: ConstHook(true), Iterator: runesTypeIterator, Equal: runesTypeEqual, Clone: runesTypeClone, Len: func(v Value) int64 { return int64(len((*Runes)(v.Ptr).Elements)) }, BinaryOp: runesTypeBinaryOp, MethodCall: runesTypeMethodCall, Access: SeqAccessHook(RuneValue, runesTypeResolve), Assign: SeqAssignHook(runesTypeResolve, Value.AsRune, runeTypeName), Append: runesTypeAppend, Contains: runesTypeContains, Slice: SeqSliceHook(NewRunesValue, runesTypeResolve), SliceStep: SeqSliceStepHook(NewRunesValue, runesTypeResolve), AsBool: runesTypeAsBool, AsInt: runesTypeAsInt, AsByte: runesTypeAsByte, AsFloat: runesTypeAsFloat, AsDecimal: runesTypeAsDecimal, AsTime: runesTypeAsTime, AsString: func(v Value) (string, bool) { return string((*Runes)(v.Ptr).Elements), true }, AsRunes: func(v Value) ([]rune, bool) { return (*Runes)(v.Ptr).Elements, true }, AsBytes: runesTypeAsBytes, AsArray: runesTypeAsArray, IsMethodPure: func(string) bool { return true }, }
var TypeRunesIterator = ValueTypeDescr{ Name: ConstHook(runesIteratorTypeName), String: SeqIterStringHook[rune](runesIteratorTypeName, runesIteratorResolve), Next: SeqIterNextHook[rune](runesIteratorResolve), Key: SeqIterKeyHook[rune](runesIteratorResolve), Value: SeqIterValueHook(RuneValue, runesIteratorResolve), }
var TypeString = ValueTypeDescr{ Name: ConstHook(stringTypeName), String: func(v Value) string { return strconv.Quote(*(*string)(v.Ptr)) }, Format: stringTypeFormat, Interface: func(v Value) any { return *(*string)(v.Ptr) }, EncodeJSON: stringTypeEncodeJSON, EncodeBinary: stringTypeEncodeBinary, DecodeBinary: stringTypeDecodeBinary, IsTrue: func(v Value) bool { return len(*(*string)(v.Ptr)) > 0 }, IsIterable: ConstHook(true), Iterator: stringTypeIterator, Equal: stringTypeEqual, Len: func(v Value) int64 { return int64(len(*(*string)(v.Ptr))) }, BinaryOp: stringTypeBinaryOp, MethodCall: stringTypeMethodCall, Access: stringTypeAccess, Contains: stringTypeContains, Slice: stringTypeSlice, SliceStep: stringTypeSliceStep, AsBool: func(v Value) (bool, bool) { return conv.ParseBool(*(*string)(v.Ptr)) }, AsInt: stringTypeAsInt, AsByte: stringTypeAsByte, AsFloat: stringTypeAsFloat, AsDecimal: stringTypeAsDecimal, AsTime: stringTypeAsTime, AsString: func(v Value) (string, bool) { return *(*string)(v.Ptr), true }, AsRunes: func(v Value) ([]rune, bool) { return []rune(*(*string)(v.Ptr)), true }, AsBytes: func(v Value) ([]byte, bool) { return []byte(*(*string)(v.Ptr)), true }, AsArray: stringTypeAsArray, IsMethodPure: func(string) bool { return true }, }
TypeString is a string type descriptor.
var TypeTime = ValueTypeDescr{ Name: ConstHook(timeTypeName), String: timeTypeString, Format: timeTypeFormat, Interface: timeTypeInterface, EncodeJSON: timeTypeEncodeJSON, EncodeBinary: timeTypeEncodeBinary, DecodeBinary: timeTypeDecodeBinary, IsTrue: timeTypeIsTrue, Equal: timeTypeEqual, Len: ConstHook(int64(1)), BinaryOp: timeTypeBinaryOp, MethodCall: timeTypeMethodCall, AsString: timeTypeAsString, AsInt: timeTypeAsInt, AsBool: timeTypeAsBool, AsTime: timeTypeAsTime, IsMethodPure: timeTypeIsMethodPure, }
TypeTime is a time type descriptor.
var TypeUndefined = ValueTypeDescr{ Name: ConstHook(undefinedTypeName), Interface: func(Value) any { return nil }, String: func(Value) string { return undefinedTypeName }, Format: undefinedTypeFormat, EncodeJSON: func(Value) ([]byte, error) { return []byte("null"), nil }, EncodeBinary: func(Value) ([]byte, error) { return []byte{}, nil }, DecodeBinary: func(v *Value, _ []byte) error { *v = Undefined; return nil }, IsTrue: ConstHook(false), IsIterable: ConstHook(true), Equal: func(v Value, r Value) bool { return v.Type == r.Type }, MethodCall: undefinedTypeMethodCall, Access: func(Value, Value, bc.Opcode) (Value, error) { return Undefined, nil }, AsBool: func(Value) (bool, bool) { return false, true }, IsMethodPure: func(string) bool { return true }, }
var TypeValuePtr = ValueTypeDescr{ Name: func(v Value) string { return fmt.Sprintf("<%s:%s>", valuePtrTypeName, v.TypeName()) }, }
var ValueTypes [256]ValueTypeDescr
ValueTypes is the global registry of value type descriptors, indexed by type ID.
Functions ¶
func Const2Hook ¶ added in v0.3.2
func EncodeString ¶
EncodeString encodes given string as JSON string according to https://www.json.org/img/string.png Implementation is inspired by https://github.com/json-iterator/go
func NormalizeIndex ¶ added in v0.3.2
NormalizeIndex normalizes index (-1 = last element, -2 = second to last, etc.) and checks if it's within bounds.
func NormalizeSliceBounds ¶ added in v0.3.2
func NormalizeSliceBounds(start int64, hasStart bool, end int64, hasEnd bool, length int64) (int64, int64)
NormalizeSliceBounds normalizes slice bounds (negative values count from the end, missing start defaults to 0, missing end defaults to length) and clamps them to [0, length]. If start > end after normalization, start is set to end.
func NormalizeSliceBoundsStep ¶ added in v0.3.2
func NormalizeSliceBoundsStep(si int64, hasStart bool, ei int64, hasEnd bool, step int64, length int64) (int64, int64)
NormalizeSliceBoundsStep returns the effective start and end for a step-based slice. Caller must ensure step != 0. For step > 0 the iteration is start..end (exclusive). For step < 0 the iteration is start..end (exclusive, with end possibly -1 to include index 0).
func SeqAccessHook ¶ added in v0.3.2
func SeqAccessHook[T any]( t2v func(T) Value, resolve func(Value) *Seq[T], ) func(Value, Value, bc.Opcode) (Value, error)
SeqAccessHook returns a hook function that allows accessing an element of the sequence at a specified index. PURE by contract.
func SeqAssignHook ¶ added in v0.3.2
func SeqAssignHook[T any]( resolve func(Value) *Seq[T], as func(Value) (T, bool), tn string, ) func(Value, Value, Value) error
IMPURE: returned Assign hook writes into the receiver. Not folded by the optimizer. See docs/purity.md.
SeqAssignHook returns a hook function that allows assigning a value to an element of the sequence at a specified index.
func SeqIterKeyHook ¶ added in v0.4.1
PURE: returned Key hook reads the iterator's current cursor without advancing it. See docs/purity.md.
func SeqIterNextHook ¶ added in v0.4.1
LOCALISED-STATE: returned Next hook advances the iterator's internal cursor. Iterators are expected to be held by a single consumer for the duration of iteration; the optimizer never speculatively evaluates iterator advancement. See docs/purity.md.
func SeqIterStringHook ¶ added in v0.4.1
func SeqIterValueHook ¶ added in v0.4.1
func SeqIterValueHook[T any]( t2v func(T) Value, resolve func(v Value) *SeqIter[T], ) func(Value) (Value, error)
PURE: returned Value hook reads the iterator's current element without advancing it. See docs/purity.md.
func SeqNameHook ¶ added in v0.4.1
SeqNameHook returns a hook function that provides the type name for the sequence based on its mutability.
func SeqSliceHook ¶ added in v0.3.2
func SeqSliceHook[T any]( alloc func([]T, bool) Value, resolve func(Value) *Seq[T], ) func(Value, Value, Value) (Value, error)
SeqSliceHook returns a hook function that allows slicing the sequence using start and end indices. PURE by contract.
func SeqSliceStepHook ¶ added in v0.3.2
func SeqSliceStepHook[T any]( alloc func([]T, bool) Value, resolve func(Value) *Seq[T], ) func(Value, Value, Value, Value) (Value, error)
SeqSliceStepHook returns a hook function that allows slicing the sequence using start and end indices with a specified step. PURE by contract.
func SetValueType ¶
func SetValueType(t uint8, f ValueTypeDescr) error
SetValueType registers a user-defined value type descriptor for the given type ID.
Types ¶
type ArrayIterator ¶
type BuiltinClosure ¶ added in v0.4.1
type BuiltinClosure struct {
Func NativeFunc
Name string
Arity int
Variadic bool
}
func (*BuiltinClosure) Set ¶ added in v0.4.1
func (f *BuiltinClosure) Set(fn NativeFunc, name string, arity int, variadic bool)
type BuiltinFunction ¶
type BuiltinFunction struct {
Func NativeFunc
Module string
Name string
Arity int
Variadic bool
Pure bool
}
func NewBuiltinFunction ¶ added in v0.4.1
func NewBuiltinFunction(name string, fn NativeFunc, arity int, variadic bool, pure bool) *BuiltinFunction
NewBuiltinFunction creates a new builtin function object. name is the name of the function. fn is the native function to be called. arity is the number of arguments the function takes. variadic is true if the function takes a variable number of arguments, in which case arity is the minimum number of arguments required. pure is true if the function does not have side effects, does not rely on external state, and always returns the same output for the same input.
type BytesIterator ¶
type CompiledFunction ¶
type CompiledFunction struct {
Instructions bc.Instructions
Free []*Value
SourceMap map[int]Pos
NumLocals int // number of local variables (including function parameters)
MaxStack int // estimated maximum operand-stack depth which can be reached during execution
NumParameters int
NamedResult int // local-slot index of function's named result: 0 = no named result, N > 0 means slot N-1
VarArgs bool
}
func (*CompiledFunction) DecodeBinary ¶ added in v0.4.1
func (o *CompiledFunction) DecodeBinary(data []byte) error
func (*CompiledFunction) EncodeBinary ¶ added in v0.4.1
func (o *CompiledFunction) EncodeBinary() ([]byte, error)
func (*CompiledFunction) GobDecode ¶ added in v0.4.1
func (o *CompiledFunction) GobDecode(data []byte) error
GobDecode wraps binary decoding to mirror GobEncode.
func (CompiledFunction) GobEncode ¶ added in v0.4.1
func (o CompiledFunction) GobEncode() ([]byte, error)
GobEncode wraps binary encoding so gob does not reflect over fields like Free []*Value (which include unsafe.Pointer).
func (*CompiledFunction) HasNamedResult ¶ added in v0.2.1
func (o *CompiledFunction) HasNamedResult() bool
func (*CompiledFunction) NamedResultSlot ¶ added in v0.2.1
func (o *CompiledFunction) NamedResultSlot() int
NamedResultSlot returns the local-slot index of the named result. Caller should check HasNamedResult first.
func (*CompiledFunction) Set ¶
func (o *CompiledFunction) Set(instructions bc.Instructions, free []*Value, sourceMap map[int]Pos, numLocals, maxStack int, numParameters int, namedResult int, varArgs bool)
func (*CompiledFunction) Size ¶
func (o *CompiledFunction) Size() int64
func (*CompiledFunction) SourcePos ¶
func (o *CompiledFunction) SourcePos(ip int) Pos
type DictIterator ¶ added in v0.0.8
type DictIterator struct {
Elements map[string]Value
Keys []string
// contains filtered or unexported fields
}
func (*DictIterator) Set ¶ added in v0.0.8
func (o *DictIterator) Set(m map[string]Value)
type FormatSpec ¶ added in v0.4.1
type FormatSpec struct {
Spec fspec.FormatSpec
Text string // original mini-language text (without the leading ':')
}
FormatSpec wraps a fully parsed fspec.FormatSpec together with its original textual form. It is an internal value kind: it lives only in the constant pool (referenced by OpFormat) and is never visible to user code.
func (FormatSpec) Equal ¶ added in v0.4.1
func (f FormatSpec) Equal(other FormatSpec) bool
func (*FormatSpec) Set ¶ added in v0.4.1
func (f *FormatSpec) Set(spec fspec.FormatSpec, text string)
type IntRangeIterator ¶
type IntRangeIterator struct {
// contains filtered or unexported fields
}
func (*IntRangeIterator) Set ¶
func (i *IntRangeIterator) Set(start, stop, step int64)
type RunesIterator ¶ added in v0.0.6
type SeqIter ¶ added in v0.4.1
type SeqIter[T any] struct { Elements []T // contains filtered or unexported fields }
type Static ¶ added in v0.4.1
type Static struct {
Primitives []Primitive
Decimals []dec128.Dec128
Strings []string
Runes []Runes
Bytes []Bytes
Times []time.Time
FormatSpecs []FormatSpec
CompiledFunctions []CompiledFunction
NameLists [][]string
}
Static variables
type VM ¶
type VM interface {
Abort() // aborts execution of the current script
IsStackEmpty() bool // returns true if there are no frames on the call stack
Call(Value, []Value) (Value, error) // calls a compiled function
Run() error // runs the VM until completion
Recover() Value // returns the in-flight error if in "deferred-for" frame
}
type Value ¶
Value represents a boxed Kavun value.
func BuiltinFunctionValue ¶
BuiltinFunctionValue creates new boxed builtin function value.
func FloatValue ¶
func ForEachCallback ¶ added in v0.3.2
ForEachCallback validates that the only argument is a callback (non-variadic function of arity 1 or 2) and returns it as a Value.
func NewArrayIteratorValue ¶
func NewArrayValue ¶
func NewBuiltinClosureValue ¶ added in v0.4.1
func NewBuiltinClosureValue(name string, fn NativeFunc, arity int, variadic bool) Value
func NewBytesIteratorValue ¶
func NewBytesValue ¶
func NewDecimalValue ¶
func NewDictIteratorValue ¶ added in v0.0.8
func NewIntRangeValue ¶
func NewRunesIteratorValue ¶ added in v0.0.6
func NewRunesValue ¶ added in v0.0.6
func NewRuntimeErrorValue ¶ added in v0.2.1
func NewStaticBytesValue ¶ added in v0.5.1
func NewStaticCompiledFunctionValue ¶ added in v0.4.1
func NewStaticCompiledFunctionValue(cf *CompiledFunction) Value
func NewStaticDecimalValue ¶ added in v0.4.1
func NewStaticFormatSpecValue ¶ added in v0.4.1
func NewStaticFormatSpecValue(fs *FormatSpec) Value
func NewStaticRunesValue ¶ added in v0.4.1
func NewStaticStringValue ¶ added in v0.4.1
func NewStaticTimeValue ¶ added in v0.5.1
func NewStringValue ¶
func NewTimeValue ¶
func NewValuePtrValue ¶ added in v0.4.1
func SeqAll ¶ added in v0.3.2
func SeqAll[T any]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqAll checks if all elements in the sequence satisfy a given condition.
func SeqAny ¶ added in v0.3.2
func SeqAny[T any]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqAny checks if any element in the sequence satisfy a given condition.
func SeqChunk ¶ added in v0.3.2
func SeqChunk[T any]( v Value, args []Value, alloc func([]T, bool) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqChunk divides the sequence into chunks of the specified size and returns a new sequence containing the chunks.
func SeqCount ¶ added in v0.3.2
func SeqCount[T comparable]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqCount counts the number of elements in the sequence that satisfy a given condition.
func SeqFilter ¶ added in v0.3.2
func SeqFilter[T comparable]( vm VM, v Value, args []Value, t2v func(T) Value, alloc func([]T, bool) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqFilter filters the elements of the sequence and returns a new sequence. If no arguments provided, it filters out zero values. If a function is provided, it filters out elements for which the function returns false. The function can have arity 1 (element) or 2 (index, element).
func SeqFind ¶ added in v0.3.2
func SeqFind[T any]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqFind searches for the first element in the sequence that satisfies a given condition and returns its index.
func SeqForEach ¶ added in v0.3.2
func SeqForEach[T any]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqForEach iterates over the elements of the sequence and calls the provided callback function for each element.
func SeqMap ¶ added in v0.3.2
func SeqMap[T any]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqMap applies a given function to each element in the sequence and returns a new sequence containing the results.
func SeqReduce ¶ added in v0.3.2
func SeqReduce[T any]( vm VM, v Value, args []Value, t2v func(T) Value, resolve func(Value) *Seq[T], ) (Value, error)
SeqReduce reduces the sequence to a single value by applying a given binary function cumulatively to the elements of the sequence, from left to right. The function can have arity 2 (accumulator, element) or 3 (accumulator, index, element).
func (*Value) DecodeBinary ¶
IMPURE by contract (mutates target)
func (Value) Format ¶ added in v0.1.3
func (v Value) Format(sp fspec.FormatSpec) (string, error)
PURE by contract
func (Value) GobEncode ¶
GobEncode wraps binary encoding so gob does not reflect over unsafe.Pointer field.
func (Value) MethodCall ¶
METHOD-DEPENDENT by contract: purity varies per method name, reported by IsMethodPure (see docs/purity.md)
func (Value) ToImmutable ¶ added in v0.3.2
PURE by contract
type ValueTypeDescr ¶ added in v0.4.1
type ValueTypeDescr struct {
Name func(v Value) string // PURE by contract
String func(v Value) string // PURE by contract
Format func(v Value, sp fspec.FormatSpec) (string, error) // PURE by contract
Interface func(v Value) any // PURE by contract
EncodeJSON func(v Value) ([]byte, error) // PURE by contract
EncodeBinary func(v Value) ([]byte, error) // PURE by contract
DecodeBinary func(v *Value, data []byte) error // IMPURE by contract (mutates target)
IsTrue func(v Value) bool // PURE by contract
Clone func(v Value) (Value, error) // PURE by contract
Equal func(v Value, r Value) bool // PURE by contract
UnaryOp func(v Value, op token.Token) (Value, error) // PURE by contract
BinaryOp func(v Value, r Value, op token.Token) (Value, error) // PURE by contract
MethodCall func(vm VM, v Value, name string, args []Value) (Value, error) // METHOD-DEPENDENT by contract: purity varies per method name, reported by IsMethodPure (see docs/purity.md)
IsIterable func(v Value) bool // PURE by contract
Contains func(v Value, e Value) bool // PURE by contract
Len func(v Value) int64 // PURE by contract
Iterator func(v Value) (Value, error) // PURE by contract (constructs fresh iterator)
Access func(v Value, index Value, mode bc.Opcode) (Value, error) // PURE by contract
Assign func(v Value, index Value, r Value) error // IMPURE by contract (mutates target)
Append func(v Value, args []Value) (Value, error) // GO-STYLE by contract (may share receiver storage)
Slice func(v Value, s Value, e Value) (Value, error) // PURE by contract
Delete func(v Value, key Value) (Value, error) // IMPURE by contract (mutates target)
SliceStep func(v Value, s Value, e Value, step Value) (Value, error) // PURE by contract
IsCallable func(v Value) bool // PURE by contract
IsVariadic func(v Value) bool // PURE by contract
Arity func(v Value) int // PURE by contract
Call func(vm VM, v Value, args []Value) (Value, error) // CALLABLE-DEPENDENT by contract
Next func(v Value) bool // LOCALISED-STATE by contract (advances iterator cursor)
Key func(v Value) (Value, error) // LOCALISED-STATE by contract (reads iterator cursor)
Value func(v Value) (Value, error) // LOCALISED-STATE by contract (reads iterator cursor)
AsBool func(v Value) (bool, bool) // PURE by contract
AsByte func(v Value) (byte, bool) // PURE by contract
AsRune func(v Value) (rune, bool) // PURE by contract
AsInt func(v Value) (int64, bool) // PURE by contract
AsFloat func(v Value) (float64, bool) // PURE by contract
AsDecimal func(v Value) (dec128.Dec128, bool) // PURE by contract
AsTime func(v Value) (time.Time, bool) // PURE by contract
AsString func(v Value) (string, bool) // PURE by contract
AsRunes func(v Value) ([]rune, bool) // PURE by contract
AsBytes func(v Value) ([]byte, bool) // PURE by contract
AsArray func(v Value) ([]Value, bool) // PURE by contract
AsDict func(v Value) (map[string]Value, bool) // PURE by contract
// IsMethodPure reports whether calling the named method on this type is safe for the AST optimizer to fold
// (deterministic given its receiver+args, no external/environment state, no redirection to a value of unknown
// purity). Queried only for a receiver whose concrete type is already statically known (a literal). Conservative
// by construction: DefaultValueType.IsMethodPure always returns false, so any type — built-in or user-registered
// — that doesn't explicitly opt in is treated as "unknown, don't fold" per docs/purity.md. Must depend only on
// name, never on the receiver value or args: purity of a method is a property of the type, not of a particular
// instance.
IsMethodPure func(name string) bool
}
ValueTypeDescr is a Kavun data type descriptor structure. See docs/purity.md for purity contract.
Source Files
¶
- array.go
- array_iterator.go
- bool.go
- builtin_closure.go
- builtin_function.go
- byte.go
- bytes.go
- bytes_iterator.go
- compiled_function.go
- decimal.go
- dict.go
- dict_iterator.go
- error.go
- float.go
- format_spec.go
- generic.go
- generic_seq.go
- generic_seq_iter.go
- init.go
- int.go
- int_range.go
- int_range_iterator.go
- record.go
- rune.go
- runes.go
- runes_iterator.go
- string.go
- time.go
- tools.go
- types.go
- undefined.go
- value.go
- value_ptr.go