Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeString(b []byte, val string) []byte
- func ReadOperands(numOperands []int, ins []byte) ([]int, int)
- func SetValueType(t uint8, f ValueType) error
- type Arena
- func (a *Arena) NewArray(capacity int, sized bool) []Value
- func (a *Arena) NewArrayIteratorValue(arr []Value) Value
- func (a *Arena) NewArrayValue(arr []Value, immutable bool) Value
- func (a *Arena) NewBuiltinFunctionValue(name string, fn NativeFunc, arity int8, variadic bool) Value
- func (a *Arena) NewBytes(capacity int, sized bool) []byte
- func (a *Arena) NewBytesIteratorValue(b []byte) Value
- func (a *Arena) NewBytesValue(b []byte, immutable bool) Value
- func (a *Arena) NewCompiledFunctionValue(instructions []byte, free []*Value, sourceMap map[int]Pos, numLocals int, ...) Value
- func (a *Arena) NewDecimal() *dec128.Dec128
- func (a *Arena) NewDict(capacity int) map[string]Value
- func (a *Arena) NewDictIteratorValue(m map[string]Value) Value
- func (a *Arena) NewDictValue(m map[string]Value, immutable bool) Value
- func (a *Arena) NewIntRangeIteratorValue(start, stop, step int64) Value
- func (a *Arena) NewIntRangeValue(start, stop, step int64) Value
- func (a *Arena) NewRecordValue(m map[string]Value, immutable bool) Value
- func (a *Arena) NewRunes(capacity int, sized bool) []rune
- func (a *Arena) NewRunesIteratorValue(s []rune) Value
- func (a *Arena) NewRunesValue(r []rune, immutable bool) Value
- func (a *Arena) NewStringValue(s string) Value
- func (a *Arena) NewTime() *time.Time
- func (a *Arena) Payload() any
- func (a *Arena) Reset()
- func (a *Arena) Stat() map[string]slab.Stats
- type ArenaOptions
- type Array
- type ArrayIterator
- type BuiltinFunction
- type Bytes
- type BytesIterator
- type CompiledFunction
- type Dict
- type DictIterator
- type Error
- type FormatSpecValue
- type IntRange
- type IntRangeIterator
- type NativeFunc
- type Opcode
- type Pos
- type Resettable
- type Runes
- type RunesIterator
- type String
- type VM
- type Value
- func ArrayIteratorValue(v *ArrayIterator) Value
- func ArrayValue(v *Array, immutable bool) Value
- func BoolValue(b bool) Value
- func BuiltinFunctionValue(f *BuiltinFunction) Value
- func ByteValue(v byte) Value
- func BytesIteratorValue(v *BytesIterator) Value
- func BytesValue(v *Bytes, immutable bool) Value
- func CompiledFunctionValue(f *CompiledFunction) Value
- func DecimalValue(d *dec128.Dec128) Value
- func DictIteratorValue(v *DictIterator) Value
- func DictValue(v *Dict, immutable bool) Value
- func ErrorValue(v *Error) Value
- func FloatValue(f float64) Value
- func IntRangeIteratorValue(v *IntRangeIterator) Value
- func IntRangeValue(v *IntRange) Value
- func IntValue(i int64) Value
- func NewArrayIteratorValue(v []Value) Value
- func NewArrayValue(vals []Value, immutable bool) Value
- func NewBuiltinFunctionValue(name string, fn NativeFunc, arity int8, variadic bool) Value
- func NewBytesIteratorValue(vals []byte) Value
- func NewBytesValue(v []byte, immutable bool) Value
- func NewCompiledFunctionValue(instructions []byte, free []*Value, sourceMap map[int]Pos, numLocals int, ...) Value
- func NewDecimalValue(d dec128.Dec128) Value
- func NewDictIteratorValue(m map[string]Value) Value
- func NewDictValue(vals map[string]Value, immutable bool) Value
- func NewErrorValue(payload Value) Value
- func NewFatalErrorValue(payload Value) Value
- func NewFormatSpecValue(spec fspec.FormatSpec, text string) Value
- func NewIntRangeIteratorValue(start, stop, step int64) Value
- func NewIntRangeValue(start, stop, step int64) Value
- func NewRecordValue(vals map[string]Value, immutable bool) Value
- func NewRunesIteratorValue(v []rune) Value
- func NewRunesValue(v []rune, immutable bool) Value
- func NewRuntimeErrorValue(kind string, fatal bool, message string) Value
- func NewStringValue(v string) Value
- func NewTimeValue(t time.Time) Value
- func RecordValue(v *Dict, immutable bool) Value
- func RuneValue(c rune) Value
- func RunesIteratorValue(v *RunesIterator) Value
- func RunesValue(v *Runes, immutable bool) Value
- func StringValue(v *String) Value
- func TimeValue(v *time.Time) Value
- func UndefinedValue() Value
- func ValuePtrValue(p *Value) Value
- func (v Value) Access(vm VM, index Value, mode Opcode) (Value, error)
- func (v Value) Append(a *Arena, args []Value) (Value, error)
- func (v Value) Arity() int8
- func (v Value) AsArray(a *Arena) ([]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(a *Arena) (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) Assign(idx Value, val Value) error
- func (v Value) BinaryOp(a *Arena, op token.Token, rhs Value) (Value, error)
- func (v Value) Call(vm VM, args []Value) (Value, error)
- func (v Value) Contains(e Value) bool
- func (v *Value) Copy(a *Arena) (Value, error)
- 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) Immutable(a *Arena) (Value, error)
- func (v Value) Interface() any
- func (v Value) IsCallable() bool
- func (v Value) IsImmutable() bool
- func (v Value) IsIterable() bool
- func (v Value) IsTrue() bool
- func (v Value) IsUserDefined() bool
- func (v Value) IsVariadic() bool
- func (v Value) Iterator(a *Arena) (Value, error)
- func (v Value) Key(a *Arena) (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(a *Arena, s Value, e Value) (Value, error)
- func (v Value) SliceStep(a *Arena, s Value, e Value, step Value) (Value, error)
- func (v Value) String() string
- func (v Value) TypeName() string
- func (v Value) UnaryOp(a *Arena, op token.Token) (Value, error)
- func (v Value) Value(a *Arena) (Value, error)
- type ValueType
Constants ¶
const ( // Pos constants NoPos Pos = 0 // Value type constants VT_UNDEFINED = uint8(0) // must be first (zero) VT_VALUE_PTR = uint8(1) VT_BUILTIN_FUNCTION = uint8(2) VT_COMPILED_FUNCTION = uint8(3) VT_FORMAT_SPEC = uint8(4) VT_ERROR = uint8(5) VT_BOOL = uint8(6) VT_BYTE = uint8(7) VT_RUNE = uint8(8) VT_INT = uint8(9) VT_FLOAT = uint8(10) VT_DECIMAL = uint8(11) VT_TIME = uint8(12) VT_STRING = uint8(13) VT_RUNES = uint8(14) VT_BYTES = uint8(15) VT_ARRAY = uint8(16) VT_RECORD = uint8(17) VT_DICT = uint8(18) VT_INT_RANGE = uint8(19) VT_RUNES_ITERATOR = uint8(20) VT_BYTES_ITERATOR = uint8(21) VT_ARRAY_ITERATOR = uint8(22) VT_DICT_ITERATOR = uint8(23) VT_INT_RANGE_ITERATOR = uint8(24) VT_USER_DEFINED = uint8(25) // must be last )
const ( OpConstant = Opcode(0) // Load constant OpBComplement = Opcode(1) // bitwise complement OpPop = Opcode(2) // Pop OpTrue = Opcode(3) // Push true OpFalse = Opcode(4) // Push false OpEqual = Opcode(5) // Equal == OpNotEqual = Opcode(6) // Not equal != OpMinus = Opcode(7) // Minus - OpLNot = Opcode(8) // Logical not ! OpJumpFalsy = Opcode(9) // Jump if falsy OpAndJump = Opcode(10) // Logical AND jump OpOrJump = Opcode(11) // Logical OR jump OpJump = Opcode(12) // Jump OpNull = Opcode(13) // Push null OpArray = Opcode(14) // Array object OpRecord = Opcode(15) // Record object OpContains = Opcode(16) // Contains operation (x in y) OpImmutable = Opcode(17) // Immutable object OpIndex = Opcode(18) // Index operation OpSliceIndex = Opcode(19) // Slice operation OpCall = Opcode(20) // Call function OpReturn = Opcode(21) // Return OpGetGlobal = Opcode(22) // Get global variable OpSetGlobal = Opcode(23) // Set global variable OpSetSelGlobal = Opcode(24) // Set global variable using selectors OpGetLocal = Opcode(25) // Get local variable OpSetLocal = Opcode(26) // Set local variable OpDefineLocal = Opcode(27) // Define local variable OpSetSelLocal = Opcode(28) // Set local variable using selectors OpGetFreePtr = Opcode(29) // Get free variable pointer object OpGetFree = Opcode(30) // Get free variables OpSetFree = Opcode(31) // Set free variables OpGetLocalPtr = Opcode(32) // Get local variable as a pointer OpSetSelFree = Opcode(33) // Set free variables using selectors OpGetBuiltin = Opcode(34) // Get builtin function OpClosure = Opcode(35) // Push closure OpIteratorInit = Opcode(36) // Iterator init OpIteratorNext = Opcode(37) // Iterator next OpIteratorKey = Opcode(38) // Iterator key OpIteratorValue = Opcode(39) // Iterator value OpBinaryOp = Opcode(40) // Binary operation OpSuspend = Opcode(41) // Suspend VM OpSelect = Opcode(42) // Select operation OpMethodCall = Opcode(43) // Call method on object OpSliceIndexStep = Opcode(44) // Slice with step OpFormat = Opcode(45) // Format value with pre-parsed FormatSpec constant OpFormatDyn = Opcode(46) // Format value with runtime-built FormatSpec string popped from the stack OpDefer = Opcode(47) // Register deferred call: pop callee + N args, store on current frame OpDeferMethod = Opcode(48) // Register deferred method call: pop receiver + N args; method name from constants[methodIdx] )
List of opcodes
const KindUser = "user"
KindUser is the kind tag automatically assigned to errors constructed from script via the error() builtin.
Variables ¶
var ( // Value shortcuts True = BoolValue(true) False = BoolValue(false) Undefined = UndefinedValue() )
var OpcodeNames = [...]string{ OpConstant: "CONST", OpPop: "POP", OpTrue: "TRUE", OpFalse: "FALSE", OpBComplement: "NEG", OpEqual: "EQL", OpNotEqual: "NEQ", OpMinus: "NEG", OpLNot: "NOT", OpJumpFalsy: "JMPF", OpAndJump: "ANDJMP", OpOrJump: "ORJMP", OpJump: "JMP", OpNull: "NULL", OpGetGlobal: "GETG", OpSetGlobal: "SETG", OpSetSelGlobal: "SETSG", OpArray: "ARR", OpRecord: "RECORD", OpImmutable: "IMMUT", OpIndex: "INDEX", OpSliceIndex: "SLICE", OpCall: "CALL", OpSliceIndexStep: "SLICESTEP", OpReturn: "RET", OpGetLocal: "GETL", OpSetLocal: "SETL", OpDefineLocal: "DEFL", OpSetSelLocal: "SETSL", OpGetBuiltin: "BUILTIN", OpClosure: "CLOSURE", OpGetFreePtr: "GETFP", OpGetFree: "GETF", OpSetFree: "SETF", OpGetLocalPtr: "GETLP", OpSetSelFree: "SETSF", OpIteratorInit: "ITER", OpIteratorNext: "ITNXT", OpIteratorKey: "ITKEY", OpIteratorValue: "ITVAL", OpBinaryOp: "BINARYOP", OpSuspend: "SUSPEND", OpSelect: "SELECT", OpMethodCall: "MCALL", OpContains: "CONTAINS", OpFormat: "FMT", OpFormatDyn: "FMTDYN", OpDefer: "DEFER", OpDeferMethod: "DEFERM", }
OpcodeNames are string representation of opcodes.
var OpcodeOperands = [...][]int{ OpConstant: {2}, OpPop: {}, OpTrue: {}, OpFalse: {}, OpBComplement: {}, OpEqual: {}, OpNotEqual: {}, OpMinus: {}, OpLNot: {}, OpJumpFalsy: {4}, OpAndJump: {4}, OpOrJump: {4}, OpJump: {4}, OpNull: {}, OpGetGlobal: {2}, OpSetGlobal: {2}, OpSetSelGlobal: {2, 1}, OpArray: {2}, OpRecord: {2}, OpImmutable: {}, OpIndex: {}, OpSliceIndex: {}, OpCall: {1, 1}, OpSliceIndexStep: {}, OpReturn: {1}, OpGetLocal: {1}, OpSetLocal: {1}, OpDefineLocal: {1}, OpSetSelLocal: {1, 1}, OpGetBuiltin: {1}, OpClosure: {2, 1}, OpGetFreePtr: {1}, OpGetFree: {1}, OpSetFree: {1}, OpGetLocalPtr: {1}, OpSetSelFree: {1, 1}, OpIteratorInit: {}, OpIteratorNext: {}, OpIteratorKey: {}, OpIteratorValue: {}, OpBinaryOp: {1}, OpSuspend: {}, OpSelect: {}, OpMethodCall: {2, 1, 1}, OpContains: {}, OpFormat: {2}, OpFormatDyn: {}, OpDefer: {1}, OpDeferMethod: {2, 1}, }
OpcodeOperands is the number of operands.
var ValueTypeDefaults = ValueType{
Name: defaultTypeName,
String: defaultTypeString,
Format: defaultTypeFormat,
Interface: defaultTypeInterface,
EncodeJSON: defaultTypeEncodeJSON,
EncodeBinary: defaultTypeEncodeBinary,
DecodeBinary: defaultTypeDecodeBinary,
IsTrue: defaultFalse,
Copy: defaultSelf,
Equal: defaultTypeEqualPrimitive,
UnaryOp: defaultTypeUnaryOp,
BinaryOp: defaultTypeBinaryOp,
MethodCall: defaultTypeMethodCall,
IsIterable: defaultFalse,
Contains: defaultTypeContains,
Len: default0,
Iterator: defaultUndefined,
Access: defaultTypeAccess,
Assign: defaultTypeAssign,
Append: defaultTypeAppend,
Slice: defaultTypeSlice,
Delete: defaultTypeDelete,
SliceStep: defaultTypeSliceStep,
IsCallable: defaultFalse,
IsVariadic: defaultFalse,
Arity: defaultTypeArity,
Call: defaultTypeCall,
Next: defaultFalse,
Key: defaultUndefined,
Value: defaultUndefined,
AsBool: defaultTypeAsBool,
AsByte: defaultTypeAsByte,
AsRune: defaultTypeAsRune,
AsInt: defaultTypeAsInt,
AsFloat: defaultTypeAsFloat,
AsDecimal: defaultTypeAsDecimal,
AsTime: defaultTypeAsTime,
AsString: defaultTypeAsString,
AsRunes: defaultTypeAsRunes,
AsBytes: defaultTypeAsBytes,
AsArray: defaultTypeAsArray,
AsDict: defaultTypeAsDict,
}
var ValueTypes [256]ValueType
Functions ¶
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 ReadOperands ¶
ReadOperands reads operands from the bytecode.
func SetValueType ¶
Types ¶
type Arena ¶ added in v0.0.6
type Arena struct {
// contains filtered or unexported fields
}
func NewArena ¶ added in v0.0.6
func NewArena(opts *ArenaOptions) *Arena
NewArena creates a new Arena with the given options. If opts is nil, it uses the default options.
func (*Arena) NewArrayIteratorValue ¶ added in v0.0.6
func (*Arena) NewArrayValue ¶ added in v0.0.6
func (*Arena) NewBuiltinFunctionValue ¶ added in v0.0.6
func (*Arena) NewBytesIteratorValue ¶ added in v0.0.6
func (*Arena) NewBytesValue ¶ added in v0.0.6
func (*Arena) NewCompiledFunctionValue ¶ added in v0.0.6
func (*Arena) NewDecimal ¶ added in v0.0.6
func (*Arena) NewDictIteratorValue ¶ added in v0.0.8
func (*Arena) NewDictValue ¶ added in v0.0.8
func (*Arena) NewIntRangeIteratorValue ¶ added in v0.0.6
func (*Arena) NewIntRangeValue ¶ added in v0.0.6
func (*Arena) NewRecordValue ¶ added in v0.0.6
func (*Arena) NewRunesIteratorValue ¶ added in v0.0.6
func (*Arena) NewRunesValue ¶ added in v0.0.6
func (*Arena) NewStringValue ¶ added in v0.0.6
type ArenaOptions ¶ added in v0.0.6
type ArenaOptions struct {
Decimals int
Times int
BytesNum int
BytesCap int
RunesNum int
RunesCap int
ArraysNum int
ArraysCap int
BuiltinFunctions int
CompiledFunctions int
StringValues int
RunesValues int
BytesValues int
ArrayValues int
DictValues int
IntRangeValues int
RunesIterators int
BytesIterators int
ArrayIterators int
DictIterators int
IntRangeIterators int
Payload Resettable
}
func DefaultArenaOptions ¶ added in v0.0.6
func DefaultArenaOptions() *ArenaOptions
type ArrayIterator ¶
type ArrayIterator struct {
Elements []Value
// contains filtered or unexported fields
}
func (*ArrayIterator) Set ¶
func (i *ArrayIterator) Set(v []Value)
type BuiltinFunction ¶
type BuiltinFunction struct {
Func NativeFunc
Name string
Arity int8
Variadic bool
}
func (*BuiltinFunction) Set ¶
func (f *BuiltinFunction) Set(fn NativeFunc, name string, arity int8, variadic bool)
type BytesIterator ¶
type BytesIterator struct {
Elements []byte
// contains filtered or unexported fields
}
func (*BytesIterator) Set ¶
func (o *BytesIterator) Set(vals []byte)
type CompiledFunction ¶
type CompiledFunction struct {
Instructions []byte
Free []*Value
SourceMap map[int]Pos
NumLocals int // number of local variables (including function parameters)
NumParameters int8
VarArgs bool
NamedResult int8 // local-slot index of function's named result: 0 = no named result, N > 0 means slot N-1
}
func (*CompiledFunction) HasNamedResult ¶ added in v0.2.1
func (o *CompiledFunction) HasNamedResult() bool
HasNamedResult reports whether the function declares a named result.
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) 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 FormatSpecValue ¶ added in v0.1.3
type FormatSpecValue struct {
Spec fspec.FormatSpec
Text string // original mini-language text (without the leading ':')
}
FormatSpecValue 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.
type IntRangeIterator ¶
type IntRangeIterator struct {
// contains filtered or unexported fields
}
func (*IntRangeIterator) Set ¶
func (i *IntRangeIterator) Set(start, stop, step int64)
type Resettable ¶ added in v0.0.7
type Resettable interface {
Reset()
}
type RunesIterator ¶ added in v0.0.6
type RunesIterator struct {
Elements []rune
// contains filtered or unexported fields
}
func (*RunesIterator) Set ¶ added in v0.0.6
func (i *RunesIterator) Set(v []rune)
type VM ¶
type VM interface {
Allocator() *Arena // returns the arena allocator used by this VM
Abort() // aborts execution of the current script
IsStackEmpty() bool // returns true if there are no frames on the call stack
Call(*CompiledFunction, []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 ¶
func ArrayIteratorValue ¶
func ArrayIteratorValue(v *ArrayIterator) Value
func ArrayValue ¶
ArrayValue creates boxed array value.
func BuiltinFunctionValue ¶
func BuiltinFunctionValue(f *BuiltinFunction) Value
BuiltinFunctionValue creates new boxed builtin function value.
func BytesIteratorValue ¶
func BytesIteratorValue(v *BytesIterator) Value
func BytesValue ¶
BytesValue creates new boxed bytes value.
func CompiledFunctionValue ¶
func CompiledFunctionValue(f *CompiledFunction) Value
CompiledFunctionValue creates new boxed compiled function value.
func DecimalValue ¶
DecimalValue creates new boxed decimal value.
func DictIteratorValue ¶ added in v0.0.8
func DictIteratorValue(v *DictIterator) Value
func IntRangeIteratorValue ¶
func IntRangeIteratorValue(v *IntRangeIterator) Value
func IntRangeValue ¶
IntRangeValue creates boxed int-range value.
func NewArrayIteratorValue ¶
func NewArrayValue ¶
NewArrayValue creates a new (heap-allocated) array value.
func NewBuiltinFunctionValue ¶
func NewBuiltinFunctionValue(name string, fn NativeFunc, arity int8, variadic bool) Value
NewBuiltinFunctionValue creates new (heap-allocated) builtin function value.
func NewBytesIteratorValue ¶
func NewBytesValue ¶
NewBytesValue creates new (heap-allocated) bytes value.
func NewCompiledFunctionValue ¶
func NewCompiledFunctionValue(instructions []byte, free []*Value, sourceMap map[int]Pos, numLocals int, numParameters int8, varArgs bool) Value
NewCompiledFunctionValue creates new (heap-allocated) compiled function value.
func NewDecimalValue ¶
NewDecimalValue creates new (heap-allocated) boxed decimal value.
func NewDictIteratorValue ¶ added in v0.0.8
func NewDictValue ¶ added in v0.0.8
NewDictValue creates new (heap-allocated) dict value.
func NewErrorValue ¶
NewErrorValue creates a heap-allocated user-kind recoverable error value. Script-level errors are recoverable by default — the zero value of the Fatal flag (false) keeps user errors visible to deferred recover().
func NewFatalErrorValue ¶ added in v0.2.1
NewFatalErrorValue creates a heap-allocated user-kind fatal error value. A fatal error, when raised, bypasses recover() and stops the VM, propagating to the host caller.
func NewFormatSpecValue ¶ added in v0.1.3
func NewFormatSpecValue(spec fspec.FormatSpec, text string) Value
NewFormatSpecValue boxes a parsed FormatSpec for the constant pool.
func NewIntRangeValue ¶
NewIntRangeValue creates a new (heap-allocated) int-range value.
func NewRecordValue ¶
NewRecordValue creates new (heap-allocated) record value.
func NewRunesIteratorValue ¶ added in v0.0.6
func NewRunesValue ¶ added in v0.0.6
NewRunesValue creates new (heap-allocated) runes value.
func NewRuntimeErrorValue ¶ added in v0.2.1
NewRuntimeErrorValue creates a heap-allocated error value with explicit kind, fatality and a string message wrapped as the payload. Used internally by the runtime when boxing an *errs.Error so that script-level recover() can inspect it (and so the round-trip back to a Go *errs.Error preserves severity).
func NewStringValue ¶
NewStringValue creates new (heap-allocated) string value.
func NewTimeValue ¶
NewTimeValue creates new (heap-allocated) boxed time value.
func RecordValue ¶
RecordValue creates new boxed record value.
func RunesIteratorValue ¶ added in v0.0.6
func RunesIteratorValue(v *RunesIterator) Value
func RunesValue ¶ added in v0.0.6
RunesValue creates new boxed runes value.
func ValuePtrValue ¶
ValuePtrValue creates new boxed value pointer value.
func (*Value) DecodeBinary ¶
func (Value) EncodeBinary ¶
func (Value) EncodeJSON ¶
func (Value) IsCallable ¶
func (Value) IsImmutable ¶
func (Value) IsIterable ¶
func (Value) IsUserDefined ¶
func (Value) IsVariadic ¶
func (Value) MethodCall ¶
type ValueType ¶
type ValueType struct {
Name func(v Value) string
String func(v Value) string
Format func(v Value, sp fspec.FormatSpec) (string, error)
Interface func(v Value) any
EncodeJSON func(v Value) ([]byte, error)
EncodeBinary func(v Value) ([]byte, error)
DecodeBinary func(v *Value, data []byte) error
IsTrue func(v Value) bool
Copy func(v Value, a *Arena) (Value, error)
Equal func(v Value, r Value) bool
UnaryOp func(v Value, a *Arena, op token.Token) (Value, error)
BinaryOp func(v Value, a *Arena, op token.Token, r Value) (Value, error)
MethodCall func(v Value, vm VM, name string, args []Value) (Value, error)
IsIterable func(v Value) bool
Contains func(v Value, e Value) bool
Len func(v Value) int64
Iterator func(v Value, a *Arena) (Value, error)
Access func(v Value, a *Arena, index Value, mode Opcode) (Value, error)
Assign func(v Value, index Value, r Value) error
Append func(v Value, a *Arena, args []Value) (Value, error)
Slice func(v Value, a *Arena, s Value, e Value) (Value, error)
Delete func(v Value, key Value) (Value, error)
SliceStep func(v Value, a *Arena, s Value, e Value, step Value) (Value, error)
IsCallable func(v Value) bool
IsVariadic func(v Value) bool
Arity func(v Value) int8
Call func(v Value, vm VM, args []Value) (Value, error)
Next func(v Value) bool
Key func(v Value, a *Arena) (Value, error)
Value func(v Value, a *Arena) (Value, error)
AsBool func(v Value) (bool, bool)
AsByte func(v Value) (byte, bool)
AsRune func(v Value) (rune, bool)
AsInt func(v Value) (int64, bool)
AsFloat func(v Value) (float64, bool)
AsDecimal func(v Value) (dec128.Dec128, bool)
AsTime func(v Value) (time.Time, bool)
AsString func(v Value) (string, bool)
AsRunes func(v Value) ([]rune, bool)
AsBytes func(v Value) ([]byte, bool)
AsArray func(v Value, a *Arena) ([]Value, bool)
AsDict func(v Value, a *Arena) (map[string]Value, bool)
}
Source Files
¶
- arena.go
- array.go
- array_iterator.go
- bool.go
- builtin_function.go
- byte.go
- bytes.go
- bytes_iterator.go
- compiled_function.go
- decimal.go
- dict_iterator.go
- dict_record.go
- error.go
- float.go
- format_spec.go
- init.go
- int.go
- int_range.go
- int_range_iterator.go
- rune.go
- runes.go
- runes_iterator.go
- string.go
- time.go
- tools.go
- types.go
- undefined.go
- value.go
- value_ptr.go