Documentation
¶
Overview ¶
Code generated by 'go generate'; DO NOT EDIT.
Index ¶
- Constants
- Variables
- func ArrayRepr(typName string, vm *VM, len int, get func(i int) Object) (_ string, err error)
- func ArrayToString(len int, get func(i int) Object) string
- func BuiltinAddCallMethodFunc(vm *VM, fn CallerObject, handler CallerObject, override bool) (err error)
- func Callable(o Object) (ok bool)
- func CloserFrom(o Object) (r io.Closer)
- func Copy[T Object](o T) T
- func DeepCopy[T Object](vm *VM, o T) (_ T, err error)
- func Filterable(obj Object) bool
- func FormatInstructions(b []byte, posOffset int) []string
- func IsIndexDeleter(obj Object) (ok bool)
- func IsIndexGetter(obj Object) (ok bool)
- func IsIndexSetter(obj Object) (ok bool)
- func IsIterator(obj Object) bool
- func IsNil(value any) bool
- func IsObjector(obj Object) (ok bool)
- func IsPrimitive(obj Object) bool
- func IsType(obj Object) (ok bool)
- func IsTypeAssignableTo(a, b ObjectType) bool
- func IsZero(value interface{}) bool
- func ItemsOfCb(vm *VM, na *NamedArgs, cb func(kv *KeyValue) error, o ...Object) (err error)
- func Iterable(vm *VM, obj Object) bool
- func Iterate(vm *VM, it Iterator, init func(state *IteratorState) error, ...) (err error)
- func IterateInstructions(insts []byte, fn func(pos int, opcode Opcode, operands []int, offset int) bool)
- func IterateObject(vm *VM, o Object, na *NamedArgs, init func(state *IteratorState) error, ...) (err error)
- func IteratorStateCheck(vm *VM, it Iterator, state *IteratorState) (err error)
- func MakeInstruction(buf []byte, op Opcode, args ...int) ([]byte, error)
- func Mapable(obj Object) bool
- func NamedParamTypeCheck(name string, typeso, value Object) (badTypes string, err error)
- func NamedParamTypeCheckAssertion(name string, assertion *TypeAssertion, value Object) (err error)
- func NewArgCaller(vm *VM, co CallerObject, args Array, namedArgs NamedArgs) func() (ret Object, err error)
- func ObjectsReprW(w io.Writer, vm *VM, len int, get func(i int) Object) (err error)
- func ObjectsStrW(w io.Writer, vm *VM, len int, get func(i int) Object) (err error)
- func Print(state *PrinterState, o ...Object) (err error)
- func PrintArray(state *PrinterState, l int, get func(i int) (Object, error)) (err error)
- func PrintDict(state *PrinterState, l int, key, value func(i int) (Object, error)) (err error)
- func PrintPairs(state *PrinterState, l int, open, close, keySep, itemSep []byte, ...) (err error)
- func PrintStateOptionsGetAnonymous(s *PrinterState) bool
- func PrintStateOptionsGetIndexes(s *PrinterState) bool
- func PrintStateOptionsGetZeros(s *PrinterState) bool
- func PrintValues(state *PrinterState, l int, open, close, itemSep []byte, ...) (err error)
- func ReadOperands(numOperands []int, ins []byte, operands []int) ([]int, int)
- func Readable(o Object) (ok bool)
- func Reducable(obj Object) bool
- func TestBytecodesEqual(t *testing.T, expected, got *Bytecode, checkSourceMap bool)
- func ToCode(o Object) string
- func ToGoBool(o Object) (v bool, ok bool)
- func ToGoByteSlice(o Object) (v []byte, ok bool)
- func ToGoFloat64(o Object) (v float64, ok bool)
- func ToGoInt(o Object) (v int, ok bool)
- func ToGoInt64(o Object) (v int64, ok bool)
- func ToGoRune(o Object) (v rune, ok bool)
- func ToGoString(o Object) (v string, ok bool)
- func ToGoUint64(o Object) (v uint64, ok bool)
- func ToInterface(o Object) (ret any)
- func ToRawStrW(w io.Writer, vm *VM, o Object) (err error)
- func ToReprTypedRS(vm *VM, typ ObjectType, o any) (s string, err error)
- func ToReprTypedS(vm *VM, typ ObjectType, o Object) (_ string, err error)
- func ToStrW(w io.Writer, vm *VM, o Object) (err error)
- func ToWritable(obj Object) bool
- func TranspileOptions() *node.TranspileOptions
- func TypeToString(typeName string) string
- func WithArgs(args ...Object) func(c *Call)
- func WithArgsV(args []Object, vargs ...Object) func(c *Call)
- func WithNamedArgs(na *NamedArgs) func(c *Call)
- func WrapIterator(iterator Iterator, wrap func(state *IteratorState) error) *wrapIterator
- func Writeable(o Object) (ok bool)
- type Adder
- type Appender
- type Arg
- type ArgType
- type ArgValue
- type Args
- func (o Args) Array() (ret Array)
- func (o Args) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o Args) CheckLen(n int) error
- func (o Args) CheckMaxLen(n int) error
- func (o Args) CheckMinLen(n int) error
- func (o Args) CheckRangeLen(min, max int) error
- func (o Args) Copy() Object
- func (o Args) DeepCopy(vm *VM) (r Object, err error)
- func (o Args) Destructure(dst ...*Arg) (err error)
- func (o Args) DestructureTo(dst ...ArgValue) (err error)
- func (o Args) DestructureValue(dst ...*Arg) (err error)
- func (o Args) DestructureVar(dst ...*Arg) (other Array, err error)
- func (o Args) Equal(right Object) (ok bool)
- func (o Args) Get(n int) (v Object)
- func (o Args) GetDefault(n int, defaul Object) (v Object)
- func (o Args) GetIJ(n int) (i, j int, ok bool)
- func (o Args) GetOnly(n int) Object
- func (o Args) IndexGet(_ *VM, index Object) (Object, error)
- func (o Args) IsFalsy() bool
- func (o Args) Items(_ *VM, cb ItemsGetterCallback) (err error)
- func (o Args) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o Args) Length() (l int)
- func (o Args) MustGet(n int) Object
- func (o *Args) Prepend(items ...Object)
- func (o *Args) Shift() (v Object)
- func (o Args) ShiftArg(shifts *int, dst *Arg) (ok bool, err error)
- func (o *Args) ShiftOk() (Object, bool)
- func (o Args) ToString() string
- func (o Args) Type() ObjectType
- func (o Args) Types() (types []ObjectType)
- func (o Args) Values() (ret Array)
- func (o Args) Walk(cb func(i int, arg Object) any) (v any)
- func (o Args) WalkE(cb func(i int, arg Object) error) (err error)
- func (o Args) WalkSkip(skip int, cb func(i int, arg Object) any) (v any)
- type Array
- func CollectCb(vm *VM, o Object, na *NamedArgs, cb func(e *KeyValue, i *Int) Object) (values Array, err error)
- func ConvertToArray(vm *VM, o ...Object) (ret Array, err error)
- func MustConvertToArray(vm *VM, o ...Object) Array
- func ToArray(o Object) (v Array, ok bool)
- func ValuesOf(vm *VM, o Object, na *NamedArgs) (values Array, err error)
- func (o *Array) Append(_ *VM, items ...Object) error
- func (o Array) AppendObjects(_ *VM, items ...Object) (Object, error)
- func (o Array) AppendToArray(arr Array) Array
- func (o Array) BinaryOp(vm *VM, tok token.Token, right Object) (_ Object, err error)
- func (o Array) Copy() Object
- func (o Array) DeepCopy(vm *VM) (_ Object, err error)
- func (o Array) Equal(right Object) bool
- func (o Array) Format(f fmt.State, verb rune)
- func (o Array) IndexGet(_ *VM, index Object) (Object, error)
- func (o Array) IndexSet(_ *VM, index, value Object) error
- func (o Array) IsFalsy() bool
- func (o Array) Items(_ *VM, cb ItemsGetterCallback) (err error)
- func (o Array) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o Array) Keys() (arr Array)
- func (o Array) Length() int
- func (o Array) Print(state *PrinterState) (err error)
- func (o Array) Repr(vm *VM) (string, error)
- func (o Array) SelfAssignOp(vm *VM, tok token.Token, right Object) (ret Object, handled bool, err error)
- func (o Array) Sort(vm *VM, less CallerObject) (_ Object, err error)
- func (o Array) SortReverse(vm *VM) (_ Object, err error)
- func (o Array) ToAnyArray(vm *VM) []any
- func (o Array) ToInterface(vm *VM) any
- func (o Array) ToString() string
- func (o Array) Type() ObjectType
- type BinaryOperatorHandler
- type BinaryOperatorType
- func (BinaryOperatorType) Call(Call) (Object, error)
- func (b BinaryOperatorType) Equal(right Object) bool
- func (BinaryOperatorType) Fields() Dict
- func (BinaryOperatorType) Getters() Dict
- func (BinaryOperatorType) IsChildOf(t ObjectType) bool
- func (b BinaryOperatorType) IsFalsy() bool
- func (BinaryOperatorType) Methods() Dict
- func (BinaryOperatorType) MethodsDisabled() bool
- func (b BinaryOperatorType) Name() string
- func (BinaryOperatorType) New(*VM, Dict) (Object, error)
- func (BinaryOperatorType) Setters() Dict
- func (b BinaryOperatorType) String() string
- func (b BinaryOperatorType) ToString() string
- func (b BinaryOperatorType) Token() token.Token
- func (b BinaryOperatorType) Type() ObjectType
- type Bool
- type Buffer
- func (o *Buffer) CallName(name string, c Call) (Object, error)
- func (o *Buffer) Equal(right Object) bool
- func (o *Buffer) GoReader() io.Reader
- func (o *Buffer) GoWriter() io.Writer
- func (o *Buffer) IndexGet(_ *VM, index Object) (Object, error)
- func (o *Buffer) IndexSet(_ *VM, index, value Object) error
- func (o *Buffer) IsFalsy() bool
- func (o *Buffer) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o *Buffer) Length() int
- func (o *Buffer) ToBytes() (Bytes, error)
- func (o *Buffer) ToString() string
- func (o *Buffer) Type() ObjectType
- type BuiltinFunction
- func (o *BuiltinFunction) Call(c Call) (Object, error)
- func (o *BuiltinFunction) Copy() Object
- func (o *BuiltinFunction) Equal(right Object) bool
- func (o *BuiltinFunction) GetGoMethods() []*Caller
- func (*BuiltinFunction) IsFalsy() bool
- func (o *BuiltinFunction) MethodsDisabled() bool
- func (o *BuiltinFunction) ParamTypes(*VM) (MultipleObjectTypes, error)
- func (o *BuiltinFunction) ToString() string
- func (*BuiltinFunction) Type() ObjectType
- func (o *BuiltinFunction) WithGoMethod(c ...*Caller) *BuiltinFunction
- type BuiltinModule
- type BuiltinObjType
- func (b *BuiltinObjType) Call(c Call) (Object, error)
- func (b *BuiltinObjType) Equal(right Object) bool
- func (b *BuiltinObjType) Fields() Dict
- func (b *BuiltinObjType) Getters() Dict
- func (b *BuiltinObjType) IsChildOf(t ObjectType) bool
- func (b *BuiltinObjType) IsFalsy() bool
- func (b *BuiltinObjType) Methods() Dict
- func (b *BuiltinObjType) Name() string
- func (b *BuiltinObjType) New(*VM, Dict) (Object, error)
- func (b *BuiltinObjType) Setters() Dict
- func (b *BuiltinObjType) String() string
- func (b *BuiltinObjType) ToString() string
- func (b *BuiltinObjType) Type() ObjectType
- type BuiltinObjectsMap
- type BuiltinType
- type Builtins
- func (s *Builtins) AppendMap(m map[string]Object)
- func (s *Builtins) ArgsInvoker(t BuiltinType, c Call) func(arg ...Object) (Object, error)
- func (s *Builtins) Call(t BuiltinType, c Call) (Object, error)
- func (s *Builtins) Caller(t BuiltinType) CallerObject
- func (s *Builtins) Get(t BuiltinType) Object
- func (s *Builtins) Invoker(t BuiltinType, c Call) func() (Object, error)
- func (s *Builtins) Set(name string, obj Object) *Builtins
- func (s *Builtins) SetType(typ ObjectType) *Builtins
- type Bytecode
- type Bytes
- func (o Bytes) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o Bytes) Copy() Object
- func (o Bytes) Equal(right Object) bool
- func (o Bytes) Format(s fmt.State, verb rune)
- func (o Bytes) IndexGet(_ *VM, index Object) (Object, error)
- func (o Bytes) IndexSet(_ *VM, index, value Object) error
- func (o Bytes) IsFalsy() bool
- func (o Bytes) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o Bytes) Length() int
- func (o Bytes) ToString() string
- func (o Bytes) Type() ObjectType
- func (o Bytes) WriteTo(_ *VM, w io.Writer) (int64, error)
- type BytesConverter
- type Call
- type CallOpt
- type CallWrapper
- type CallableFunc
- type Caller
- type CallerMethod
- type CallerMethodDefinition
- type CallerObject
- type CallerObjectWithMethods
- func AddCallerMethod(vm *VM, dst CallerObject, methods ...CallerMethodDefinition) (_ *CallerObjectWithMethods, err error)
- func MustAddCallerMethod(vm *VM, dst CallerObject, methods ...CallerMethodDefinition) (co *CallerObjectWithMethods)
- func NewCallerObjectWithMethods(callerObject CallerObject) *CallerObjectWithMethods
- func NewTypedFunction(fn *Function, types MultipleObjectTypes) *CallerObjectWithMethods
- func (o *CallerObjectWithMethods) AddCallerMethod(vm *VM, argTypes MultipleObjectTypes, handler CallerObject, override bool) error
- func (o *CallerObjectWithMethods) Call(c Call) (Object, error)
- func (o *CallerObjectWithMethods) Caller() CallerObject
- func (o *CallerObjectWithMethods) CallerMethodOfArgs(args Args) (co CallerObject)
- func (o *CallerObjectWithMethods) CallerMethodOfArgsTypes(types []ObjectType) (co CallerObject)
- func (o *CallerObjectWithMethods) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
- func (o *CallerObjectWithMethods) CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (co CallerObject, validate bool)
- func (o *CallerObjectWithMethods) CallerMethods() *MethodArgType
- func (o *CallerObjectWithMethods) Equal(right Object) bool
- func (o *CallerObjectWithMethods) HasCallerMethods() bool
- func (o *CallerObjectWithMethods) MethodWalk(cb func(m *CallerMethod) any) (v any)
- func (o *CallerObjectWithMethods) MethodWalkSorted(cb func(m *CallerMethod) any) (v any)
- func (o *CallerObjectWithMethods) RegisterDefaultWithTypes(types MultipleObjectTypes) *CallerObjectWithMethods
- func (o *CallerObjectWithMethods) String() string
- func (o *CallerObjectWithMethods) ToString() string
- type CallerObjectWithParamTypes
- type CallerObjectWithStaticMethods
- type CallerOption
- type CanCallerObject
- type CanCallerObjectMethodsEnabler
- type CanCallerObjectTypesValidation
- type CanCloser
- type CanFilterabler
- type CanIterabler
- type CanIterationDoner
- type CanMapeabler
- type CanReducer
- type CanToWriter
- type Char
- type CollectableIterator
- type CompilableImporter
- type CompileOptions
- type CompileStack
- type CompiledFunction
- func (o *CompiledFunction) Call(c Call) (Object, error)
- func (o *CompiledFunction) CanValidateParamTypes() bool
- func (o CompiledFunction) ClearSourceFileInfo() *CompiledFunction
- func (o *CompiledFunction) Copy() Object
- func (o *CompiledFunction) Equal(right Object) bool
- func (o *CompiledFunction) Format(f fmt.State, verb rune)
- func (o *CompiledFunction) Fprint(w io.Writer)
- func (o *CompiledFunction) FprintLP(linePrefix string, w io.Writer)
- func (*CompiledFunction) IsFalsy() bool
- func (o *CompiledFunction) ParamTypes(vm *VM) (types MultipleObjectTypes, err error)
- func (o *CompiledFunction) Repr(*VM) (_ string, err error)
- func (o *CompiledFunction) SetNamedParams(params ...*NamedParam)
- func (o *CompiledFunction) SourcePos(ip int) source.Pos
- func (o *CompiledFunction) ToString() string
- func (*CompiledFunction) Type() ObjectType
- func (o *CompiledFunction) ValidateParamTypes(vm *VM, args Args) (err error)
- func (o *CompiledFunction) WithParams(names ...string) *CompiledFunction
- type Compiler
- func (c *Compiler) BaseEmbedMap() *EmbedMap
- func (c *Compiler) BaseModuleMap() *ModuleMap
- func (c *Compiler) Bytecode() *Bytecode
- func (c *Compiler) Compile(nd ast.Node) error
- func (c *Compiler) CompileModule(nd ast.Node, module *ModuleInfo, moduleMap *ModuleMap, src []byte, ...) (bc *Bytecode, err error)
- func (c *Compiler) SetGlobalSymbolsIndex()
- type CompilerError
- type CompilerOptions
- type Copier
- type Decimal
- func (o Decimal) BinaryOp(vm *VM, tok token.Token, right Object) (Object, error)
- func (o Decimal) CallName(name string, c Call) (_ Object, err error)
- func (o Decimal) Equal(right Object) bool
- func (o Decimal) Format(s fmt.State, verb rune)
- func (o *Decimal) GobDecode(bytes []byte) (err error)
- func (o Decimal) GobEncode() ([]byte, error)
- func (o Decimal) IsFalsy() bool
- func (o Decimal) ToBytes() (b Bytes, err error)
- func (o Decimal) ToGo() decimal.Decimal
- func (o Decimal) ToInterface() any
- func (o Decimal) ToString() string
- func (o Decimal) Type() ObjectType
- type DeepCopier
- type Dict
- func (o Dict) Backup(key string) func()
- func (o Dict) BinaryOp(vm *VM, tok token.Token, right Object) (_ Object, err error)
- func (o Dict) Copy() Object
- func (o Dict) DeepCopy(vm *VM) (_ Object, err error)
- func (o Dict) Equal(right Object) bool
- func (o Dict) Filter(f func(k string, v Object) bool) Dict
- func (o Dict) Format(f fmt.State, verb rune)
- func (o Dict) Get(key string) (r Object)
- func (o Dict) IndexDelete(_ *VM, key Object) error
- func (o Dict) IndexGet(_ *VM, index Object) (Object, error)
- func (o Dict) IndexSet(_ *VM, index, value Object) error
- func (o Dict) IsFalsy() bool
- func (o Dict) Items(_ *VM, cb ItemsGetterCallback) (err error)
- func (o Dict) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o Dict) Keys() Array
- func (o Dict) Length() int
- func (o Dict) Print(state *PrinterState) (err error)
- func (o Dict) Repr(vm *VM) (_ string, err error)
- func (o *Dict) Set(key string, value Object)
- func (o Dict) SortedKeys() Array
- func (o Dict) ToInterface(vm *VM) any
- func (o Dict) ToInterfaceMap(vm *VM) (m map[string]any)
- func (o Dict) ToNamedArgs() *NamedArgs
- func (o Dict) ToString() string
- func (o Dict) Type() ObjectType
- func (o Dict) Values() Array
- type EmbedMap
- func (m *EmbedMap) Add(name string, module Importable) *EmbedMap
- func (m *EmbedMap) AddFile(path string, src []byte) *EmbedMap
- func (m *EmbedMap) Copy() *EmbedMap
- func (m *EmbedMap) Get(name string) Importable
- func (m *EmbedMap) Remove(name string)
- func (m *EmbedMap) SetExtImporter(im ExtImporter) *EmbedMap
- type EmbededFileData
- type Error
- func IsError(a, b error) *Error
- func NewArgumentTypeError(pos, expectType, foundType string) *Error
- func NewArgumentTypeErrorT(pos string, foundType ObjectType, expectType ...ObjectType) *Error
- func NewIndexTypeError(expectType, foundType string) *Error
- func NewIndexTypeErrorT(foundType ObjectType, expectType ...ObjectType) *Error
- func NewIndexValueTypeError(expectType, foundType string) *Error
- func NewIndexValueTypeErrorT(foundType ObjectType, expectType ...ObjectType) *Error
- func NewNamedArgumentTypeError(name, expectType, foundType string) *Error
- func NewOperandTypeError(token, leftType, rightType string) *Error
- func WrapError(cause error) *Error
- func (o *Error) Copy() Object
- func (o *Error) Equal(right Object) bool
- func (o *Error) Error() string
- func (o *Error) IndexGet(_ *VM, index Object) (Object, error)
- func (o *Error) IsFalsy() bool
- func (o *Error) NewError(messages ...string) *Error
- func (o *Error) ToString() string
- func (o *Error) Type() ObjectType
- func (o *Error) Unwrap() error
- type ErrorHumanizing
- type Eval
- type ExtImporter
- type Falser
- type Filterabler
- type Flag
- type Float
- type Function
- type FunctionHeader
- type FunctionHeaderParam
- type Importable
- type IndexDelProxy
- type IndexDeleteProxy
- type IndexDeleter
- type IndexGetProxy
- func (i *IndexGetProxy) CallName(name string, c Call) (Object, error)
- func (i *IndexGetProxy) CanIterate() bool
- func (i *IndexGetProxy) Equal(right Object) bool
- func (i IndexGetProxy) IndexGet(vm *VM, index Object) (value Object, err error)
- func (i *IndexGetProxy) IsFalsy() bool
- func (i *IndexGetProxy) Iterate(vm *VM, na *NamedArgs) Iterator
- func (i *IndexGetProxy) ToInterface() any
- func (i *IndexGetProxy) ToString() string
- func (i *IndexGetProxy) Type() ObjectType
- type IndexGetSetter
- type IndexGetter
- type IndexProxy
- type IndexSetProxy
- type IndexSetter
- type IndexableStructField
- type Indexer
- type Int
- type Invoker
- func (inv *Invoker) Acquire()
- func (inv *Invoker) Caller(args Args, namedArgs *NamedArgs) (VMCaller, error)
- func (inv *Invoker) Invoke(args Args, namedArgs *NamedArgs) (Object, error)
- func (inv *Invoker) Prepare(f func(vm *VM))
- func (inv *Invoker) PrepareHandlers() []func(vm *VM)
- func (inv *Invoker) Release()
- func (inv *Invoker) ValidArgs(v bool) *Invoker
- type ItemsGetter
- type ItemsGetterCallback
- type Iterabler
- type Iteration
- func (it *Iteration) Input() Object
- func (it *Iteration) ItType() ObjectType
- func (it *Iteration) Next(vm *VM, state *IteratorState) (err error)
- func (it *Iteration) Repr(vm *VM) (string, error)
- func (it *Iteration) SetInput(input Object) *Iteration
- func (it *Iteration) SetItType(itType ObjectType) *Iteration
- func (it *Iteration) Start(vm *VM) (state *IteratorState, err error)
- func (it *Iteration) Type() ObjectType
- type IterationDoner
- type Iterator
- type IteratorState
- type IteratorStateCollectMode
- type IteratorStateMode
- type KeyValue
- func (o *KeyValue) BinaryOp(vm *VM, tok token.Token, right Object) (Object, error)
- func (KeyValue) Call(*NamedArgs, ...Object) (Object, error)
- func (KeyValue) CanCall() bool
- func (KeyValue) CanIterate() bool
- func (o KeyValue) Copy() Object
- func (o KeyValue) DeepCopy(vm *VM) (_ Object, err error)
- func (o *KeyValue) Equal(right Object) bool
- func (o *KeyValue) IndexGet(vm *VM, index Object) (value Object, err error)
- func (o *KeyValue) IndexSet(vm *VM, index, value Object) error
- func (o *KeyValue) IsFalsy() bool
- func (o *KeyValue) IsLess(vm *VM, other *KeyValue) bool
- func (o *KeyValue) Print(state *PrinterState) (err error)
- func (o *KeyValue) Repr(vm *VM) (_ string, err error)
- func (o *KeyValue) ToString() string
- func (o *KeyValue) Type() ObjectType
- type KeyValueArray
- func (o KeyValueArray) AddItems(arg ...*KeyValue) KeyValueArray
- func (o *KeyValueArray) Append(vm *VM, items ...Object) (err error)
- func (o KeyValueArray) AppendArray(arr ...Array) (KeyValueArray, error)
- func (o KeyValueArray) AppendMap(m Dict) KeyValueArray
- func (o KeyValueArray) AppendObjects(vm *VM, items ...Object) (this Object, err error)
- func (o KeyValueArray) BinaryOp(vm *VM, tok token.Token, right Object) (Object, error)
- func (KeyValueArray) Call(*NamedArgs, ...Object) (Object, error)
- func (o KeyValueArray) CallName(name string, c Call) (_ Object, err error)
- func (KeyValueArray) CanCall() bool
- func (KeyValueArray) CanIterate() bool
- func (o KeyValueArray) Copy() Object
- func (o KeyValueArray) DeepCopy(vm *VM) (r Object, err error)
- func (o KeyValueArray) Delete(keys ...Object) Object
- func (o KeyValueArray) Equal(right Object) bool
- func (o KeyValueArray) Get(keys ...Object) Object
- func (o KeyValueArray) IndexGet(_ *VM, index Object) (Object, error)
- func (o KeyValueArray) IsFalsy() bool
- func (o KeyValueArray) Items(_ *VM, cb ItemsGetterCallback) (err error)
- func (o KeyValueArray) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o KeyValueArray) Keys() (arr Array)
- func (o KeyValueArray) Length() int
- func (o KeyValueArray) Print(state *PrinterState) (err error)
- func (o KeyValueArray) Repr(vm *VM) (_ string, err error)
- func (o KeyValueArray) Sort(vm *VM, less CallerObject) (_ Object, err error)
- func (o KeyValueArray) SortReverse(vm *VM) (Object, error)
- func (o KeyValueArray) ToDict(out Dict) Dict
- func (o KeyValueArray) ToString() string
- func (o KeyValueArray) Type() ObjectType
- func (o KeyValueArray) Values() (arr Array)
- type KeyValueArrays
- func (o KeyValueArrays) Array() (ret Array)
- func (o KeyValueArrays) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o KeyValueArrays) CallName(name string, c Call) (Object, error)
- func (o KeyValueArrays) Copy() Object
- func (o KeyValueArrays) DeepCopy(vm *VM) (_ Object, err error)
- func (o KeyValueArrays) Equal(right Object) bool
- func (o KeyValueArrays) IndexGet(_ *VM, index Object) (Object, error)
- func (o KeyValueArrays) IsFalsy() bool
- func (o KeyValueArrays) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o KeyValueArrays) Length() int
- func (o KeyValueArrays) Print(state *PrinterState) (err error)
- func (o KeyValueArrays) Repr(vm *VM) (_ string, err error)
- func (o KeyValueArrays) ToString() string
- func (KeyValueArrays) Type() ObjectType
- type KeysGetter
- type LengthGetter
- type LengthIterator
- type LimitedIterator
- type Mapabler
- type MethodArgType
- func (at *MethodArgType) Add(types MultipleObjectTypes, m *CallerMethod, override bool) error
- func (at *MethodArgType) GetMethod(types []ObjectType) *CallerMethod
- func (at *MethodArgType) IsZero() (ok bool)
- func (at *MethodArgType) Walk(cb func(m *CallerMethod) any) (v any)
- func (at *MethodArgType) WalkSorted(cb func(m *CallerMethod) any) (v any)
- type MethodCaller
- type MethodDefinition
- type Methods
- func (args Methods) Add(pth, types ObjectTypes, cm *CallerMethod, override bool) (err error)
- func (args Methods) GetMethod(types []ObjectType) (cm *CallerMethod)
- func (args Methods) IsZero() (ok bool)
- func (args Methods) Walk(cb func(m *CallerMethod) any) (rv any)
- func (args Methods) WalkSorted(cb func(m *CallerMethod) any) (rv any)
- type MixedParams
- func (m *MixedParams) Dict() Dict
- func (m *MixedParams) Equal(right Object) bool
- func (m *MixedParams) IndexGet(vm *VM, index Object) (value Object, err error)
- func (m *MixedParams) IsFalsy() bool
- func (m *MixedParams) Repr(vm *VM) (s string, err error)
- func (m *MixedParams) ToDict(d Dict) Dict
- func (m *MixedParams) ToString() string
- func (m *MixedParams) Type() ObjectType
- type ModuleInfo
- type ModuleMap
- func (m *ModuleMap) Add(name string, module Importable) *ModuleMap
- func (m *ModuleMap) AddBuiltinModule(name string, attrs map[string]Object) *ModuleMap
- func (m *ModuleMap) AddSourceModule(name string, src []byte) *ModuleMap
- func (m *ModuleMap) Copy() *ModuleMap
- func (m *ModuleMap) Fork(moduleName string) *ModuleMap
- func (m *ModuleMap) Get(name string) Importable
- func (m *ModuleMap) Remove(name string)
- func (m *ModuleMap) SetExtImporter(im ExtImporter) *ModuleMap
- type MultipleObjectTypes
- type NameCallerObject
- type NamedArgVar
- type NamedArgs
- func (o *NamedArgs) Add(obj Object) (err error)
- func (o *NamedArgs) AllDict() (ret Dict)
- func (o *NamedArgs) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o *NamedArgs) Call(c Call) (Object, error)
- func (o *NamedArgs) CallName(name string, c Call) (Object, error)
- func (o *NamedArgs) CheckNames(accept ...string) error
- func (o *NamedArgs) CheckNamesFromSet(set map[string]int) error
- func (o *NamedArgs) Contains(key string) bool
- func (o *NamedArgs) Copy() Object
- func (o NamedArgs) DeepCopy(vm *VM) (_ Object, err error)
- func (o *NamedArgs) Dict() (ret Dict)
- func (o *NamedArgs) Empty() bool
- func (o *NamedArgs) Equal(right Object) bool
- func (o *NamedArgs) Get(dst ...*NamedArgVar) (err error)
- func (o *NamedArgs) GetOne(dst ...*NamedArgVar) (err error)
- func (o *NamedArgs) GetPassedValue(key string) (val Object)
- func (o *NamedArgs) GetValue(key string) (val Object)
- func (o *NamedArgs) GetValueOrNil(key string) (val Object)
- func (o *NamedArgs) GetVar(dst ...*NamedArgVar) (args Dict, err error)
- func (o *NamedArgs) IndexGet(vm *VM, index Object) (value Object, err error)
- func (o *NamedArgs) IsFalsy() bool
- func (o *NamedArgs) Items(_ *VM, cb ItemsGetterCallback) (err error)
- func (o *NamedArgs) Iterate(vm *VM, na *NamedArgs) Iterator
- func (o *NamedArgs) Join() KeyValueArray
- func (o *NamedArgs) MustGetValue(key string) (val Object)
- func (o *NamedArgs) MustGetValueOrNil(key string) (val Object)
- func (o *NamedArgs) Ready() (arr KeyValueArray)
- func (o *NamedArgs) ToString() string
- func (o *NamedArgs) Type() ObjectType
- func (o *NamedArgs) UnReady() *NamedArgs
- func (o *NamedArgs) UnreadPairs() (ret KeyValueArray)
- func (o *NamedArgs) Walk(cb func(na *KeyValue) error) (err error)
- type NamedParam
- type NamedParams
- type NextIterationHandler
- type NilType
- type Niler
- type Obj
- func (o *Obj) CallName(name string, c Call) (_ Object, err error)
- func (o *Obj) CastTo(vm *VM, t ObjectType) (Object, error)
- func (o Obj) Copy() Object
- func (o Obj) DeepCopy(vm *VM) (r Object, err error)
- func (o *Obj) Equal(right Object) bool
- func (o *Obj) Fields() Dict
- func (o *Obj) IndexDelete(_ *VM, key Object) error
- func (o *Obj) IndexGet(vm *VM, index Object) (Object, error)
- func (o *Obj) IndexSet(vm *VM, index, value Object) (err error)
- func (o *Obj) IsFalsy() bool
- func (o *Obj) Items(vm *VM, cb ItemsGetterCallback) (err error)
- func (o *Obj) Keys() Array
- func (o *Obj) Length() int
- func (o *Obj) Methods() *IndexGetProxy
- func (o *Obj) ToString() string
- func (o *Obj) Type() ObjectType
- func (o *Obj) Values() Array
- type ObjType
- func (o *ObjType) AddCallerMethod(vm *VM, types MultipleObjectTypes, handler CallerObject, override bool) error
- func (o *ObjType) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o *ObjType) Call(c Call) (_ Object, err error)
- func (o *ObjType) CallName(name string, c Call) (ret Object, err error)
- func (o *ObjType) Caller() CallerObject
- func (o *ObjType) CallerMethodOfArgs(args Args) (co CallerObject)
- func (o *ObjType) CallerMethodOfArgsTypes(types []ObjectType) (co CallerObject)
- func (o *ObjType) CallerMethodWithValidationCheckOfArgs(args Args) (co CallerObject, ok bool)
- func (o *ObjType) CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (co CallerObject, validate bool)
- func (o *ObjType) CallerMethods() *MethodArgType
- func (o *ObjType) Equal(right Object) bool
- func (o *ObjType) Fields() Dict
- func (o *ObjType) Format(f fmt.State, verb rune)
- func (o *ObjType) Getters() Dict
- func (o *ObjType) HasCallerMethods() bool
- func (o *ObjType) IndexGet(_ *VM, index Object) (value Object, err error)
- func (o *ObjType) IsChildOf(t ObjectType) bool
- func (ObjType) IsFalsy() bool
- func (o *ObjType) Methods() Dict
- func (o *ObjType) Name() string
- func (o *ObjType) New(_ *VM, fields Dict) (Object, error)
- func (o *ObjType) NewCall(c Call) (Object, error)
- func (o *ObjType) Setters() Dict
- func (o *ObjType) String() string
- func (o *ObjType) ToString() string
- func (o *ObjType) Type() ObjectType
- type Object
- func BuiltinAppendFunc(c Call) (Object, error)
- func BuiltinBinaryOperatorFunc(c Call) (ret Object, err error)
- func BuiltinCapFunc(arg Object) Object
- func BuiltinCastFunc(c Call) (ret Object, err error)
- func BuiltinCharsFunc(arg Object) (ret Object, err error)
- func BuiltinCloseFunc(c Call) (ret Object, err error)
- func BuiltinCollectFunc(c Call) (_ Object, err error)
- func BuiltinContainsFunc(arg0, arg1 Object) (Object, error)
- func BuiltinCopyFunc(c Call) (_ Object, err error)
- func BuiltinDeepCopyFunc(c Call) (_ Object, err error)
- func BuiltinDeleteFunc(c Call) (_ Object, err error)
- func BuiltinEachFunc(c Call) (_ Object, err error)
- func BuiltinEnumerateFunc(c Call) (_ Object, err error)
- func BuiltinFilterFunc(c Call) (_ Object, err error)
- func BuiltinFlushFunc(c Call) (Object, error)
- func BuiltinGlobalsFunc(c Call) (Object, error)
- func BuiltinIsArrayFunc(arg Object) Object
- func BuiltinIsBoolFunc(arg Object) Object
- func BuiltinIsBytesFunc(arg Object) Object
- func BuiltinIsCallableFunc(arg Object) Object
- func BuiltinIsCharFunc(arg Object) Object
- func BuiltinIsDictFunc(arg Object) Object
- func BuiltinIsErrorFunc(c Call) (ret Object, err error)
- func BuiltinIsFloatFunc(arg Object) Object
- func BuiltinIsFunc(c Call) (ok Object, err error)
- func BuiltinIsFunctionFunc(arg Object) Object
- func BuiltinIsIntFunc(arg Object) Object
- func BuiltinIsIterableFunc(vm *VM, arg Object) Object
- func BuiltinIsIteratorFunc(arg Object) Object
- func BuiltinIsNilFunc(arg Object) Object
- func BuiltinIsRawStrFunc(arg Object) Object
- func BuiltinIsStrFunc(arg Object) Object
- func BuiltinIsSyncDictFunc(arg Object) Object
- func BuiltinIsUintFunc(arg Object) Object
- func BuiltinItemsFunc(c Call) (_ Object, err error)
- func BuiltinIterateFunc(c Call) (_ Object, err error)
- func BuiltinIterationDoneFunc(c Call) (_ Object, err error)
- func BuiltinIteratorInputFunc(o Object) Object
- func BuiltinKeysFunc(c Call) (_ Object, err error)
- func BuiltinLenFunc(arg Object) Object
- func BuiltinMakeArrayFunc(n int, arg Object) (Object, error)
- func BuiltinMapFunc(c Call) (_ Object, err error)
- func BuiltinMultiValueDictFunc(c Call) (ret Object, err error)
- func BuiltinNamedParamTypeCheckFunc(c Call) (val Object, err error)
- func BuiltinNewFunc(c Call) (ret Object, err error)
- func BuiltinOBEndFunc(c Call) (ret Object, err error)
- func BuiltinOBStartFunc(c Call) (ret Object, err error)
- func BuiltinPopWriterFunc(c Call) (ret Object, err error)
- func BuiltinPrintFunc(c Call) (bytesWritten Object, err error)
- func BuiltinPrintfFunc(c Call) (_ Object, err error)
- func BuiltinPrintlnFunc(c Call) (bytesWritten Object, err error)
- func BuiltinPushWriterFunc(c Call) (ret Object, err error)
- func BuiltinRawCallerFunc(c Call) (ret Object, err error)
- func BuiltinReadFunc(c Call) (ret Object, err error)
- func BuiltinReduceFunc(c Call) (_ Object, err error)
- func BuiltinRepeatFunc(arg Object, count int) (ret Object, err error)
- func BuiltinReprFunc(c Call) (_ Object, err error)
- func BuiltinSelfAssignOperatorFunc(c Call) (ret Object, err error)
- func BuiltinSortFunc(vm *VM, arg Object, less CallerObject) (ret Object, err error)
- func BuiltinSortReverseFunc(vm *VM, arg Object, less CallerObject) (Object, error)
- func BuiltinSprintfFunc(c Call) (ret Object, err error)
- func BuiltinStdIOFunc(c Call) (ret Object, err error)
- func BuiltinStructFunc(c Call) (ret Object, err error)
- func BuiltinToArrayFunc(c Call) (_ Object, err error)
- func BuiltinTypeNameFunc(arg Object) Object
- func BuiltinTypeOfFunc(c Call) (_ Object, err error)
- func BuiltinUserDataFunc(c Call) (_ Object, err error)
- func BuiltinValuesFunc(c Call) (_ Object, err error)
- func BuiltinWrapFunc(c Call) (ret Object, err error)
- func BuiltinWriteFunc(c Call) (ret Object, err error)
- func DoCall(co CallerObject, c Call) (ret Object, err error)
- func IteratorObject(it Iterator) Object
- func MustCall(callee Object, args ...Object) (Object, error)
- func MustCallVargs(callee Object, args []Object, vargs ...Object) (Object, error)
- func MustToObject(v any) (ret Object)
- func MustVal(v Object, _ error) (ret Object)
- func NewArrayFunc(c Call) (ret Object, err error)
- func NewBufferFunc(c Call) (ret Object, err error)
- func NewBytesFunc(c Call) (_ Object, err error)
- func NewDictFunc(c Call) (ret Object, err error)
- func NewErrorFunc(c Call) (ret Object, err error)
- func NewKeyValueArrayFunc(c Call) (ret Object, err error)
- func NewKeyValueFunc(c Call) (ret Object, err error)
- func NewMixedParamsFunc(c Call) (ret Object, err error)
- func NewPrinterStateFunc(c Call) (ret Object, err error)
- func NewRawStrFunc(c Call) (ret Object, err error)
- func NewRegexpFunc(c Call) (_ Object, err error)
- func NewStrFunc(c Call) (_ Object, err error)
- func NewSyncDictFunc(c Call) (ret Object, err error)
- func ToObject(v any) (ret Object, err error)
- func TypedIteratorObject(typ ObjectType, it Iterator) Object
- func Val(v Object, e error) (ret Object, err error)
- type ObjectConverters
- type ObjectImpl
- type ObjectIterator
- type ObjectPtr
- func (o *ObjectPtr) BinaryOp(vm *VM, tok token.Token, right Object) (Object, error)
- func (o *ObjectPtr) Call(c Call) (Object, error)
- func (o *ObjectPtr) CanCall() bool
- func (o *ObjectPtr) Copy() Object
- func (o *ObjectPtr) DeepCopy(*VM) (Object, error)
- func (o *ObjectPtr) Equal(x Object) bool
- func (o *ObjectPtr) IsFalsy() bool
- func (o *ObjectPtr) ToString() string
- func (o *ObjectPtr) Type() ObjectType
- type ObjectRepresenter
- type ObjectToWriter
- type ObjectToWriterFunc
- type ObjectToWriters
- type ObjectType
- type ObjectTypeArray
- type ObjectTypeNode
- type ObjectTypes
- type Objector
- type OpCallFlag
- type Opcode
- type OptimizerError
- type Param
- type ParamOption
- type ParamType
- type Params
- type PipedInvokeIterator
- func (f *PipedInvokeIterator) Call(state *IteratorState) (err error)
- func (f *PipedInvokeIterator) Handler() func(state *IteratorState) error
- func (f *PipedInvokeIterator) Input() Object
- func (f *PipedInvokeIterator) Next(vm *VM, state *IteratorState) (err error)
- func (f *PipedInvokeIterator) PostCall() func(state *IteratorState, ret Object) error
- func (f *PipedInvokeIterator) PreCall() func(k, v Object) (Object, error)
- func (f *PipedInvokeIterator) Repr(vm *VM) (s string, err error)
- func (f *PipedInvokeIterator) SetHandler(handler func(state *IteratorState) error) *PipedInvokeIterator
- func (f *PipedInvokeIterator) SetPostCall(postCall func(state *IteratorState, ret Object) error) *PipedInvokeIterator
- func (f *PipedInvokeIterator) SetPreCall(preCall func(k, v Object) (Object, error)) *PipedInvokeIterator
- func (f *PipedInvokeIterator) SetType(typ ObjectType) *PipedInvokeIterator
- func (f *PipedInvokeIterator) Start(vm *VM) (state *IteratorState, err error)
- func (f *PipedInvokeIterator) Type() ObjectType
- type PrintStateOptionSortType
- type Printer
- type PrinterState
- func (s *PrinterState) BytesWritten() int64
- func (s *PrinterState) Context() context.Context
- func (s PrinterState) Copy() *PrinterState
- func (s *PrinterState) DoEnter(f func() error) error
- func (s *PrinterState) DoVisit(obj Object, f func() error) (err error)
- func (s *PrinterState) Enter() (leave func())
- func (s *PrinterState) Equal(right Object) bool
- func (s *PrinterState) Indent() []byte
- func (s *PrinterState) Indented() bool
- func (s *PrinterState) IndexGet(_ *VM, index Object) (value Object, err error)
- func (s *PrinterState) IsFalsy() bool
- func (s *PrinterState) Option(key string) Object
- func (s *PrinterState) OptionDefault(key string, defaul Object) (value Object)
- func (s *PrinterState) OptionOk(key string) (value Object, ok bool)
- func (s *PrinterState) Options() Dict
- func (s *PrinterState) Print(o Object) error
- func (s *PrinterState) PrintFromArgs(sep []byte, args Args) (err error)
- func (s *PrinterState) PrintIndent()
- func (s *PrinterState) PrintLine()
- func (s *PrinterState) PrintLineIndent()
- func (s *PrinterState) PrintMany(sep []byte, o ...Object) (err error)
- func (s *PrinterState) SkipDepth() bool
- func (s *PrinterState) Stack() *PrinterStateStack
- func (s *PrinterState) ToString() string
- func (s *PrinterState) Type() ObjectType
- func (s *PrinterState) Value(key any) (value any)
- func (s *PrinterState) Visited(obj Object) bool
- func (s *PrinterState) WithContext(ctx context.Context) *PrinterState
- func (s *PrinterState) WithValue(key, value any) *PrinterState
- func (s *PrinterState) WithValueBackup(key, value any) (restore func())
- func (s *PrinterState) Write(b []byte) (n int, err error)
- type PrinterStateOption
- func PrinterStateWithContext(ctx context.Context) PrinterStateOption
- func PrinterStateWithIndent(indent Object) PrinterStateOption
- func PrinterStateWithMaxDepth(depth int) PrinterStateOption
- func PrinterStateWithOptions(options Dict) PrinterStateOption
- func PrinterStateWithRaw(v bool) PrinterStateOption
- type PrinterStateStack
- type RangeIteration
- func NewRangeIteration(typ ObjectType, o Object, len int, readTo func(e *KeyValue, i int) error) *RangeIteration
- func SliceEntryIteration[T any](typ ObjectType, o Object, items []T, ...) *RangeIteration
- func SliceIteration[T any](typ ObjectType, o Object, items []T, get func(e *KeyValue, i Int, v T) error) *RangeIteration
- func (it *RangeIteration) Input() Object
- func (it *RangeIteration) Length() int
- func (it *RangeIteration) Next(_ *VM, state *IteratorState) (err error)
- func (it *RangeIteration) ParseNamedArgs(na *NamedArgs) *RangeIteration
- func (it *RangeIteration) Repr(vm *VM) (string, error)
- func (it *RangeIteration) SetReversed(v bool) *RangeIteration
- func (it *RangeIteration) Start(*VM) (state *IteratorState, err error)
- func (it *RangeIteration) Type() ObjectType
- type RawStr
- func (o RawStr) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o RawStr) Equal(right Object) bool
- func (o RawStr) Format(s fmt.State, verb rune)
- func (o RawStr) IndexGet(_ *VM, index Object) (Object, error)
- func (o RawStr) IsFalsy() bool
- func (o RawStr) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o RawStr) Length() int
- func (o RawStr) Quoted() string
- func (o RawStr) Repr(*VM) (string, error)
- func (o RawStr) ToString() string
- func (o RawStr) Type() ObjectType
- func (o RawStr) WriteTo(_ *VM, w io.Writer) (int64, error)
- type ReadWriter
- type Reader
- type Reducer
- type ReflectArray
- func (o *ReflectArray) Copy() (obj Object)
- func (o *ReflectArray) Format(s fmt.State, verb rune)
- func (o *ReflectArray) Get(vm *VM, i int) (value Object, err error)
- func (o *ReflectArray) IndexGet(vm *VM, index Object) (value Object, err error)
- func (o *ReflectArray) IndexSet(vm *VM, index, value Object) (err error)
- func (o *ReflectArray) IsFalsy() bool
- func (o *ReflectArray) Iterate(vm *VM, na *NamedArgs) Iterator
- func (o *ReflectArray) Length() int
- func (o *ReflectArray) Print(state *PrinterState) (err error)
- func (o *ReflectArray) Repr(vm *VM) (_ string, err error)
- func (o *ReflectArray) ToString() string
- type ReflectField
- type ReflectFunc
- type ReflectMap
- func (o *ReflectMap) Copy() (obj Object)
- func (o *ReflectMap) Format(s fmt.State, verb rune)
- func (o *ReflectMap) IndexDelete(vm *VM, index Object) (err error)
- func (o *ReflectMap) IndexGet(vm *VM, index Object) (value Object, err error)
- func (o *ReflectMap) IndexSet(vm *VM, index, value Object) (err error)
- func (o *ReflectMap) IsFalsy() bool
- func (o *ReflectMap) Iterate(vm *VM, na *NamedArgs) Iterator
- func (o *ReflectMap) Length() int
- func (o *ReflectMap) Print(s *PrinterState) (err error)
- func (o *ReflectMap) Repr(vm *VM) (_ string, err error)
- func (o *ReflectMap) ToString() string
- type ReflectMethod
- type ReflectSlice
- func (o *ReflectSlice) AppendObjects(vm *VM, items ...Object) (_ Object, err error)
- func (o *ReflectSlice) Copy() (obj Object)
- func (o *ReflectSlice) Format(s fmt.State, verb rune)
- func (o *ReflectSlice) Insert(vm *VM, at int, items ...Object) (_ Object, err error)
- func (o *ReflectSlice) Slice(low, high int) Object
- func (o *ReflectSlice) ToString() string
- type ReflectStruct
- func (s *ReflectStruct) Call(c Call) (Object, error)
- func (s *ReflectStruct) CallName(name string, c Call) (Object, error)
- func (s *ReflectStruct) CanCall() bool
- func (s *ReflectStruct) CanClose() bool
- func (s *ReflectStruct) CanIterationDone() (ok bool)
- func (s *ReflectStruct) Close() error
- func (s *ReflectStruct) Copy() (obj Object)
- func (s *ReflectStruct) FalbackIndexHandler(...) *ReflectStruct
- func (s *ReflectStruct) Field(vm *VM, name string) (handled bool, value any, err error)
- func (s *ReflectStruct) FieldHandler(handler func(vm *VM, s *ReflectStruct, name string, v any) any) *ReflectStruct
- func (s *ReflectStruct) IndexGet(vm *VM, index Object) (value Object, err error)
- func (s *ReflectStruct) IndexGetS(vm *VM, index string) (value Object, err error)
- func (s *ReflectStruct) IndexSet(vm *VM, index, value Object) (err error)
- func (s *ReflectStruct) Init()
- func (s *ReflectStruct) Iterate(vm *VM, na *NamedArgs) Iterator
- func (s *ReflectStruct) IterationDone(vm *VM) error
- func (s *ReflectStruct) Print(state *PrinterState) (err error)
- func (s *ReflectStruct) Reader() Reader
- func (s *ReflectStruct) Repr(vm *VM) (_ string, err error)
- func (s *ReflectStruct) SafeField(vm *VM, name string) (handled bool, value any, err error)
- func (s *ReflectStruct) SetField(vm *VM, index string, value any) (handled bool, err error)
- func (s *ReflectStruct) SetFieldValue(vm *VM, df *ReflectField, value any) (err error)
- func (s *ReflectStruct) SetValues(vm *VM, values Dict) (err error)
- func (s *ReflectStruct) ToString() string
- func (s *ReflectStruct) UserData() Indexer
- func (s *ReflectStruct) Writer() Writer
- type ReflectType
- func (r *ReflectType) Call(c Call) (Object, error)
- func (r *ReflectType) Equal(right Object) bool
- func (r *ReflectType) Fields() (fields Dict)
- func (r *ReflectType) Fqn() string
- func (r *ReflectType) GetRMethods() map[string]*ReflectMethod
- func (r *ReflectType) Getters() Dict
- func (r *ReflectType) IsChildOf(t ObjectType) bool
- func (r *ReflectType) IsFalsy() bool
- func (r *ReflectType) Methods() (m Dict)
- func (r *ReflectType) Name() string
- func (r *ReflectType) New(vm *VM, m Dict) (_ Object, err error)
- func (r *ReflectType) Setters() Dict
- func (r *ReflectType) String() string
- func (r *ReflectType) ToString() string
- func (r *ReflectType) Type() ObjectType
- type ReflectValue
- func (r *ReflectValue) CallName(name string, c Call) (Object, error)
- func (r *ReflectValue) CallNameOf(this ReflectValuer, name string, c Call) (Object, error)
- func (r *ReflectValue) Copy() (obj Object)
- func (r *ReflectValue) Equal(right Object) bool
- func (r *ReflectValue) FalbackNameCallerHandler(...) *ReflectValue
- func (r *ReflectValue) Format(s fmt.State, verb rune)
- func (r *ReflectValue) GetRType() *ReflectType
- func (r *ReflectValue) GetRValue() *ReflectValue
- func (r *ReflectValue) Init()
- func (r *ReflectValue) IsFalsy() bool
- func (r *ReflectValue) IsNil() bool
- func (r *ReflectValue) IsPtr() bool
- func (r *ReflectValue) Method(name string) *ReflectFunc
- func (r *ReflectValue) Methods() *IndexGetProxy
- func (r *ReflectValue) Print(state *PrinterState) (err error)
- func (r *ReflectValue) PtrValue() reflect.Value
- func (r *ReflectValue) Repr(_ *VM) (string, error)
- func (r *ReflectValue) ToInterface() any
- func (r *ReflectValue) ToString() string
- func (r *ReflectValue) ToStringW(w io.Writer)
- func (r *ReflectValue) Type() ObjectType
- func (r *ReflectValue) Value() reflect.Value
- type ReflectValueOptions
- type ReflectValuePrinter
- type ReflectValuer
- type Regexp
- func (o *Regexp) BinaryOp(vm *VM, tok token.Token, right Object) (ret Object, err error)
- func (o *Regexp) CallName(name string, c Call) (_ Object, err error)
- func (o *Regexp) Equal(right Object) bool
- func (o *Regexp) Find(arg Object) (ret Object)
- func (o *Regexp) FindAll(arg Object, n int) (ret Object)
- func (o *Regexp) Go() *regexp.Regexp
- func (o *Regexp) IsFalsy() bool
- func (o *Regexp) Match(arg Object) (ret Bool)
- func (o *Regexp) ToInterface() any
- func (o *Regexp) ToString() string
- func (o *Regexp) Type() ObjectType
- type RegexpBytesResult
- type RegexpBytesSliceResult
- type RegexpStrsResult
- type RegexpStrsSliceResult
- type Representer
- type ReverseSorter
- type RunOpts
- type RuntimeError
- func (o *RuntimeError) Copy() Object
- func (o *RuntimeError) Equal(right Object) bool
- func (o *RuntimeError) Error() string
- func (o *RuntimeError) FileSet() *source.FileSet
- func (o *RuntimeError) Format(s fmt.State, verb rune)
- func (o *RuntimeError) IndexGet(vm *VM, index Object) (Object, error)
- func (o *RuntimeError) IsFalsy() bool
- func (o *RuntimeError) NewError(messages ...string) *RuntimeError
- func (o *RuntimeError) StackTrace() source.FilePosStackTrace
- func (o *RuntimeError) ToString() string
- func (*RuntimeError) Type() ObjectType
- func (o *RuntimeError) Unwrap() error
- type SelfAssignOperatorHandler
- type SelfAssignOperatorType
- func (SelfAssignOperatorType) Call(Call) (Object, error)
- func (b SelfAssignOperatorType) Equal(right Object) bool
- func (SelfAssignOperatorType) Fields() Dict
- func (SelfAssignOperatorType) Getters() Dict
- func (SelfAssignOperatorType) IsChildOf(t ObjectType) bool
- func (b SelfAssignOperatorType) IsFalsy() bool
- func (SelfAssignOperatorType) Methods() Dict
- func (SelfAssignOperatorType) MethodsDisabled() bool
- func (b SelfAssignOperatorType) Name() string
- func (SelfAssignOperatorType) New(*VM, Dict) (Object, error)
- func (SelfAssignOperatorType) Setters() Dict
- func (b SelfAssignOperatorType) String() string
- func (b SelfAssignOperatorType) ToString() string
- func (b SelfAssignOperatorType) Token() token.Token
- func (b SelfAssignOperatorType) Type() ObjectType
- type SetupOpts
- type SimpleOptimizer
- type Slicer
- type Sorter
- type SourceModule
- type StackReader
- func (s *StackReader) Equal(right Object) bool
- func (s *StackReader) GoReader() io.Reader
- func (s *StackReader) IsFalsy() bool
- func (s *StackReader) Pop()
- func (s *StackReader) Push(r io.Reader)
- func (s *StackReader) Read(p []byte) (n int, err error)
- func (s *StackReader) ToString() string
- func (s *StackReader) Type() ObjectType
- type StackWriter
- func (w *StackWriter) Current() Writer
- func (w *StackWriter) Equal(right Object) bool
- func (w *StackWriter) Flush() (n Int, err error)
- func (w *StackWriter) GoWriter() io.Writer
- func (w *StackWriter) IsFalsy() bool
- func (w *StackWriter) Old() Writer
- func (w *StackWriter) Pop() Writer
- func (w *StackWriter) Push(sw io.Writer)
- func (w *StackWriter) ToString() string
- func (w *StackWriter) Type() ObjectType
- func (w *StackWriter) Write(p []byte) (n int, err error)
- type StartIterationHandler
- type StateIteratorObject
- func (s *StateIteratorObject) AddStartHandler(f func(s *StateIteratorObject))
- func (s *StateIteratorObject) Equal(right Object) bool
- func (s *StateIteratorObject) GetIterator() Iterator
- func (s *StateIteratorObject) IndexGet(vm *VM, index Object) (value Object, err error)
- func (s *StateIteratorObject) Info() Dict
- func (s *StateIteratorObject) IsFalsy() bool
- func (s *StateIteratorObject) Key() Object
- func (s *StateIteratorObject) Next(vm *VM, state *IteratorState) (err error)
- func (s *StateIteratorObject) Read() (_ bool, err error)
- func (s *StateIteratorObject) Repr(vm *VM) (r string, err error)
- func (s *StateIteratorObject) Start(vm *VM) (state *IteratorState, err error)
- func (s *StateIteratorObject) ToString() string
- func (s *StateIteratorObject) Type() ObjectType
- func (s *StateIteratorObject) Value() Object
- type Str
- func (o Str) BinaryOp(_ *VM, tok token.Token, right Object) (Object, error)
- func (o Str) Equal(right Object) bool
- func (o Str) Format(s fmt.State, verb rune)
- func (o Str) IndexGet(_ *VM, index Object) (Object, error)
- func (o Str) IsFalsy() bool
- func (o Str) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o Str) Length() int
- func (o Str) Quoted() string
- func (o Str) Repr(*VM) (string, error)
- func (o Str) ToString() string
- func (o Str) Type() ObjectType
- type Symbol
- type SymbolInfo
- type SymbolScope
- type SymbolTable
- func (st *SymbolTable) Builtins() *Builtins
- func (st *SymbolTable) DefineGlobal(name string) (*Symbol, error)
- func (st *SymbolTable) DefineGlobals(names []string) (s []*Symbol, err error)
- func (st *SymbolTable) DefineLocal(name string) (*Symbol, bool)
- func (st *SymbolTable) DisableBuiltin(names ...string) *SymbolTable
- func (st *SymbolTable) DisabledBuiltins() []string
- func (st *SymbolTable) EnableParams(v bool) *SymbolTable
- func (st *SymbolTable) Fork(block bool) *SymbolTable
- func (st *SymbolTable) FreeSymbols() []*Symbol
- func (st *SymbolTable) InBlock() bool
- func (st *SymbolTable) MaxSymbols() int
- func (st *SymbolTable) NamedParams() NamedParams
- func (st *SymbolTable) NextIndex() int
- func (st *SymbolTable) Params() Params
- func (st *SymbolTable) Parent(skipBlock bool) *SymbolTable
- func (st *SymbolTable) Resolve(name string) (symbol *Symbol, ok bool)
- func (st *SymbolTable) SetNamedParams(params ...*NamedParam) (err error)
- func (st *SymbolTable) SetParams(varParams bool, params []string, types []ParamType) (err error)
- func (st *SymbolTable) ShadowedBuiltins() []string
- func (st *SymbolTable) Symbols() []*Symbol
- type SyncDict
- func (o *SyncDict) BinaryOp(vm *VM, tok token.Token, right Object) (Object, error)
- func (o *SyncDict) Copy() Object
- func (o *SyncDict) DeepCopy(vm *VM) (v Object, err error)
- func (o *SyncDict) Equal(right Object) bool
- func (o *SyncDict) Format(f fmt.State, verb rune)
- func (o *SyncDict) Get(index string) (value Object, exists bool)
- func (o *SyncDict) IndexDelete(vm *VM, key Object) error
- func (o *SyncDict) IndexGet(vm *VM, index Object) (Object, error)
- func (o *SyncDict) IndexSet(vm *VM, index, value Object) error
- func (o *SyncDict) IsFalsy() bool
- func (o *SyncDict) Items(vm *VM, cb ItemsGetterCallback) (err error)
- func (o *SyncDict) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o *SyncDict) Keys() Array
- func (o *SyncDict) Length() int
- func (o *SyncDict) Lock()
- func (o *SyncDict) RLock()
- func (o *SyncDict) RUnlock()
- func (o *SyncDict) ToString() string
- func (o *SyncDict) Type() ObjectType
- func (o *SyncDict) Unlock()
- func (o *SyncDict) Values() Array
- type SyncIterator
- type ToArrayAppenderObject
- type ToArrayConveter
- type ToDictConveter
- type ToIterfaceConverter
- type ToIterfaceVMConverter
- type ToReaderConverter
- type ToWriter
- type ToWriterConverter
- type Type
- func (t *Type) AddCallerMethod(vm *VM, types MultipleObjectTypes, handler CallerObject, override bool) error
- func (t *Type) AddMethod(types MultipleObjectTypes, handler CallerObject, override bool) error
- func (t *Type) Call(c Call) (_ Object, err error)
- func (t *Type) Caller() CallerObject
- func (t *Type) CallerMethodOfArgs(args Args) (co CallerObject)
- func (t *Type) CallerMethodOfArgsTypes(types []ObjectType) (co CallerObject)
- func (t *Type) CallerMethodWithValidationCheckOfArgs(args Args) (co CallerObject, ok bool)
- func (t *Type) CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (co CallerObject, validate bool)
- func (t *Type) CallerMethods() *MethodArgType
- func (t *Type) Equal(right Object) bool
- func (Type) Fields() Dict
- func (Type) Getters() Dict
- func (t *Type) HasCallerMethods() bool
- func (t *Type) IndexDelete(vm *VM, index Object) (err error)
- func (t *Type) IndexGet(vm *VM, index Object) (value Object, err error)
- func (t *Type) IndexSet(vm *VM, index, value Object) (err error)
- func (t *Type) IsChildOf(ot ObjectType) bool
- func (t *Type) IsFalsy() bool
- func (Type) Methods() Dict
- func (t Type) Name() string
- func (Type) New(*VM, Dict) (Object, error)
- func (Type) Setters() Dict
- func (t *Type) String() string
- func (t *Type) ToString() string
- func (t *Type) Type() ObjectType
- func (t *Type) WithConstructor(handler CallerObject) *Type
- func (t *Type) WithMethod(types MultipleObjectTypes, handler CallerObject, override bool) *Type
- type TypeAssertion
- type TypeAssertionHandler
- type TypeAssertionHandlers
- type Uint
- type UpDownLines
- type UserDataStorage
- type VM
- func (vm *VM) Abort()
- func (vm *VM) Aborted() bool
- func (vm *VM) AddCallerMethod(co CallerObject, types MultipleObjectTypes, caller CallerObject) error
- func (vm *VM) AddCallerMethodOverride(co CallerObject, types MultipleObjectTypes, override bool, caller CallerObject) error
- func (vm *VM) CallBuiltin(t BuiltinType, namedArgs *NamedArgs, args ...Object) (Object, error)
- func (vm *VM) Clear() *VM
- func (vm *VM) GetGlobals() Object
- func (vm *VM) GetLocals(locals []Object) []Object
- func (vm *VM) GetSymbolValue(symbol *SymbolInfo) (value Object, err error)
- func (vm *VM) Init() *VM
- func (vm *VM) Read(b []byte) (int, error)
- func (vm *VM) Run(args ...Object) (Object, error)
- func (vm *VM) RunCompiledFunction(f *CompiledFunction, args ...Object) (Object, error)
- func (vm *VM) RunCompiledFunctionOpts(f *CompiledFunction, opts *RunOpts) (Object, error)
- func (vm *VM) RunOpts(opts *RunOpts) (Object, error)
- func (vm *VM) SetBytecode(bc *Bytecode) *VM
- func (vm *VM) SetRecover(v bool) *VM
- func (vm *VM) Setup(opts SetupOpts) *VM
- func (vm *VM) SourcePos() source.FilePos
- func (vm *VM) ToInterface(v Object) any
- func (vm *VM) ToInterfaceArray(v Array) (ret []any)
- func (vm *VM) ToObject(v any) (Object, error)
- func (vm *VM) ToObjectArray(v []any) (ret Array, err error)
- func (vm *VM) Write(b []byte) (int, error)
- type VMCaller
- type ValuesGetter
- type ValuesIterator
- type Writer
- type Zeroer
Constants ¶
const ( // True represents a true value. True = Bool(true) // False represents a false value. False = Bool(false) // Yes represents a flag on. Yes = Flag(true) // Yes represents a flag off. No = Flag(false) )
const ( PrintStateOptionIndent = "indent" PrintStateOptionMaxDepth = "maxDepth" PrintStateOptionRaw = "raw" PrintStateOptionZeros = "zeros" PrintStateOptionAnonymous = "anonymous" PrintStateOptionSortKeys = "sortKeys" PrintStateOptionIndexes = "indexes" )
const ( // AttrModuleName is a special attribute injected into modules to identify // the modules by name. AttrModuleName = "__module_name__" )
const MainName = parser.MainName
const ObjectMethodsGetterFieldName = "__methods__"
const PrintLoop = repr.QuotePrefix + "↶" + repr.QuoteSufix
Variables ¶
var ( TBinaryOperatorAdd = BinaryOperatorType(token.Add) // + TBinaryOperatorSub = BinaryOperatorType(token.Sub) // - TBinaryOperatorMul = BinaryOperatorType(token.Mul) // * TBinaryOperatorPow = BinaryOperatorType(token.Pow) // ** TBinaryOperatorQuo = BinaryOperatorType(token.Quo) // / TBinaryOperatorRem = BinaryOperatorType(token.Rem) // % TBinaryOperatorAnd = BinaryOperatorType(token.And) // & TBinaryOperatorOr = BinaryOperatorType(token.Or) // | TBinaryOperatorXor = BinaryOperatorType(token.Xor) // ^ TBinaryOperatorShl = BinaryOperatorType(token.Shl) // << TBinaryOperatorShr = BinaryOperatorType(token.Shr) // >> TBinaryOperatorAndNot = BinaryOperatorType(token.AndNot) // &^ TBinaryOperatorLAnd = BinaryOperatorType(token.LAnd) // && TBinaryOperatorEqual = BinaryOperatorType(token.Equal) // == TBinaryOperatorNotEqual = BinaryOperatorType(token.NotEqual) // != TBinaryOperatorLess = BinaryOperatorType(token.Less) // < TBinaryOperatorGreater = BinaryOperatorType(token.Greater) // > TBinaryOperatorLessEq = BinaryOperatorType(token.LessEq) // <= TBinaryOperatorGreaterEq = BinaryOperatorType(token.GreaterEq) // >= TBinaryOperatorTilde = BinaryOperatorType(token.Tilde) // ~ TBinaryOperatorDoubleTilde = BinaryOperatorType(token.DoubleTilde) // ~~ TBinaryOperatorTripleTilde = BinaryOperatorType(token.TripleTilde) // ~~~ TSelfAssignOperatorAdd = SelfAssignOperatorType(token.Add) // + TSelfAssignOperatorInc = SelfAssignOperatorType(token.Inc) // ++ TSelfAssignOperatorSub = SelfAssignOperatorType(token.Sub) // - TSelfAssignOperatorDec = SelfAssignOperatorType(token.Dec) // -- TSelfAssignOperatorMul = SelfAssignOperatorType(token.Mul) // * TSelfAssignOperatorPow = SelfAssignOperatorType(token.Pow) // ** TSelfAssignOperatorQuo = SelfAssignOperatorType(token.Quo) // / TSelfAssignOperatorRem = SelfAssignOperatorType(token.Rem) // % TSelfAssignOperatorAnd = SelfAssignOperatorType(token.And) // & TSelfAssignOperatorOr = SelfAssignOperatorType(token.Or) // | TSelfAssignOperatorXor = SelfAssignOperatorType(token.Xor) // ^ TSelfAssignOperatorShl = SelfAssignOperatorType(token.Shl) // << TSelfAssignOperatorShr = SelfAssignOperatorType(token.Shr) // >> TSelfAssignOperatorAndNot = SelfAssignOperatorType(token.AndNot) // &^ TSelfAssignOperatorLOr = SelfAssignOperatorType(token.LOr) // || )
var ( TNil, TFlag, TBool, TInt, TUint, TFloat, TDecimal, TChar, TRawStr, TStr, TBytes, TBuffer, TArray, TDict, TSyncDict, TKeyValue, TKeyValueArray, TRegexp, TRegexpStrsResult, TRegexpStrsSliceResult, TRegexpBytesResult, TRegexpBytesSliceResult, TMixedParams, TError ObjectType TBuiltinFunction = &BuiltinObjType{ NameValue: "builtinFunction", } TCallWrapper = &BuiltinObjType{ NameValue: "callwrap", } TCompiledFunction = &BuiltinObjType{ NameValue: "compiledFunction", } TFunction = &BuiltinObjType{ NameValue: "function", } TKeyValueArrays = &BuiltinObjType{ NameValue: "keyValueArrays", } TArgs = &BuiltinObjType{ NameValue: "args", } TNamedArgs = &BuiltinObjType{ NameValue: "namedArgs", } TObjectPtr = &BuiltinObjType{ NameValue: "objectPtr", } TReader = &BuiltinObjType{ NameValue: "reader", } TWriter = &BuiltinObjType{ NameValue: "writer", } TDiscardWriter = &BuiltinObjType{ NameValue: "discardWriter", } TObjectTypeArray = &BuiltinObjType{ NameValue: "objectTypeArray", } TReflectMethod = &BuiltinObjType{ NameValue: "reflectMethod", } TIndexGetProxy = &BuiltinObjType{ NameValue: "indexGetProxy", } TPrinterState = &BuiltinObjType{ NameValue: "PrinterState", } )
var ( TAny = &Type{TypeName: "Any"} TSymbol = &Type{Parent: TAny, TypeName: "Symbol"} TIterationStateFlag = &Type{Parent: TAny, TypeName: "IterationStateFlag"} IterationStop = &Type{Parent: TIterationStateFlag, TypeName: "IterationStop"} IterationSkip = &Type{Parent: TIterationStateFlag, TypeName: "IterationSkip"} TBase = &Type{Parent: TAny, TypeName: "Base"} TIterator = &Type{Parent: TAny, TypeName: "Iterator"} TIterabler = &Type{Parent: TAny, TypeName: "Iterabler"} TNilIterator = &Type{Parent: TIterator, TypeName: "NilIterator"} TStateIterator = &Type{Parent: TIterator, TypeName: "StateIterator"} TStrIterator = &Type{Parent: TIterator, TypeName: "StrIterator"} TRawStrIterator = &Type{Parent: TIterator, TypeName: "RawStrIterator"} TArrayIterator = &Type{Parent: TIterator, TypeName: "ArrayIterator"} TDictIterator = &Type{Parent: TIterator, TypeName: "DictIterator"} TBytesIterator = &Type{Parent: TIterator, TypeName: "BytesIterator"} TKeyValueArrayIterator = &Type{Parent: TIterator, TypeName: "KeyValueArrayIterator"} TKeyValueArraysIterator = &Type{Parent: TIterator, TypeName: "KeyValueArraysIterator"} TArgsIterator = &Type{Parent: TIterator, TypeName: "ArgsIterator"} TReflectArrayIterator = &Type{Parent: TIterator, TypeName: "ReflectArrayIterator"} TReflectMapIterator = &Type{Parent: TIterator, TypeName: "ReflectMapIterator"} TReflectStructIterator = &Type{Parent: TIterator, TypeName: "ReflectStructIterator"} TKeysIterator = &Type{Parent: TIterator, TypeName: "KeysIterator"} TValuesIterator = &Type{Parent: TIterator, TypeName: "ValuesIterator"} TEnumerateIterator = &Type{Parent: TIterator, TypeName: "EnumerateIterator"} TItemsIterator = &Type{Parent: TIterator, TypeName: "ItemsIterator"} TCallbackIterator = &Type{Parent: TIterator, TypeName: "CallbackIterator"} TEachIterator = &Type{Parent: TIterator, TypeName: "EachIterator"} TMapIterator = &Type{Parent: TIterator, TypeName: "MapIterator"} TFilterIterator = &Type{Parent: TIterator, TypeName: "FilterIterator"} TZipIterator = &Type{Parent: TIterator, TypeName: "ZipIterator"} TPipedInvokeIterator = &Type{Parent: TIterator, TypeName: "PipedInvokeIterator"} )
var ( NewFlagFunc = funcPORO(func(arg Object) Object { return Flag(!arg.IsFalsy()) }) NewBoolFunc = funcPORO(func(arg Object) Object { return Bool(!arg.IsFalsy()) }) NewIntFunc = funcPi64RO(func(v int64) Object { return Int(v) }) NewUintFunc = funcPu64RO(func(v uint64) Object { return Uint(v) }) NewFloatFunc = funcPf64RO(func(v float64) Object { return Float(v) }) NewDecimalFunc = funcPpVM_OROe(func(vm *VM, v Object) (Object, error) { return Decimal(decimal.Zero).BinaryOp(vm, token.Add, v) }) NewCharFunc = funcPOROe(func(arg Object) (Object, error) { v, ok := ToChar(arg) if ok && v != utf8.RuneError { return v, nil } if v == utf8.RuneError || arg == Nil { return Nil, nil } return Nil, NewArgumentTypeError( "1st", "numeric|string|bool", arg.Type().Name(), ) }) )
var ( // DefaultCompilerOptions holds default Compiler options. DefaultCompilerOptions = CompilerOptions{ OptimizerMaxCycle: 100, OptimizeConst: true, OptimizeExpr: true, } DefaultCompileOptions = CompileOptions{ CompilerOptions: DefaultCompilerOptions, } // TraceCompilerOptions holds Compiler options to print trace output // to stdout for Parser, Optimizer, Compiler. TraceCompilerOptions = CompilerOptions{ Trace: os.Stdout, TraceParser: true, TraceCompiler: true, TraceOptimizer: true, OptimizerMaxCycle: 1<<8 - 1, OptimizeConst: true, OptimizeExpr: true, } )
var ( // ErrSymbolLimit represents a symbol limit error which is returned by // Compiler when number of local symbols exceeds the symbo limit for // a function that is 256. ErrSymbolLimit = &Error{ Name: "SymbolLimitError", Message: "number of local symbols exceeds the limit", } // ErrStackOverflow represents a stack overflow error. ErrStackOverflow = &Error{Name: "StackOverflowError"} // ErrVMAborted represents a VM aborted error. ErrVMAborted = &Error{Name: "VMAbortedError"} // ErrWrongNumArguments represents a wrong number of arguments error. ErrWrongNumArguments = &Error{Name: "WrongNumberOfArgumentsError"} // ErrInvalidOperator represents an error for invalid operator usage. ErrInvalidOperator = &Error{Name: "InvalidOperatorError"} // ErrIndexOutOfBounds represents an out of bounds index error. ErrIndexOutOfBounds = &Error{Name: "IndexOutOfBoundsError"} // ErrInvalidIndex represents an invalid index error. ErrInvalidIndex = &Error{Name: "InvalidIndexError"} // ErrNotIterable is an error where an Object is not iterable. ErrNotIterable = &Error{Name: "NotIterableError"} // ErrNotIndexable is an error where an Object is not indexable. ErrNotIndexable = &Error{Name: "NotIndexableError"} // ErrNotIndexAssignable is an error where an Object is not index assignable. ErrNotIndexAssignable = &Error{Name: "NotIndexAssignableError"} // ErrNotIndexDeletable is an error where an Object is not index deletable. ErrNotIndexDeletable = &Error{Name: "NotIndexDeletableError"} // ErrNotCallable is an error where Object is not callable. ErrNotCallable = &Error{Name: "NotCallableError"} // ErrNotImplemented is an error where an Object has not implemented a required method. ErrNotImplemented = &Error{Name: "NotImplementedError"} // ErrZeroDivision is an error where divisor is zero. ErrZeroDivision = &Error{Name: "ZeroDivisionError"} // ErrUnexpectedNamedArg is an error where unexpected kwarg. ErrUnexpectedNamedArg = &Error{Name: "ErrUnexpectedNamedArg"} // ErrUnexpectedArgValue is an error where unexpected argument value. ErrUnexpectedArgValue = &Error{Name: "ErrUnexpectedArgValue"} // ErrIncompatibleCast is an error where incompatible cast. ErrIncompatibleCast = &Error{Name: "ErrIncompatibleCast"} // ErrIncompatibleReflectFuncType is an error where incompatible reflect func type. ErrIncompatibleReflectFuncType = &Error{Name: "ErrIncompatibleReflectFuncType"} // ErrReflectCallPanicsType is an error where call reflect function panics. ErrReflectCallPanicsType = &Error{Name: "ErrReflectCallPanicsType"} // ErrMethodDuplication is an error where method was duplication. ErrMethodDuplication = &Error{Name: "ErrMethodDuplication"} // ErrMethodNotAppendable is an error where method append is disabled. ErrMethodNotAppendable = &Error{Name: "ErrMethodNotAppendable"} // ErrType represents a type error. ErrType = &Error{Name: "TypeError"} // ErrNotInitializable represents a not initializable type error. ErrNotInitializable = &Error{Name: "ErrNotInitializable"} // ErrNotWriteable represents a not writeable type error. ErrNotWriteable = &Error{Name: "ErrNotWriteable"} )
var ( ReprQuote = repr.Quote ReprQuoteTyped = repr.QuoteTyped )
var BuiltinObjects = BuiltinObjectsMap{ BuiltinMakeArray: &BuiltinFunction{ Name: ":makeArray", Value: funcPiOROe(BuiltinMakeArrayFunc), AcceptMethodsDisabled: true, }, BuiltinBinaryOperator: &BuiltinFunction{ Name: "binaryOperator", Value: BuiltinBinaryOperatorFunc, }, BuiltinSelfAssignOperator: &BuiltinFunction{ Name: "selfAssignOperator", Value: BuiltinSelfAssignOperatorFunc, }, BuiltinCast: &BuiltinFunction{ Name: "cast", Value: BuiltinCastFunc, }, BuiltinChars: &BuiltinFunction{ Name: "chars", Value: funcPOROe(BuiltinCharsFunc), }, BuiltinAppend: &BuiltinFunction{ Name: "append", Value: BuiltinAppendFunc, }, BuiltinDelete: &BuiltinFunction{ Name: "delete", Value: BuiltinDeleteFunc, }, BuiltinCopy: &BuiltinFunction{ Name: "copy", Value: BuiltinCopyFunc, }, BuiltinDeepCopy: &BuiltinFunction{ Name: "dcopy", Value: BuiltinDeepCopyFunc, }, BuiltinRepeat: &BuiltinFunction{ Name: "repeat", Value: funcPOiROe(BuiltinRepeatFunc), }, BuiltinContains: &BuiltinFunction{ Name: "contains", Value: funcPOOROe(BuiltinContainsFunc), }, BuiltinLen: &BuiltinFunction{ Name: "len", Value: funcPORO(BuiltinLenFunc), }, BuiltinCap: &BuiltinFunction{ Name: "cap", Value: funcPORO(BuiltinCapFunc), }, BuiltinSort: &BuiltinFunction{ Name: "sort", Value: funcPpVM_OCo_less_ROe(BuiltinSortFunc), }, BuiltinSortReverse: &BuiltinFunction{ Name: "sortReverse", Value: funcPpVM_OCo_less_ROe(BuiltinSortReverseFunc), }, BuiltinTypeName: &BuiltinFunction{ Name: "typeName", Value: funcPORO(BuiltinTypeNameFunc), AcceptMethodsDisabled: true, }, BuiltinPrint: &BuiltinFunction{ Name: "print", Value: BuiltinPrintFunc, }, BuiltinPrintf: &BuiltinFunction{ Name: "printf", Value: BuiltinPrintfFunc, }, BuiltinPrintln: &BuiltinFunction{ Name: "println", Value: BuiltinPrintlnFunc, }, BuiltinSprintf: &BuiltinFunction{ Name: "sprintf", Value: BuiltinSprintfFunc, AcceptMethodsDisabled: true, }, BuiltinGlobals: &BuiltinFunction{ Name: "globals", Value: BuiltinGlobalsFunc, AcceptMethodsDisabled: true, }, BuiltinRepr: &BuiltinFunction{ Name: "repr", Value: BuiltinReprFunc, }, BuiltinNamedParamTypeCheck: &BuiltinFunction{ Name: "namedParamTypeCheck", Value: BuiltinNamedParamTypeCheckFunc, AcceptMethodsDisabled: true, }, BuiltinIs: &BuiltinFunction{ Name: "is", Value: BuiltinIsFunc, AcceptMethodsDisabled: true, }, BuiltinIsError: &BuiltinFunction{ Name: "isError", Value: BuiltinIsErrorFunc, AcceptMethodsDisabled: true, }, BuiltinIsInt: &BuiltinFunction{ Name: "isInt", Value: funcPORO(BuiltinIsIntFunc), AcceptMethodsDisabled: true, }, BuiltinIsUint: &BuiltinFunction{ Name: "isUint", Value: funcPORO(BuiltinIsUintFunc), AcceptMethodsDisabled: true, }, BuiltinIsFloat: &BuiltinFunction{ Name: "isFloat", Value: funcPORO(BuiltinIsFloatFunc), AcceptMethodsDisabled: true, }, BuiltinIsChar: &BuiltinFunction{ Name: "isChar", Value: funcPORO(BuiltinIsCharFunc), AcceptMethodsDisabled: true, }, BuiltinIsBool: &BuiltinFunction{ Name: "isBool", Value: funcPORO(BuiltinIsBoolFunc), AcceptMethodsDisabled: true, }, BuiltinIsStr: &BuiltinFunction{ Name: "isStr", Value: funcPORO(BuiltinIsStrFunc), AcceptMethodsDisabled: true, }, BuiltinIsRawStr: &BuiltinFunction{ Name: "isRawStr", Value: funcPORO(BuiltinIsRawStrFunc), AcceptMethodsDisabled: true, }, BuiltinIsBytes: &BuiltinFunction{ Name: "isBytes", Value: funcPORO(BuiltinIsBytesFunc), AcceptMethodsDisabled: true, }, BuiltinIsDict: &BuiltinFunction{ Name: "isDict", Value: funcPORO(BuiltinIsDictFunc), AcceptMethodsDisabled: true, }, BuiltinIsSyncDict: &BuiltinFunction{ Name: "isSyncDict", Value: funcPORO(BuiltinIsSyncDictFunc), AcceptMethodsDisabled: true, }, BuiltinIsArray: &BuiltinFunction{ Name: "isArray", Value: funcPORO(BuiltinIsArrayFunc), AcceptMethodsDisabled: true, }, BuiltinIsNil: &BuiltinFunction{ Name: "isNil", Value: funcPORO(BuiltinIsNilFunc), AcceptMethodsDisabled: true, }, BuiltinIsFunction: &BuiltinFunction{ Name: "isFunction", Value: funcPORO(BuiltinIsFunctionFunc), AcceptMethodsDisabled: true, }, BuiltinIsCallable: &BuiltinFunction{ Name: "isCallable", Value: funcPORO(BuiltinIsCallableFunc), }, BuiltinIsIterable: &BuiltinFunction{ Name: "isIterable", Value: funcPpVM_ORO(BuiltinIsIterableFunc), }, BuiltinIsIterator: &BuiltinFunction{ Name: "isIterator", Value: funcPORO(BuiltinIsIteratorFunc), }, BuiltinStdIO: &BuiltinFunction{ Name: "stdio", Value: BuiltinStdIOFunc, }, BuiltinWrap: &BuiltinFunction{ Name: "wrap", Value: BuiltinWrapFunc, }, BuiltinStruct: &BuiltinFunction{ Name: "struct", Value: BuiltinStructFunc, AcceptMethodsDisabled: true, }, BuiltinNew: &BuiltinFunction{ Name: "new", Value: BuiltinNewFunc, }, BuiltinTypeOf: &BuiltinFunction{ Name: "typeof", Value: BuiltinTypeOfFunc, AcceptMethodsDisabled: true, }, BuiltinAddCallMethod: &BuiltinFunction{ Name: "addCallMethod", Value: funcPpVM_CoCob_override_Re(BuiltinAddCallMethodFunc), AcceptMethodsDisabled: true, }, BuiltinRawCaller: &BuiltinFunction{ Name: "rawCaller", Value: BuiltinRawCallerFunc, AcceptMethodsDisabled: true, }, BuiltinVMPushWriter: &BuiltinFunction{ Name: "vmPushWriter", Value: BuiltinPushWriterFunc, AcceptMethodsDisabled: true, }, BuiltinVMPopWriter: &BuiltinFunction{ Name: "vmPopWriter", Value: BuiltinPopWriterFunc, }, BuiltinOBStart: &BuiltinFunction{ Name: "obstart", Value: BuiltinOBStartFunc, AcceptMethodsDisabled: true, }, BuiltinOBEnd: &BuiltinFunction{ Name: "obend", Value: BuiltinOBEndFunc, AcceptMethodsDisabled: true, }, BuiltinFlush: &BuiltinFunction{ Name: "flush", Value: BuiltinFlushFunc, }, BuiltinUserData: &BuiltinFunction{ Name: "userData", Value: BuiltinUserDataFunc, }, BuiltinClose: &BuiltinFunction{ Name: "close", Value: BuiltinCloseFunc, }, BuiltinWrongNumArgumentsError: ErrWrongNumArguments, BuiltinInvalidOperatorError: ErrInvalidOperator, BuiltinIndexOutOfBoundsError: ErrIndexOutOfBounds, BuiltinNotIterableError: ErrNotIterable, BuiltinNotIndexableError: ErrNotIndexable, BuiltinNotIndexAssignableError: ErrNotIndexAssignable, BuiltinNotCallableError: ErrNotCallable, BuiltinNotImplementedError: ErrNotImplemented, BuiltinZeroDivisionError: ErrZeroDivision, BuiltinTypeError: ErrType, BuiltinDiscardWriter: DiscardWriter, }
BuiltinObjects is list of builtins, exported for REPL.
var BuiltinsMap = map[string]BuiltinType{ "binaryOperator": BuiltinBinaryOperator, "selfAssignOperator": BuiltinSelfAssignOperator, "cast": BuiltinCast, "append": BuiltinAppend, "delete": BuiltinDelete, "copy": BuiltinCopy, "dcopy": BuiltinDeepCopy, "repeat": BuiltinRepeat, "contains": BuiltinContains, "len": BuiltinLen, "sort": BuiltinSort, "sortReverse": BuiltinSortReverse, "filter": BuiltinFilter, "map": BuiltinMap, "each": BuiltinEach, "reduce": BuiltinReduce, "typeName": BuiltinTypeName, "chars": BuiltinChars, "close": BuiltinClose, "read": BuiltinRead, "write": BuiltinWrite, "print": BuiltinPrint, "printf": BuiltinPrintf, "println": BuiltinPrintln, "sprintf": BuiltinSprintf, "globals": BuiltinGlobals, "stdio": BuiltinStdIO, "wrap": BuiltinWrap, "struct": BuiltinStruct, "new": BuiltinNew, "typeof": BuiltinTypeOf, "addCallMethod": BuiltinAddCallMethod, "rawCaller": BuiltinRawCaller, "repr": BuiltinRepr, "userData": BuiltinUserData, "namedParamTypeCheck": BuiltinNamedParamTypeCheck, "toArray": BuiltinToArray, "is": BuiltinIs, "isError": BuiltinIsError, "isInt": BuiltinIsInt, "isUint": BuiltinIsUint, "isFloat": BuiltinIsFloat, "isChar": BuiltinIsChar, "isBool": BuiltinIsBool, "isStr": BuiltinIsStr, "isRawStr": BuiltinIsRawStr, "isBytes": BuiltinIsBytes, "isDict": BuiltinIsDict, "isSyncDict": BuiltinIsSyncDict, "isArray": BuiltinIsArray, "isNil": BuiltinIsNil, "isFunction": BuiltinIsFunction, "isCallable": BuiltinIsCallable, "isIterable": BuiltinIsIterable, "isIterator": BuiltinIsIterator, "WrongNumArgumentsError": BuiltinWrongNumArgumentsError, "InvalidOperatorError": BuiltinInvalidOperatorError, "IndexOutOfBoundsError": BuiltinIndexOutOfBoundsError, "NotIterableError": BuiltinNotIterableError, "NotIndexableError": BuiltinNotIndexableError, "NotIndexAssignableError": BuiltinNotIndexAssignableError, "NotCallableError": BuiltinNotCallableError, "NotImplementedError": BuiltinNotImplementedError, "ZeroDivisionError": BuiltinZeroDivisionError, "TypeError": BuiltinTypeError, ":makeArray": BuiltinMakeArray, "cap": BuiltinCap, "iterate": BuiltinIterate, "keys": BuiltinKeys, "values": BuiltinValues, "items": BuiltinItems, "collect": BuiltinCollect, "enumerate": BuiltinEnumerate, "iterator": BuiltinIterator, "iteratorInput": BuiltinIteratorInput, "zip": BuiltinZipIterator, "keyValue": BuiltinKeyValue, "keyValueArray": BuiltinKeyValueArray, "vmPushWriter": BuiltinVMPushWriter, "vmPopWriter": BuiltinVMPopWriter, "obstart": BuiltinOBStart, "obend": BuiltinOBEnd, "flush": BuiltinFlush, "DISCARD_WRITER": BuiltinDiscardWriter, }
BuiltinsMap is list of builtin types, exported for REPL.
var DecimalZero = Decimal(decimal.Zero)
var DiscardWriter = NewTypedWriter(io.Discard, TDiscardWriter)
var EmptyNamedArgs = &NamedArgs{ro: true}
var OpcodeNames = [...]string{ OpNoOp: "NOOP", OpConstant: "CONSTANT", OpCall: "CALL", OpGetGlobal: "GETGLOBAL", OpSetGlobal: "SETGLOBAL", OpGetLocal: "GETLOCAL", OpSetLocal: "SETLOCAL", OpGetBuiltin: "GETBUILTIN", OpBinary: "BINARY", OpUnary: "UNARY", OpSelfAssign: "SELFASSIGN", OpEqual: "EQUAL", OpNotEqual: "NOTEQUAL", OpJump: "JUMP", OpJumpFalsy: "JUMPFALSY", OpAndJump: "ANDJUMP", OpOrJump: "ORJUMP", OpDict: "DICT", OpArray: "ARRAY", OpSliceIndex: "SLICEINDEX", OpGetIndex: "GETINDEX", OpSetIndex: "SETINDEX", OpNil: "NIL", OpStdIn: "STDIN", OpStdOut: "STDOUT", OpStdErr: "STDERR", OpDotName: "DOTNAME", OpDotFile: "DOTFILE", OpIsModule: "ISMODULE", OpPop: "POP", OpGetFree: "GETFREE", OpSetFree: "SETFREE", OpGetLocalPtr: "GETLOCALPTR", OpGetFreePtr: "GETFREEPTR", OpClosure: "CLOSURE", OpIterInit: "ITERINIT", OpIterNext: "ITERNEXT", OpIterNextElse: "ITERNEXTELSE", OpIterKey: "ITERKEY", OpIterValue: "ITERVALUE", OpLoadModule: "LOADMODULE", OpStoreModule: "STOREMODULE", OpReturn: "RETURN", OpSetupTry: "SETUPTRY", OpSetupCatch: "SETUPCATCH", OpSetupFinally: "SETUPFINALLY", OpThrow: "THROW", OpFinalizer: "FINALIZER", OpDefineLocal: "DEFINELOCAL", OpTrue: "TRUE", OpFalse: "FALSE", OpYes: "YES", OpNo: "NO", OpCallName: "CALLNAME", OpJumpNil: "JUMPNIL", OpJumpNotNil: "JUMPNOTNIL", OpKeyValueArray: "KVARRAY", OpKeyValue: "KV", OpCallee: "CALLEE", OpArgs: "ARGS", OpNamedArgs: "NAMEDARGS", OpIsNil: "ISNIL", OpNotIsNil: "NOTISNIL", }
OpcodeNames are string representation of opcodes.
var OpcodeOperands = [...][]int{ OpNoOp: {}, OpConstant: {2}, OpCall: {1, 1}, OpGetGlobal: {2}, OpSetGlobal: {2}, OpGetLocal: {1}, OpSetLocal: {1}, OpGetBuiltin: {2}, OpBinary: {1}, OpUnary: {1}, OpSelfAssign: {1}, OpEqual: {}, OpNotEqual: {}, OpIsNil: {}, OpNotIsNil: {}, OpJump: {2}, OpJumpFalsy: {2}, OpAndJump: {2}, OpOrJump: {2}, OpDict: {2}, OpArray: {2}, OpSliceIndex: {}, OpGetIndex: {1}, OpSetIndex: {}, OpNil: {}, OpStdIn: {}, OpStdOut: {}, OpStdErr: {}, OpDotName: {}, OpDotFile: {}, OpIsModule: {}, OpPop: {}, OpGetFree: {1}, OpSetFree: {1}, OpGetLocalPtr: {1}, OpGetFreePtr: {1}, OpClosure: {2, 1}, OpIterInit: {}, OpIterNext: {}, OpIterNextElse: {2, 2}, OpIterKey: {}, OpIterValue: {}, OpLoadModule: {2, 2}, OpStoreModule: {2}, OpReturn: {1}, OpSetupTry: {2, 2}, OpSetupCatch: {}, OpSetupFinally: {}, OpThrow: {1}, OpFinalizer: {1}, OpDefineLocal: {1}, OpTrue: {}, OpFalse: {}, OpYes: {}, OpNo: {}, OpCallName: {1, 1}, OpJumpNil: {2}, OpJumpNotNil: {2}, OpKeyValueArray: {2}, OpCallee: {}, OpArgs: {}, OpNamedArgs: {}, OpKeyValue: {1}, }
OpcodeOperands is the number of operands.
var (
TOperator = &Type{TypeName: "Operator", Parent: TBase}
)
var Types = map[reflect.Type]ObjectType{}
Functions ¶
func BuiltinAddCallMethodFunc ¶
func BuiltinAddCallMethodFunc(vm *VM, fn CallerObject, handler CallerObject, override bool) (err error)
func CloserFrom ¶
func Filterable ¶
func FormatInstructions ¶
FormatInstructions returns string representation of bytecode instructions.
func IsIndexDeleter ¶
func IsIndexGetter ¶
func IsIndexSetter ¶
func IsIterator ¶
func IsObjector ¶
func IsPrimitive ¶
func IsTypeAssignableTo ¶
func IsTypeAssignableTo(a, b ObjectType) bool
func IterateInstructions ¶
func IterateInstructions(insts []byte, fn func(pos int, opcode Opcode, operands []int, offset int) bool)
IterateInstructions iterate instructions and call given function for each instruction. Note: Do not use operands slice in callback, it is reused for less allocation.
func IterateObject ¶
func IteratorStateCheck ¶
func IteratorStateCheck(vm *VM, it Iterator, state *IteratorState) (err error)
func MakeInstruction ¶
MakeInstruction returns a bytecode for an Opcode and the operands.
Provide "buf" slice which is a returning value to reduce allocation or nil to create new byte slice. This is implemented to reduce compilation allocation that resulted in -15% allocation, +2% speed in compiler. It takes ~8ns/op with zero allocation.
Returning error is required to identify bugs faster when VM and Opcodes are under heavy development.
Warning: Unknown Opcode causes panic!
func NamedParamTypeCheck ¶
func NamedParamTypeCheckAssertion ¶
func NamedParamTypeCheckAssertion(name string, assertion *TypeAssertion, value Object) (err error)
func NewArgCaller ¶
func ObjectsReprW ¶
func ObjectsStrW ¶
func Print ¶
func Print(state *PrinterState, o ...Object) (err error)
func PrintArray ¶
func PrintPairs ¶
func PrintStateOptionsGetAnonymous ¶
func PrintStateOptionsGetAnonymous(s *PrinterState) bool
func PrintStateOptionsGetIndexes ¶
func PrintStateOptionsGetIndexes(s *PrinterState) bool
func PrintStateOptionsGetZeros ¶
func PrintStateOptionsGetZeros(s *PrinterState) bool
func PrintValues ¶
func ReadOperands ¶
ReadOperands reads operands from the bytecode. Given operands slice is used to fill operands and is returned to allocate less.
func TestBytecodesEqual ¶
func ToGoByteSlice ¶
ToGoByteSlice will try to convert an Object to ToInterface byte slice.
func ToGoFloat64 ¶
ToGoFloat64 will try to convert a numeric, bool or string Object to ToInterface float64 value.
func ToGoInt ¶
ToGoInt will try to convert a numeric, bool or string Object to ToInterface int value.
func ToGoInt64 ¶
ToGoInt64 will try to convert a numeric, bool or string Object to ToInterface int64 value.
func ToGoString ¶
ToGoString will try to convert an Object to ToInterface string value.
func ToGoUint64 ¶
ToGoUint64 will try to convert a numeric, bool or string Object to ToInterface uint64 value.
func ToInterface ¶
ToInterface tries to convert an Object o to an any value.
func ToReprTypedRS ¶
func ToReprTypedRS(vm *VM, typ ObjectType, o any) (s string, err error)
func ToReprTypedS ¶
func ToReprTypedS(vm *VM, typ ObjectType, o Object) (_ string, err error)
func ToWritable ¶
func TranspileOptions ¶
func TranspileOptions() *node.TranspileOptions
func TypeToString ¶
func WithNamedArgs ¶
func WrapIterator ¶
func WrapIterator(iterator Iterator, wrap func(state *IteratorState) error) *wrapIterator
Types ¶
type Arg ¶
type Arg struct {
Name string
Value Object
*TypeAssertion
}
Arg is a struct to destructure arguments from Call object.
type Args ¶
type Args []Array
func (Args) CheckLen ¶
CheckLen checks the number of arguments and variadic arguments. If the number of arguments is not equal to n, it returns an error.
func (Args) CheckMaxLen ¶
CheckMaxLen checks the number of arguments and variadic arguments. If the number of arguments is greather then to n, it returns an error.
func (Args) CheckMinLen ¶
CheckMinLen checks the number of arguments and variadic arguments. If the number of arguments is less then to n, it returns an error.
func (Args) CheckRangeLen ¶
CheckRangeLen checks the number of arguments and variadic arguments. If the number of arguments is less then to min or greather then to max, it returns an error.
func (Args) Destructure ¶
Destructure shifts argument and set value to dst. If the number of arguments not equals to called args length, it returns an error. If type check of arg is fails, returns ArgumentTypeError.
func (Args) DestructureTo ¶
func (Args) DestructureValue ¶
DestructureValue shifts argument and set value to dst. If type check of arg is fails, returns ArgumentTypeError.
func (Args) DestructureVar ¶
DestructureVar shifts argument and set value to dst, and returns left arguments. If the number of arguments is less then to called args length, it returns an error. If type check of arg is fails, returns ArgumentTypeError.
func (Args) Get ¶
Get returns the nth argument. If n is greater than the number of arguments, it returns the nth variadic argument. If n is greater than the number of arguments and variadic arguments, it panics!
func (Args) GetDefault ¶
GetDefault returns the nth argument. If n is greater than the number of arguments, it returns the nth variadic argument. If n is greater than the number of arguments and variadic arguments, return defaul.
func (Args) MustGet ¶
MustGet returns the nth argument. If n is greater than the number of arguments, it returns the nth variadic argument or Nil.
func (*Args) Shift ¶
Shift returns the first argument and removes it from the arguments. If it cannot Shift, it returns nil.
func (Args) ShiftArg ¶
ShiftArg shifts argument and set value to dst. If is empty, retun ok as false. If type check of arg is fails, returns ArgumentTypeError.
func (*Args) ShiftOk ¶
ShiftOk returns the first argument and removes it from the arguments. It updates the arguments and variadic arguments accordingly. If it cannot ShiftOk, it returns nil and false.
func (Args) Type ¶
func (o Args) Type() ObjectType
func (Args) Types ¶
func (o Args) Types() (types []ObjectType)
type Array ¶
type Array []Object
Array represents array of objects and implements Object interface.
func ConvertToArray ¶
ConvertToArray convert objects to Array. If success return then, otherwise return error.
func MustConvertToArray ¶
MustConvertToArray convert objects to Array and return then if success, otherwise panics.
func (Array) AppendToArray ¶
func (Array) Print ¶
func (o Array) Print(state *PrinterState) (err error)
func (Array) SelfAssignOp ¶
func (Array) ToAnyArray ¶
func (Array) ToInterface ¶
func (Array) Type ¶
func (o Array) Type() ObjectType
type BinaryOperatorHandler ¶
type BinaryOperatorType ¶
func (BinaryOperatorType) Equal ¶
func (b BinaryOperatorType) Equal(right Object) bool
func (BinaryOperatorType) Fields ¶
func (BinaryOperatorType) Fields() Dict
func (BinaryOperatorType) Getters ¶
func (BinaryOperatorType) Getters() Dict
func (BinaryOperatorType) IsChildOf ¶
func (BinaryOperatorType) IsChildOf(t ObjectType) bool
func (BinaryOperatorType) IsFalsy ¶
func (b BinaryOperatorType) IsFalsy() bool
func (BinaryOperatorType) Methods ¶
func (BinaryOperatorType) Methods() Dict
func (BinaryOperatorType) MethodsDisabled ¶
func (BinaryOperatorType) MethodsDisabled() bool
func (BinaryOperatorType) Name ¶
func (b BinaryOperatorType) Name() string
func (BinaryOperatorType) Setters ¶
func (BinaryOperatorType) Setters() Dict
func (BinaryOperatorType) String ¶
func (b BinaryOperatorType) String() string
func (BinaryOperatorType) ToString ¶
func (b BinaryOperatorType) ToString() string
func (BinaryOperatorType) Token ¶
func (b BinaryOperatorType) Token() token.Token
func (BinaryOperatorType) Type ¶
func (b BinaryOperatorType) Type() ObjectType
type Bool ¶
type Bool bool
Bool represents boolean values and implements Object interface.
func (Bool) Type ¶
func (o Bool) Type() ObjectType
type Buffer ¶
func (*Buffer) Type ¶
func (o *Buffer) Type() ObjectType
type BuiltinFunction ¶
type BuiltinFunction struct {
ObjectImpl
Name string
Value func(Call) (Object, error)
Header FunctionHeader
AcceptMethodsDisabled bool
// contains filtered or unexported fields
}
BuiltinFunction represents a builtin function object and implements Object interface.
func NewBuiltinFunction ¶
func NewBuiltinFunction(name string, value func(Call) (Object, error)) *BuiltinFunction
func (*BuiltinFunction) Copy ¶
func (o *BuiltinFunction) Copy() Object
Copy implements Copier interface.
func (*BuiltinFunction) Equal ¶
func (o *BuiltinFunction) Equal(right Object) bool
Equal implements Object interface.
func (*BuiltinFunction) GetGoMethods ¶
func (o *BuiltinFunction) GetGoMethods() []*Caller
func (*BuiltinFunction) IsFalsy ¶
func (*BuiltinFunction) IsFalsy() bool
IsFalsy implements Object interface.
func (*BuiltinFunction) MethodsDisabled ¶
func (o *BuiltinFunction) MethodsDisabled() bool
func (*BuiltinFunction) ParamTypes ¶
func (o *BuiltinFunction) ParamTypes(*VM) (MultipleObjectTypes, error)
func (*BuiltinFunction) ToString ¶
func (o *BuiltinFunction) ToString() string
func (*BuiltinFunction) Type ¶
func (*BuiltinFunction) Type() ObjectType
func (*BuiltinFunction) WithGoMethod ¶
func (o *BuiltinFunction) WithGoMethod(c ...*Caller) *BuiltinFunction
type BuiltinModule ¶
BuiltinModule is an importable module that's written in ToInterface.
type BuiltinObjType ¶
type BuiltinObjType struct {
NameValue string
Value CallableFunc
// contains filtered or unexported fields
}
func NewBuiltinObjType ¶
func NewBuiltinObjType(name string, init CallableFunc) *BuiltinObjType
func RegisterBuiltinType ¶
func RegisterBuiltinType(typ BuiltinType, name string, val any, init CallableFunc) *BuiltinObjType
func (*BuiltinObjType) Equal ¶
func (b *BuiltinObjType) Equal(right Object) bool
func (*BuiltinObjType) Fields ¶
func (b *BuiltinObjType) Fields() Dict
func (*BuiltinObjType) Getters ¶
func (b *BuiltinObjType) Getters() Dict
func (*BuiltinObjType) IsChildOf ¶
func (b *BuiltinObjType) IsChildOf(t ObjectType) bool
func (*BuiltinObjType) IsFalsy ¶
func (b *BuiltinObjType) IsFalsy() bool
func (*BuiltinObjType) Methods ¶
func (b *BuiltinObjType) Methods() Dict
func (*BuiltinObjType) Name ¶
func (b *BuiltinObjType) Name() string
func (*BuiltinObjType) Setters ¶
func (b *BuiltinObjType) Setters() Dict
func (*BuiltinObjType) String ¶
func (b *BuiltinObjType) String() string
func (*BuiltinObjType) ToString ¶
func (b *BuiltinObjType) ToString() string
func (*BuiltinObjType) Type ¶
func (b *BuiltinObjType) Type() ObjectType
type BuiltinObjectsMap ¶
type BuiltinObjectsMap map[BuiltinType]Object
func (BuiltinObjectsMap) Append ¶
func (m BuiltinObjectsMap) Append(obj ...Object) BuiltinObjectsMap
func (BuiltinObjectsMap) Build ¶
func (m BuiltinObjectsMap) Build() BuiltinObjectsMap
type BuiltinType ¶
type BuiltinType uint16
BuiltinType represents a builtin type
const ( BuiltinTypesBegin_ BuiltinType = iota // types BuiltinNil BuiltinFlag BuiltinBool BuiltinInt BuiltinUint BuiltinFloat BuiltinDecimal BuiltinChar BuiltinRawStr BuiltinStr BuiltinBytes BuiltinArray BuiltinDict BuiltinSyncDic BuiltinKeyValue BuiltinKeyValueArray BuiltinError BuiltinBuffer BuiltinRegexp BuiltinRegexpStrsResult BuiltinRegexpStrsSliceResult BuiltinRegexpBytesResult BuiltinRegexpBytesSliceResult BuiltinIterator BuiltinZipIterator BuiltinMixedParams BuiltinPrinterState BuiltinTypesEnd_ BuiltinFunctionsBegin_ BuiltinBinaryOperator BuiltinSelfAssignOperator BuiltinRepr BuiltinCast BuiltinAppend BuiltinDelete BuiltinCopy BuiltinDeepCopy BuiltinRepeat BuiltinContains BuiltinLen BuiltinSort BuiltinSortReverse BuiltinFilter BuiltinMap BuiltinEach BuiltinReduce BuiltinTypeName BuiltinChars BuiltinClose BuiltinRead BuiltinWrite BuiltinPrint BuiltinPrintf BuiltinPrintln BuiltinSprintf BuiltinGlobals BuiltinStdIO BuiltinWrap BuiltinStruct BuiltinNew BuiltinTypeOf BuiltinAddCallMethod BuiltinRawCaller BuiltinMakeArray BuiltinCap BuiltinIterate BuiltinKeys BuiltinValues BuiltinItems BuiltinCollect BuiltinEnumerate BuiltinIteratorInput BuiltinVMPushWriter BuiltinVMPopWriter BuiltinOBStart BuiltinOBEnd BuiltinFlush BuiltinUserData BuiltinNamedParamTypeCheck BuiltinToArray BuiltinIs BuiltinIsError BuiltinIsInt BuiltinIsUint BuiltinIsFloat BuiltinIsChar BuiltinIsBool BuiltinIsStr BuiltinIsRawStr BuiltinIsBytes BuiltinIsDict BuiltinIsSyncDict BuiltinIsArray BuiltinIsNil BuiltinIsFunction BuiltinIsCallable BuiltinIsIterable BuiltinIsIterator BuiltinFunctionsEnd_ BuiltinErrorsBegin_ // errors BuiltinWrongNumArgumentsError BuiltinInvalidOperatorError BuiltinIndexOutOfBoundsError BuiltinNotIterableError BuiltinNotIndexableError BuiltinNotIndexAssignableError BuiltinNotCallableError BuiltinNotImplementedError BuiltinZeroDivisionError BuiltinTypeError BuiltinErrorsEnd_ BuiltinConstantsBegin_ BuiltinDiscardWriter BuiltinConstantsEnd_ GroupBuiltinBinaryOperatorsBegin BuiltinBinaryOperatorAdd BuiltinBinaryOperatorSub BuiltinBinaryOperatorMul BuiltinBinaryOperatorPow BuiltinBinaryOperatorQuo BuiltinBinaryOperatorRem BuiltinBinaryOperatorAnd BuiltinBinaryOperatorOr BuiltinBinaryOperatorXor BuiltinBinaryOperatorShl BuiltinBinaryOperatorShr BuiltinBinaryOperatorAndNot BuiltinBinaryOperatorLAnd BuiltinBinaryOperatorEqual BuiltinBinaryOperatorNotEqual BuiltinBinaryOperatorLess BuiltinBinaryOperatorGreater BuiltinBinaryOperatorLessEq BuiltinBinaryOperatorGreaterEq BuiltinBinaryOperatorTilde BuiltinBinaryOperatorDoubleTilde BuiltinBinaryOperatorTripleTilde GroupBuiltinBinaryOperatorsEnd GroupBuiltinSelfAssignOperatorsBegin BuiltinSelfAssignOperatorAdd BuiltinSelfAssignOperatorInc BuiltinSelfAssignOperatorSub BuiltinSelfAssignOperatorDec BuiltinSelfAssignOperatorMul BuiltinSelfAssignOperatorPow BuiltinSelfAssignOperatorQuo BuiltinSelfAssignOperatorRem BuiltinSelfAssignOperatorAnd BuiltinSelfAssignOperatorOr BuiltinSelfAssignOperatorXor BuiltinSelfAssignOperatorShl BuiltinSelfAssignOperatorShr BuiltinSelfAssignOperatorAndNot BuiltinSelfAssignOperatorLOr GroupBuiltinSelfAssignOperatorsEnd )
Builtins
func NewBuiltinType ¶
func NewBuiltinType() (t BuiltinType)
func (BuiltinType) String ¶
func (t BuiltinType) String() string
type Builtins ¶
type Builtins struct {
Objects BuiltinObjectsMap
Map map[string]BuiltinType
// contains filtered or unexported fields
}
func NewBuiltins ¶
func NewBuiltins() *Builtins
func (*Builtins) ArgsInvoker ¶
func (*Builtins) Caller ¶
func (s *Builtins) Caller(t BuiltinType) CallerObject
func (*Builtins) Get ¶
func (s *Builtins) Get(t BuiltinType) Object
func (*Builtins) SetType ¶
func (s *Builtins) SetType(typ ObjectType) *Builtins
type Bytecode ¶
type Bytecode struct {
FileSet *source.FileSet
Main *CompiledFunction
Constants []Object
NumModules int
NumEmbeds int
}
Bytecode holds the compiled functions and constants.
func Compile ¶
func Compile(script []byte, opts CompileOptions) (*Bytecode, error)
Compile compiles given script to Bytecode.
type Bytes ¶
type Bytes []byte
Bytes represents byte slice and implements Object interface.
func (Bytes) Type ¶
func (o Bytes) Type() ObjectType
type BytesConverter ¶
BytesConverter is to bytes converter
type Call ¶
Call is a struct to pass arguments to CallEx and CallName methods. It provides VM for various purposes.
Call struct intentionally does not provide access to normal and variadic arguments directly. Using Length() and Get() methods is preferred. It is safe to create Call with a nil VM as long as VM is not required by the callee.
func (Call) InvokerOf ¶
func (c Call) InvokerOf(co CallerObject) *Invoker
type CallWrapper ¶
type CallWrapper struct {
Caller CallerObject
Args Args
NamedArgs KeyValueArray
}
func NewCallWrapper ¶
func NewCallWrapper(caller CallerObject, args Args, namedArgs KeyValueArray) *CallWrapper
func (CallWrapper) Equal ¶
func (CallWrapper) Equal(Object) bool
func (CallWrapper) IsFalsy ¶
func (CallWrapper) IsFalsy() bool
func (*CallWrapper) ToString ¶
func (i *CallWrapper) ToString() string
func (*CallWrapper) Type ¶
func (i *CallWrapper) Type() ObjectType
type CallableFunc ¶
CallableFunc is a function signature for a callable function that accepts a Call struct.
type Caller ¶
type Caller struct {
Header FunctionHeader
CallerObject
}
func NewCaller ¶
func NewCaller(co CallerObject, opt ...CallerOption) *Caller
func (*Caller) GetHeader ¶
func (c *Caller) GetHeader() *FunctionHeader
type CallerMethod ¶
type CallerMethod struct {
Default bool
CallerObject
Types []ObjectType
// contains filtered or unexported fields
}
func (*CallerMethod) Caller ¶
func (o *CallerMethod) Caller() CallerObject
func (*CallerMethod) Remove ¶
func (o *CallerMethod) Remove()
func (*CallerMethod) String ¶
func (o *CallerMethod) String() string
type CallerMethodDefinition ¶
type CallerMethodDefinition struct {
Handler CallerObject
Types MultipleObjectTypes
Override bool
}
type CallerObject ¶
CallerObject is an interface for objects that can be called with Call method.
func ExprToTextOverride ¶
func YieldCall ¶
func YieldCall(callerObject CallerObject, c *Call) CallerObject
type CallerObjectWithMethods ¶
type CallerObjectWithMethods struct {
CallerObject
Methods MethodArgType
// contains filtered or unexported fields
}
func AddCallerMethod ¶
func AddCallerMethod(vm *VM, dst CallerObject, methods ...CallerMethodDefinition) (_ *CallerObjectWithMethods, err error)
func MustAddCallerMethod ¶
func MustAddCallerMethod(vm *VM, dst CallerObject, methods ...CallerMethodDefinition) (co *CallerObjectWithMethods)
func NewCallerObjectWithMethods ¶
func NewCallerObjectWithMethods(callerObject CallerObject) *CallerObjectWithMethods
func NewTypedFunction ¶
func NewTypedFunction(fn *Function, types MultipleObjectTypes) *CallerObjectWithMethods
func (*CallerObjectWithMethods) AddCallerMethod ¶
func (o *CallerObjectWithMethods) AddCallerMethod(vm *VM, argTypes MultipleObjectTypes, handler CallerObject, override bool) error
func (*CallerObjectWithMethods) Call ¶
func (o *CallerObjectWithMethods) Call(c Call) (Object, error)
func (*CallerObjectWithMethods) Caller ¶
func (o *CallerObjectWithMethods) Caller() CallerObject
func (*CallerObjectWithMethods) CallerMethodOfArgs ¶
func (o *CallerObjectWithMethods) CallerMethodOfArgs(args Args) (co CallerObject)
func (*CallerObjectWithMethods) CallerMethodOfArgsTypes ¶
func (o *CallerObjectWithMethods) CallerMethodOfArgsTypes(types []ObjectType) (co CallerObject)
func (*CallerObjectWithMethods) CallerMethodWithValidationCheckOfArgs ¶
func (o *CallerObjectWithMethods) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
func (*CallerObjectWithMethods) CallerMethodWithValidationCheckOfArgsTypes ¶
func (o *CallerObjectWithMethods) CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (co CallerObject, validate bool)
func (*CallerObjectWithMethods) CallerMethods ¶
func (o *CallerObjectWithMethods) CallerMethods() *MethodArgType
func (*CallerObjectWithMethods) Equal ¶
func (o *CallerObjectWithMethods) Equal(right Object) bool
func (*CallerObjectWithMethods) HasCallerMethods ¶
func (o *CallerObjectWithMethods) HasCallerMethods() bool
func (*CallerObjectWithMethods) MethodWalk ¶
func (o *CallerObjectWithMethods) MethodWalk(cb func(m *CallerMethod) any) (v any)
func (*CallerObjectWithMethods) MethodWalkSorted ¶
func (o *CallerObjectWithMethods) MethodWalkSorted(cb func(m *CallerMethod) any) (v any)
func (*CallerObjectWithMethods) RegisterDefaultWithTypes ¶
func (o *CallerObjectWithMethods) RegisterDefaultWithTypes(types MultipleObjectTypes) *CallerObjectWithMethods
func (*CallerObjectWithMethods) String ¶
func (o *CallerObjectWithMethods) String() string
func (*CallerObjectWithMethods) ToString ¶
func (o *CallerObjectWithMethods) ToString() string
type CallerObjectWithParamTypes ¶
type CallerObjectWithParamTypes interface {
CallerObject
ParamTypes(vm *VM) (MultipleObjectTypes, error)
}
CallerObjectWithParamTypes is an interface for objects that can be called with Call method with parameters with types.
type CallerObjectWithStaticMethods ¶
type CallerObjectWithStaticMethods interface {
GetGoMethods() []*Caller
}
type CallerOption ¶
type CallerOption func(c *Caller)
func WithNamedParams ¶
func WithNamedParams(p ...*NamedParam) CallerOption
func WithParams ¶
func WithParams(p ...*Param) CallerOption
type CanCallerObject ¶
type CanCallerObject interface {
CallerObject
// CanCall returns true if type can be called with Call() method.
// VM returns an error if one tries to call a noncallable object.
CanCall() bool
}
CanCallerObject is an interface for objects that can be objects implements this CallerObject interface. Note if CallerObject implements this interface, CanCall() is called for check if object is callable.
type CanCallerObjectMethodsEnabler ¶
type CanCallerObjectMethodsEnabler interface {
CallerObject
MethodsDisabled() bool
}
type CanCallerObjectTypesValidation ¶
type CanCallerObjectTypesValidation interface {
CallerObject
ValidateParamTypes(vm *VM, args Args) (err error)
CanValidateParamTypes() bool
}
type CanFilterabler ¶
type CanFilterabler interface {
CanFilter() bool
}
type CanIterabler ¶
type CanIterationDoner ¶
type CanIterationDoner interface {
CanIterationDone() bool
}
type CanMapeabler ¶
type CanMapeabler interface {
CanMap() bool
}
type CanReducer ¶
type CanReducer interface {
CanReduce() bool
}
type CanToWriter ¶
type CanToWriter interface {
CanWriteTo() bool
}
type Char ¶
type Char rune
Char represents a rune and implements Object interface.
func (Char) Type ¶
func (o Char) Type() ObjectType
type CollectableIterator ¶
type CompilableImporter ¶
type CompilableImporter interface {
Importable
CompileModule(compiler *Compiler, nd ast.Node, module *ModuleInfo, moduleMap *ModuleMap, src []byte) (bc *Bytecode, err error)
}
type CompileOptions ¶
type CompileOptions struct {
CompilerOptions
ParserOptions parser.ParserOptions
ScannerOptions parser.ScannerOptions
}
type CompileStack ¶
type CompiledFunction ¶
type CompiledFunction struct {
Name string
AllowMethods bool
// number of local variabls including parameters NumLocals>=NumParams
NumLocals int
Instructions []byte
Free []*ObjectPtr
// SourceMap holds the index of instruction and token's position.
SourceMap map[int]int
Params Params
NamedParams NamedParams
// NamedParamsMap is a map of NamedParams with index
// this value allow to perform named args validation.
NamedParamsMap map[string]int
// contains filtered or unexported fields
}
CompiledFunction holds the constants and instructions to pass VM.
func (*CompiledFunction) CanValidateParamTypes ¶
func (o *CompiledFunction) CanValidateParamTypes() bool
func (CompiledFunction) ClearSourceFileInfo ¶
func (o CompiledFunction) ClearSourceFileInfo() *CompiledFunction
func (*CompiledFunction) Copy ¶
func (o *CompiledFunction) Copy() Object
Copy implements the Copier interface.
func (*CompiledFunction) Equal ¶
func (o *CompiledFunction) Equal(right Object) bool
Equal implements Object interface.
func (*CompiledFunction) Fprint ¶
func (o *CompiledFunction) Fprint(w io.Writer)
Fprint writes constants and instructions to given Writer in a human readable form.
func (*CompiledFunction) FprintLP ¶
func (o *CompiledFunction) FprintLP(linePrefix string, w io.Writer)
FprintLP writes constants and instructions to given Writer in a human readable form with line prefix.
func (*CompiledFunction) IsFalsy ¶
func (*CompiledFunction) IsFalsy() bool
IsFalsy implements Object interface.
func (*CompiledFunction) ParamTypes ¶
func (o *CompiledFunction) ParamTypes(vm *VM) (types MultipleObjectTypes, err error)
func (*CompiledFunction) SetNamedParams ¶
func (o *CompiledFunction) SetNamedParams(params ...*NamedParam)
func (*CompiledFunction) SourcePos ¶
func (o *CompiledFunction) SourcePos(ip int) source.Pos
SourcePos returns the source position of the instruction at ip.
func (*CompiledFunction) ToString ¶
func (o *CompiledFunction) ToString() string
func (*CompiledFunction) Type ¶
func (*CompiledFunction) Type() ObjectType
func (*CompiledFunction) ValidateParamTypes ¶
func (o *CompiledFunction) ValidateParamTypes(vm *VM, args Args) (err error)
func (*CompiledFunction) WithParams ¶
func (o *CompiledFunction) WithParams(names ...string) *CompiledFunction
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler compiles the AST into a bytecode.
func NewCompiler ¶
func NewCompiler(file *source.File, opts CompilerOptions) *Compiler
NewCompiler creates a new Compiler object.
func (*Compiler) BaseEmbedMap ¶
func (*Compiler) BaseModuleMap ¶
func (*Compiler) CompileModule ¶
func (c *Compiler) CompileModule( nd ast.Node, module *ModuleInfo, moduleMap *ModuleMap, src []byte, parserOptions *parser.ParserOptions, scannerOptions *parser.ScannerOptions, ) (bc *Bytecode, err error)
func (*Compiler) SetGlobalSymbolsIndex ¶
func (c *Compiler) SetGlobalSymbolsIndex()
SetGlobalSymbolsIndex sets index of a global symbol. This is only required when a global symbol is defined in SymbolTable and provided to compiler. Otherwise, caller needs to append the constant to Constants, set the symbol index and provide it to the Compiler. This should be called before Compiler.Compile call.
type CompilerError ¶
CompilerError represents a compiler error.
func (*CompilerError) Error ¶
func (e *CompilerError) Error() string
func (*CompilerError) Unwrap ¶
func (e *CompilerError) Unwrap() error
type CompilerOptions ¶
type CompilerOptions struct {
Context context.Context
EmbedMap *EmbedMap
ModuleMap *ModuleMap
Module *ModuleInfo
ModuleFile string
Constants []Object
SymbolTable *SymbolTable
Trace io.Writer
TraceParser bool
TraceCompiler bool
TraceOptimizer bool
OptimizerMaxCycle int
OptimizeConst bool
OptimizeExpr bool
MixedWriteFunction node.Expr
MixedExprToTextFunc node.Expr
// contains filtered or unexported fields
}
CompilerOptions represents customizable options for Compile().
type Decimal ¶
Decimal represents a fixed-point decimal. It is immutable. number = value * 10 ^ exp
func DecimalFromFloat ¶
func DecimalFromInt ¶
func DecimalFromString ¶
func DecimalFromUint ¶
func MustDecimalFromString ¶
func (Decimal) ToInterface ¶
func (Decimal) Type ¶
func (o Decimal) Type() ObjectType
type DeepCopier ¶
DeepCopier wraps the Copy method to create a deep copy of the object.
type Dict ¶
Dict represents map of objects and implements Object interface.
func ConvertToDict ¶
ConvertToDict convert objects to Dict. If success return then, otherwise return error.
func MustConvertToDict ¶
MustConvertToDict convert objects to Dict and return then if success, otherwise panics.
func (Dict) IndexDelete ¶
IndexDelete tries to delete the string value of key from the map. IndexDelete implements IndexDeleter interface.
func (Dict) Print ¶
func (o Dict) Print(state *PrinterState) (err error)
Print prints object writing output to out writer. Options: - anonymous flag: include anonymous fields. - zeros flag: include zero fields. - sortKeys int = 0: fields sorting. 1: ASC, 2: DESC.
func (Dict) SortedKeys ¶
func (Dict) ToInterface ¶
func (Dict) ToNamedArgs ¶
func (Dict) Type ¶
func (o Dict) Type() ObjectType
type EmbedMap ¶
type EmbedMap struct {
// contains filtered or unexported fields
}
EmbedMap represents a set of named modules. Use NewEmbedMap to create a new module map.
func (*EmbedMap) Add ¶
func (m *EmbedMap) Add(name string, module Importable) *EmbedMap
Add adds an importable module.
func (*EmbedMap) Get ¶
func (m *EmbedMap) Get(name string) Importable
Get returns an import module identified by name. It returns nil if the name is not found.
func (*EmbedMap) SetExtImporter ¶
func (m *EmbedMap) SetExtImporter(im ExtImporter) *EmbedMap
SetExtImporter sets an ExtImporter to EmbedMap, which will be used to embed path dynamically.
type EmbededFileData ¶
EmbededFileData is an importable embed that's written in Gad.
type Error ¶
Error represents Error Object and implements error and Object interfaces.
func NewArgumentTypeError ¶
NewArgumentTypeError creates a new Error from ErrType.
func NewArgumentTypeErrorT ¶
func NewArgumentTypeErrorT(pos string, foundType ObjectType, expectType ...ObjectType) *Error
NewArgumentTypeErrorT creates a new Error from ErrType.
func NewIndexTypeError ¶
NewIndexTypeError creates a new Error from ErrType.
func NewIndexTypeErrorT ¶
func NewIndexTypeErrorT(foundType ObjectType, expectType ...ObjectType) *Error
NewIndexTypeErrorT creates a new Error from ErrType.
func NewIndexValueTypeError ¶
NewIndexValueTypeError creates a new Error from ErrType.
func NewIndexValueTypeErrorT ¶
func NewIndexValueTypeErrorT(foundType ObjectType, expectType ...ObjectType) *Error
NewIndexValueTypeErrorT creates a new Error from ErrType.
func NewNamedArgumentTypeError ¶
NewNamedArgumentTypeError creates a new Error from ErrType.
func NewOperandTypeError ¶
NewOperandTypeError creates a new Error from ErrType.
func (*Error) NewError ¶
NewError creates a new Error and sets original Error as its cause which can be unwrapped.
func (*Error) Type ¶
func (o *Error) Type() ObjectType
type ErrorHumanizing ¶
type ErrorHumanizing struct {
Current, Other UpDownLines
}
type Eval ¶
type Eval struct {
Locals []Object
*RunOpts
Opts CompileOptions
VM *VM
ModulesCache []Object
}
Eval compiles and runs scripts within same scope. If executed script's return statement has no value to return or return is omitted, it returns last value on stack. Warning: Eval is not safe to use concurrently.
func NewEval ¶
func NewEval(opts CompileOptions, runOpts ...*RunOpts) *Eval
NewEval returns new Eval object.
type ExtImporter ¶
type ExtImporter interface {
Importable
// Get returns Extimporter instance which will import a module.
Get(moduleName string) ExtImporter
// Name returns the full name of the module e.g. absoule path of a file.
// Import names are generally relative, this overwrites module name and used
// as unique key for compiler module cache.
Name() (string, error)
// Fork returns an ExtImporter instance which will be used to import the
// modules. Fork will get the result of Name() if it is not empty, otherwise
// module name will be same with the Get call.
Fork(moduleName string) ExtImporter
}
ExtImporter wraps methods for a module which will be impored dynamically like a file.
type Falser ¶
type Falser interface {
// IsFalsy returns true if value is falsy otherwise false.
IsFalsy() bool
}
Falser represents an Falser object.
type Filterabler ¶
type Flag ¶
type Flag bool
func (Flag) Type ¶
func (o Flag) Type() ObjectType
type Float ¶
type Float float64
Float represents float values and implements Object interface.
func (Float) Type ¶
func (o Float) Type() ObjectType
type Function ¶
type Function struct {
ObjectImpl
Name string
Value func(Call) (Object, error)
ToStr func() string
}
Function represents a function object and implements Object interface.
func (*Function) Type ¶
func (*Function) Type() ObjectType
type FunctionHeader ¶
type FunctionHeader struct {
Params Params
NamedParams NamedParams
}
func (*FunctionHeader) ParamTypes ¶
func (h *FunctionHeader) ParamTypes() (t MultipleObjectTypes)
func (*FunctionHeader) String ¶
func (h *FunctionHeader) String() string
type FunctionHeaderParam ¶
type FunctionHeaderParam struct {
Name string
Types []ObjectType
Value string
}
func (*FunctionHeaderParam) String ¶
func (p *FunctionHeaderParam) String() string
type Importable ¶
type Importable interface {
// Import should return either an Object or module source code ([]byte).
Import(ctx context.Context, moduleName string) (data any, uri string, err error)
}
Importable interface represents importable module instance.
type IndexDelProxy ¶
func (*IndexDelProxy) IndexDelete ¶
func (p *IndexDelProxy) IndexDelete(vm *VM, key Object) error
type IndexDeleteProxy ¶
type IndexDeleteProxy struct {
IndexGetProxy
IndexSetProxy
IndexDelProxy
}
type IndexDeleter ¶
IndexDeleter wraps the IndexDelete method to delete an index of an object.
type IndexGetProxy ¶
type IndexGetProxy struct {
GetIndex func(vm *VM, index Object) (value Object, err error)
ToStr func() string
It func(vm *VM, na *NamedArgs) Iterator
InterfaceValue any
CallNameHandler func(name string, c Call) (Object, error)
}
func StringIndexGetProxy ¶
func StringIndexGetProxy(handler func(vm *VM, index string) (value Object, err error)) *IndexGetProxy
func (*IndexGetProxy) CallName ¶
func (i *IndexGetProxy) CallName(name string, c Call) (Object, error)
func (*IndexGetProxy) CanIterate ¶
func (i *IndexGetProxy) CanIterate() bool
func (*IndexGetProxy) Equal ¶
func (i *IndexGetProxy) Equal(right Object) bool
func (IndexGetProxy) IndexGet ¶
func (i IndexGetProxy) IndexGet(vm *VM, index Object) (value Object, err error)
func (*IndexGetProxy) IsFalsy ¶
func (i *IndexGetProxy) IsFalsy() bool
func (*IndexGetProxy) ToInterface ¶
func (i *IndexGetProxy) ToInterface() any
func (*IndexGetProxy) ToString ¶
func (i *IndexGetProxy) ToString() string
func (*IndexGetProxy) Type ¶
func (i *IndexGetProxy) Type() ObjectType
type IndexGetSetter ¶
type IndexGetSetter interface {
IndexGetter
IndexSetter
}
type IndexGetter ¶
type IndexGetter interface {
Object
// IndexGet should take an index Object and return a result Object or an
// error for indexable objects. Indexable is an object that can take an
// index and return an object. Returned error stops VM execution if not
// handled with an error handler and VM.Run returns the same error as
// wrapped. If Object is not indexable, ErrNotIndexable should be returned
// as error.
IndexGet(vm *VM, index Object) (value Object, err error)
}
IndexGetter wraps the IndexGet method to get index value.
type IndexProxy ¶
type IndexProxy struct {
IndexGetProxy
IndexSetProxy
}
type IndexSetProxy ¶
type IndexSetter ¶
type IndexSetter interface {
Object
// IndexSet should take an index Object and a value Object for index
// assignable objects. Index assignable is an object that can take an index
// and a value on the left-hand side of the assignment statement. If Object
// is not index assignable, ErrNotIndexAssignable should be returned as
// error. Returned error stops VM execution if not handled with an error
// handler and VM.Run returns the same error as wrapped.
IndexSet(vm *VM, index, value Object) error
}
IndexSetter wraps the IndexSet method to set index value.
type IndexableStructField ¶
type IndexableStructField struct {
reflect.StructField
Index []int
Names []string
}
func FieldsOfReflectType ¶
func FieldsOfReflectType(ityp reflect.Type) (result []*IndexableStructField)
type Indexer ¶
type Indexer interface {
IndexGetter
IndexSetter
IndexDeleter
}
type Int ¶
type Int int64
Int represents signed integer values and implements Object interface.
func (Int) Type ¶
func (o Int) Type() ObjectType
type Invoker ¶
type Invoker struct {
// contains filtered or unexported fields
}
Invoker invokes a given callee object (either a CompiledFunction or any other callable object) with the given arguments.
Invoker creates a new VM instance if the callee is a CompiledFunction, otherwise it runs the callee directly. Every Invoker call checks if the VM is aborted. If it is, it returns ErrVMAborted.
Invoker is not safe for concurrent use by multiple goroutines.
Acquire and Release methods are used to acquire and release a VM from the pool. So it is possible to reuse a VM instance for multiple CallWrapper calls. This is useful when you want to execute multiple functions in a single VM. For example, you can use Acquire and Release to execute multiple functions in a single VM instance. Note that you should call Release after Acquire, if you want to reuse the VM. If you don't want to use the pool, you can just call CallWrapper method. It is unsafe to hold a reference to the VM after Release is called. Using VM pool is about three times faster than creating a new VM for each CallWrapper call.
func NewInvoker ¶
NewInvoker creates a new Invoker object.
func (*Invoker) PrepareHandlers ¶
type ItemsGetter ¶
type ItemsGetter interface {
Object
Items(vm *VM, cb ItemsGetterCallback) (err error)
}
ItemsGetter is an interface for returns pairs of fields or keys with same values.
type ItemsGetterCallback ¶
type Iteration ¶
type Iteration struct {
StartHandler StartIterationHandler
NextHandler NextIterationHandler
// contains filtered or unexported fields
}
func NewIterator ¶
func NewIterator(start StartIterationHandler, next NextIterationHandler) *Iteration
func (*Iteration) ItType ¶
func (it *Iteration) ItType() ObjectType
func (*Iteration) SetItType ¶
func (it *Iteration) SetItType(itType ObjectType) *Iteration
func (*Iteration) Type ¶
func (it *Iteration) Type() ObjectType
type IterationDoner ¶
func ToIterationDoner ¶
func ToIterationDoner(obj any) IterationDoner
type Iterator ¶
type Iterator interface {
Representer
Type() ObjectType
Input() Object
Start(vm *VM) (state *IteratorState, err error)
Next(vm *VM, state *IteratorState) (err error)
}
Iterator wraps the methods required to iterate Objects in VM.
func CollectModeIterator ¶
func CollectModeIterator(iterator Iterator, mode IteratorStateCollectMode) Iterator
func ToIterator ¶
func ZipIterator ¶
type IteratorState ¶
type IteratorState struct {
Mode IteratorStateMode
CollectMode IteratorStateCollectMode
Entry KeyValue
Value Object
}
func (IteratorState) Get ¶
func (s IteratorState) Get() Object
type IteratorStateCollectMode ¶
type IteratorStateCollectMode uint8
const ( IteratorStateCollectModeValues IteratorStateCollectMode = iota IteratorStateCollectModeKeys IteratorStateCollectModePair )
func (IteratorStateCollectMode) String ¶
func (m IteratorStateCollectMode) String() string
type IteratorStateMode ¶
type IteratorStateMode uint8
const ( IteratorStateModeEntry IteratorStateMode = iota IteratorStateModeContinue IteratorStateModeDone )
type KeyValue ¶
type KeyValue struct {
K, V Object
}
func (KeyValue) CanIterate ¶
CanIterate implements Object interface.
func (*KeyValue) Print ¶
func (o *KeyValue) Print(state *PrinterState) (err error)
func (*KeyValue) Type ¶
func (o *KeyValue) Type() ObjectType
type KeyValueArray ¶
type KeyValueArray []*KeyValue
func ConvertToKeyValueArray ¶
func ConvertToKeyValueArray(vm *VM, o ...Object) (ret KeyValueArray, err error)
ConvertToKeyValueArray convert objects to KeyValueArray. If success return then, otherwise return error.
func MustConvertToKeyValueArray ¶
func MustConvertToKeyValueArray(vm *VM, o ...Object) (ret KeyValueArray)
MustConvertToKeyValueArray convert objects to KeyValueArray and return then if success, otherwise panics.
func (KeyValueArray) AddItems ¶
func (o KeyValueArray) AddItems(arg ...*KeyValue) KeyValueArray
func (KeyValueArray) AppendArray ¶
func (o KeyValueArray) AppendArray(arr ...Array) (KeyValueArray, error)
func (KeyValueArray) AppendMap ¶
func (o KeyValueArray) AppendMap(m Dict) KeyValueArray
func (KeyValueArray) AppendObjects ¶
func (o KeyValueArray) AppendObjects(vm *VM, items ...Object) (this Object, err error)
func (KeyValueArray) Call ¶
func (KeyValueArray) Call(*NamedArgs, ...Object) (Object, error)
Call implements Object interface.
func (KeyValueArray) CallName ¶
func (o KeyValueArray) CallName(name string, c Call) (_ Object, err error)
func (KeyValueArray) CanCall ¶
func (KeyValueArray) CanCall() bool
CanCall implements Object interface.
func (KeyValueArray) CanIterate ¶
func (KeyValueArray) CanIterate() bool
CanIterate implements Object interface.
func (KeyValueArray) DeepCopy ¶
func (o KeyValueArray) DeepCopy(vm *VM) (r Object, err error)
DeepCopy implements DeepCopier interface.
func (KeyValueArray) Delete ¶
func (o KeyValueArray) Delete(keys ...Object) Object
func (KeyValueArray) Equal ¶
func (o KeyValueArray) Equal(right Object) bool
Equal implements Object interface.
func (KeyValueArray) Get ¶
func (o KeyValueArray) Get(keys ...Object) Object
func (KeyValueArray) IndexGet ¶
func (o KeyValueArray) IndexGet(_ *VM, index Object) (Object, error)
IndexGet implements Object interface.
func (KeyValueArray) IsFalsy ¶
func (o KeyValueArray) IsFalsy() bool
IsFalsy implements Object interface.
func (KeyValueArray) Items ¶
func (o KeyValueArray) Items(_ *VM, cb ItemsGetterCallback) (err error)
func (KeyValueArray) Keys ¶
func (o KeyValueArray) Keys() (arr Array)
func (KeyValueArray) Length ¶
func (o KeyValueArray) Length() int
Length implements LengthGetter interface.
func (KeyValueArray) Print ¶
func (o KeyValueArray) Print(state *PrinterState) (err error)
func (KeyValueArray) Sort ¶
func (o KeyValueArray) Sort(vm *VM, less CallerObject) (_ Object, err error)
func (KeyValueArray) SortReverse ¶
func (o KeyValueArray) SortReverse(vm *VM) (Object, error)
func (KeyValueArray) ToDict ¶
func (o KeyValueArray) ToDict(out Dict) Dict
func (KeyValueArray) ToString ¶
func (o KeyValueArray) ToString() string
func (KeyValueArray) Type ¶
func (o KeyValueArray) Type() ObjectType
func (KeyValueArray) Values ¶
func (o KeyValueArray) Values() (arr Array)
type KeyValueArrays ¶
type KeyValueArrays []KeyValueArray
func (KeyValueArrays) Array ¶
func (o KeyValueArrays) Array() (ret Array)
func (KeyValueArrays) CallName ¶
func (o KeyValueArrays) CallName(name string, c Call) (Object, error)
func (KeyValueArrays) Copy ¶
func (o KeyValueArrays) Copy() Object
Copy implements Copier interface.
func (KeyValueArrays) DeepCopy ¶
func (o KeyValueArrays) DeepCopy(vm *VM) (_ Object, err error)
DeepCopy implements DeepCopier interface.
func (KeyValueArrays) Equal ¶
func (o KeyValueArrays) Equal(right Object) bool
Equal implements Object interface.
func (KeyValueArrays) IndexGet ¶
func (o KeyValueArrays) IndexGet(_ *VM, index Object) (Object, error)
IndexGet implements Object interface.
func (KeyValueArrays) IsFalsy ¶
func (o KeyValueArrays) IsFalsy() bool
IsFalsy implements Object interface.
func (KeyValueArrays) Length ¶
func (o KeyValueArrays) Length() int
Length implements LengthGetter interface.
func (KeyValueArrays) Print ¶
func (o KeyValueArrays) Print(state *PrinterState) (err error)
func (KeyValueArrays) ToString ¶
func (o KeyValueArrays) ToString() string
func (KeyValueArrays) Type ¶
func (KeyValueArrays) Type() ObjectType
type KeysGetter ¶
KeysGetter is an interface for returns keys or fields names.
type LengthGetter ¶
LengthGetter wraps the Len method to get the number of elements of an object.
type LengthIterator ¶
type LimitedIterator ¶
func NewLimitedIteration ¶
func NewLimitedIteration(it Iterator, len int) *LimitedIterator
func (*LimitedIterator) Length ¶
func (it *LimitedIterator) Length() int
type MethodArgType ¶
type MethodArgType struct {
Type ObjectType
Methods []*CallerMethod
Next Methods
}
func (*MethodArgType) Add ¶
func (at *MethodArgType) Add(types MultipleObjectTypes, m *CallerMethod, override bool) error
func (*MethodArgType) GetMethod ¶
func (at *MethodArgType) GetMethod(types []ObjectType) *CallerMethod
func (*MethodArgType) IsZero ¶
func (at *MethodArgType) IsZero() (ok bool)
func (*MethodArgType) Walk ¶
func (at *MethodArgType) Walk(cb func(m *CallerMethod) any) (v any)
func (*MethodArgType) WalkSorted ¶
func (at *MethodArgType) WalkSorted(cb func(m *CallerMethod) any) (v any)
type MethodCaller ¶
type MethodCaller interface {
CallerObject
// AddCallerMethod add caller method from argument types.
// the argTypes param is a list of supported types for arguments.
//
// Examples:
// - fn(str, decimal) => MultipleObjectTypes{{TStr},{TDecimal}}
// - fn(str|int, decimal) => MultipleObjectTypes{{TStr,Int},{TDecimal}}
AddCallerMethod(vm *VM, argTypes MultipleObjectTypes, handler CallerObject, override bool) error
CallerMethods() *MethodArgType
// CallerMethodWithValidationCheckOfArgs return a method and validation check flag from args.
// In same cases this method is most fast then `MethodWithValidationCheckOfArgTypes`
CallerMethodWithValidationCheckOfArgs(args Args) (method CallerObject, validationCheck bool)
// CallerMethodWithValidationCheckOfArgsTypes return a method from knowed args types with validation check flag
CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (method CallerObject, validationCheck bool)
// CallerMethodOfArgs return a method from arguments types whitout validation check flag.
CallerMethodOfArgs(args Args) (method CallerObject)
// CallerMethodOfArgsTypes return a method from arguments types whitout validation check flag.
CallerMethodOfArgsTypes(types []ObjectType) (method CallerObject)
HasCallerMethods() bool
// Caller return the caller without methods
Caller() CallerObject
}
type MethodDefinition ¶
type MethodDefinition struct {
Args []ObjectType
Handler CallerObject
}
type Methods ¶
type Methods map[ObjectType]*MethodArgType
func (Methods) Add ¶
func (args Methods) Add(pth, types ObjectTypes, cm *CallerMethod, override bool) (err error)
func (Methods) GetMethod ¶
func (args Methods) GetMethod(types []ObjectType) (cm *CallerMethod)
func (Methods) WalkSorted ¶
func (args Methods) WalkSorted(cb func(m *CallerMethod) any) (rv any)
type MixedParams ¶
type MixedParams struct {
Positional Array
Named KeyValueArray
}
func (*MixedParams) Dict ¶
func (m *MixedParams) Dict() Dict
func (*MixedParams) Equal ¶
func (m *MixedParams) Equal(right Object) bool
func (*MixedParams) IndexGet ¶
func (m *MixedParams) IndexGet(vm *VM, index Object) (value Object, err error)
func (*MixedParams) IsFalsy ¶
func (m *MixedParams) IsFalsy() bool
func (*MixedParams) ToDict ¶
func (m *MixedParams) ToDict(d Dict) Dict
func (*MixedParams) ToString ¶
func (m *MixedParams) ToString() string
func (*MixedParams) Type ¶
func (m *MixedParams) Type() ObjectType
type ModuleInfo ¶
type ModuleMap ¶
type ModuleMap struct {
// contains filtered or unexported fields
}
ModuleMap represents a set of named modules. Use NewModuleMap to create a new module map.
func (*ModuleMap) Add ¶
func (m *ModuleMap) Add(name string, module Importable) *ModuleMap
Add adds an importable module.
func (*ModuleMap) AddBuiltinModule ¶
AddBuiltinModule adds a builtin module.
func (*ModuleMap) AddSourceModule ¶
AddSourceModule adds a source module.
func (*ModuleMap) Fork ¶
Fork creates a new ModuleMap instance if ModuleMap has an ExtImporter to make ExtImporter preseve state.
func (*ModuleMap) Get ¶
func (m *ModuleMap) Get(name string) Importable
Get returns an import module identified by name. It returns nil if the name is not found.
func (*ModuleMap) SetExtImporter ¶
func (m *ModuleMap) SetExtImporter(im ExtImporter) *ModuleMap
SetExtImporter sets an ExtImporter to ModuleMap, which will be used to import modules dynamically.
type MultipleObjectTypes ¶
type MultipleObjectTypes []ObjectTypes
func (MultipleObjectTypes) String ¶
func (t MultipleObjectTypes) String() string
func (MultipleObjectTypes) Tree ¶
func (t MultipleObjectTypes) Tree() *ObjectTypeNode
type NameCallerObject ¶
NameCallerObject is an interface for objects that can be called with CallName method to call a method of an object. Objects implementing this interface can reduce allocations by not creating a callable object for each method call.
type NamedArgVar ¶
type NamedArgVar struct {
Name string
Value Object
ValueF func() Object
*TypeAssertion
}
NamedArgVar is a struct to destructure named arguments from Call object.
type NamedArgs ¶
type NamedArgs struct {
// contains filtered or unexported fields
}
func NewNamedArgs ¶
func NewNamedArgs(pairs ...KeyValueArray) *NamedArgs
func (*NamedArgs) CheckNames ¶
func (*NamedArgs) CheckNamesFromSet ¶
func (*NamedArgs) Get ¶
func (o *NamedArgs) Get(dst ...*NamedArgVar) (err error)
Get destructure. Return errors: - ArgumentTypeError if type check of arg is fail. - UnexpectedNamedArg if have unexpected arg.
func (*NamedArgs) GetOne ¶
func (o *NamedArgs) GetOne(dst ...*NamedArgVar) (err error)
GetOne get one value. Return errors: - ArgumentTypeError if type check of arg is fail.
func (*NamedArgs) GetPassedValue ¶
GetPassedValue Get passed value
func (*NamedArgs) GetValueOrNil ¶
GetValueOrNil Must return value from key
func (*NamedArgs) GetVar ¶
func (o *NamedArgs) GetVar(dst ...*NamedArgVar) (args Dict, err error)
GetVar destructure and return others. Returns ArgumentTypeError if type check of arg is fail.
func (*NamedArgs) Join ¶
func (o *NamedArgs) Join() KeyValueArray
func (*NamedArgs) MustGetValue ¶
MustGetValue Must return value from key but not takes as read
func (*NamedArgs) MustGetValueOrNil ¶
MustGetValueOrNil Must return value from key nut not takes as read
func (*NamedArgs) Ready ¶
func (o *NamedArgs) Ready() (arr KeyValueArray)
func (*NamedArgs) Type ¶
func (o *NamedArgs) Type() ObjectType
func (*NamedArgs) UnreadPairs ¶
func (o *NamedArgs) UnreadPairs() (ret KeyValueArray)
type NamedParam ¶
type NamedParam struct {
Name string
// Value is a script of default value
Value string
Usage string
Index int
Type []*SymbolInfo
Var bool
}
func NewNamedParam ¶
func NewNamedParam(name string, value string) *NamedParam
func (*NamedParam) String ¶
func (p *NamedParam) String() string
type NamedParams ¶
type NamedParams struct {
Params []*NamedParam
// contains filtered or unexported fields
}
func NewNamedParams ¶
func NewNamedParams(params ...*NamedParam) (np *NamedParams)
func (*NamedParams) ByName ¶
func (n *NamedParams) ByName() map[string]int
func (*NamedParams) Len ¶
func (n *NamedParams) Len() int
func (*NamedParams) Names ¶
func (n *NamedParams) Names() (names []string)
func (*NamedParams) String ¶
func (n *NamedParams) String() string
func (*NamedParams) ToMap ¶
func (n *NamedParams) ToMap() (np map[string]*NamedParam)
func (*NamedParams) Variadic ¶
func (n *NamedParams) Variadic() bool
type NextIterationHandler ¶
type NextIterationHandler func(vm *VM, state *IteratorState) (err error)
type NilType ¶
type NilType struct {
ObjectImpl
}
NilType represents the type of global Nil Object. One should use the NilType in type switches only.
func (*NilType) Type ¶
func (o *NilType) Type() ObjectType
type Obj ¶
type Obj struct {
// contains filtered or unexported fields
}
Obj represents map of objects and implements Object interface.
func (*Obj) IndexDelete ¶
IndexDelete tries to delete the string value of key from the map. IndexDelete implements IndexDeleter interface.
func (*Obj) Methods ¶
func (o *Obj) Methods() *IndexGetProxy
func (*Obj) Type ¶
func (o *Obj) Type() ObjectType
type ObjType ¶
type ObjType struct {
TypeName string
FieldsDict Dict
SettersDict Dict
MethodsDict Dict
GettersDict Dict
Inherits ObjectTypeArray
// contains filtered or unexported fields
}
ObjType represents type objects and implements Object interface.
func NewObjType ¶
func (*ObjType) AddCallerMethod ¶
func (o *ObjType) AddCallerMethod(vm *VM, types MultipleObjectTypes, handler CallerObject, override bool) error
func (*ObjType) Caller ¶
func (o *ObjType) Caller() CallerObject
func (*ObjType) CallerMethodOfArgs ¶
func (o *ObjType) CallerMethodOfArgs(args Args) (co CallerObject)
func (*ObjType) CallerMethodOfArgsTypes ¶
func (o *ObjType) CallerMethodOfArgsTypes(types []ObjectType) (co CallerObject)
func (*ObjType) CallerMethodWithValidationCheckOfArgs ¶
func (o *ObjType) CallerMethodWithValidationCheckOfArgs(args Args) (co CallerObject, ok bool)
func (*ObjType) CallerMethodWithValidationCheckOfArgsTypes ¶
func (o *ObjType) CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (co CallerObject, validate bool)
func (*ObjType) CallerMethods ¶
func (o *ObjType) CallerMethods() *MethodArgType
func (*ObjType) HasCallerMethods ¶
func (*ObjType) IsChildOf ¶
func (o *ObjType) IsChildOf(t ObjectType) bool
func (*ObjType) Type ¶
func (o *ObjType) Type() ObjectType
type Object ¶
type Object interface {
Falser
// OpDotName should return the name of the type.
Type() ObjectType
// ToString should return a string of the type's value.
ToString() string
// Equal checks equality of objects.
Equal(right Object) bool
}
Object represents an object in the VM.
func BuiltinAppendFunc ¶
func BuiltinCapFunc ¶
func BuiltinCastFunc ¶
func BuiltinCharsFunc ¶
func BuiltinCloseFunc ¶
func BuiltinCollectFunc ¶
func BuiltinContainsFunc ¶
func BuiltinCopyFunc ¶
func BuiltinDeepCopyFunc ¶
func BuiltinDeleteFunc ¶
func BuiltinEachFunc ¶
func BuiltinEnumerateFunc ¶
func BuiltinFilterFunc ¶
func BuiltinFlushFunc ¶
func BuiltinGlobalsFunc ¶
func BuiltinIsArrayFunc ¶
func BuiltinIsBoolFunc ¶
func BuiltinIsBytesFunc ¶
func BuiltinIsCallableFunc ¶
func BuiltinIsCharFunc ¶
func BuiltinIsDictFunc ¶
func BuiltinIsErrorFunc ¶
func BuiltinIsFloatFunc ¶
func BuiltinIsFunc ¶
func BuiltinIsFunctionFunc ¶
func BuiltinIsIntFunc ¶
func BuiltinIsIterableFunc ¶
func BuiltinIsIteratorFunc ¶
func BuiltinIsNilFunc ¶
func BuiltinIsRawStrFunc ¶
func BuiltinIsStrFunc ¶
func BuiltinIsSyncDictFunc ¶
func BuiltinIsUintFunc ¶
func BuiltinItemsFunc ¶
func BuiltinIterateFunc ¶
func BuiltinKeysFunc ¶
func BuiltinLenFunc ¶
func BuiltinMapFunc ¶
func BuiltinNewFunc ¶
func BuiltinOBEndFunc ¶
func BuiltinOBStartFunc ¶
func BuiltinPopWriterFunc ¶
func BuiltinPrintFunc ¶
func BuiltinPrintfFunc ¶
func BuiltinPrintlnFunc ¶
func BuiltinPushWriterFunc ¶
func BuiltinRawCallerFunc ¶
func BuiltinReadFunc ¶
func BuiltinReduceFunc ¶
func BuiltinReprFunc ¶
func BuiltinSortFunc ¶
func BuiltinSortFunc(vm *VM, arg Object, less CallerObject) (ret Object, err error)
func BuiltinSortReverseFunc ¶
func BuiltinSortReverseFunc(vm *VM, arg Object, less CallerObject) (Object, error)
func BuiltinSprintfFunc ¶
func BuiltinStdIOFunc ¶
func BuiltinStructFunc ¶
func BuiltinToArrayFunc ¶
func BuiltinTypeNameFunc ¶
func BuiltinTypeOfFunc ¶
func BuiltinUserDataFunc ¶
func BuiltinValuesFunc ¶
func BuiltinWrapFunc ¶
func BuiltinWriteFunc ¶
func IteratorObject ¶
func MustCallVargs ¶
func MustToObject ¶
func NewArrayFunc ¶
func NewBufferFunc ¶
func NewBytesFunc ¶
func NewDictFunc ¶
func NewErrorFunc ¶
func NewKeyValueArrayFunc ¶
func NewKeyValueFunc ¶
func NewMixedParamsFunc ¶
func NewPrinterStateFunc ¶
func NewRawStrFunc ¶
func NewRegexpFunc ¶
func NewStrFunc ¶
func NewSyncDictFunc ¶
func ToObject ¶
ToObject is analogous to ToObject but it will always convert signed integers to Int and unsigned integers to Uint. It is an alternative to ToObject. Note that, this function is subject to change in the future.
func TypedIteratorObject ¶
func TypedIteratorObject(typ ObjectType, it Iterator) Object
type ObjectConverters ¶
type ObjectConverters struct {
ToGoHandlers map[ObjectType]func(vm *VM, v Object) any
ToObjectHandlers map[reflect.Type]func(vm *VM, v any) (Object, error)
}
func NewObjectConverters ¶
func NewObjectConverters() *ObjectConverters
func (*ObjectConverters) Register ¶
func (oc *ObjectConverters) Register(objType ObjectType, togo func(vm *VM, v Object) any, goType reflect.Type, toObject func(vm *VM, v any) (Object, error)) *ObjectConverters
func (*ObjectConverters) ToInterface ¶
func (oc *ObjectConverters) ToInterface(vm *VM, v Object) any
type ObjectImpl ¶
type ObjectImpl struct{}
ObjectImpl is the basic Object implementation and it does not nothing, and helps to implement Object interface by embedding and overriding methods in custom implementations. Str and OpDotName must be implemented otherwise calling these methods causes panic.
func (ObjectImpl) ToString ¶
func (ObjectImpl) ToString() string
func (ObjectImpl) Type ¶
func (ObjectImpl) Type() ObjectType
type ObjectIterator ¶
type ObjectPtr ¶
type ObjectPtr struct {
ObjectImpl
Value *Object
}
ObjectPtr represents a pointer variable.
func (*ObjectPtr) Type ¶
func (o *ObjectPtr) Type() ObjectType
type ObjectRepresenter ¶
type ObjectRepresenter interface {
Object
Representer
}
type ObjectToWriter ¶
type ObjectToWriterFunc ¶
var DefaultObjectToWrite ObjectToWriterFunc = func(vm *VM, w io.Writer, obj Object) (handled bool, n int64, err error) { if ToWritable(obj) { n, err = obj.(ToWriter).WriteTo(vm, w) } else { var s Object if s, err = Val(vm.Builtins.Call(BuiltinRawStr, Call{VM: vm, Args: Args{Array{obj}}})); err != nil { return false, 0, err } var n32 int n32, err = w.Write([]byte(s.(RawStr))) n += int64(n32) } handled = true return }
type ObjectToWriters ¶
type ObjectToWriters []ObjectToWriter
func (ObjectToWriters) Append ¶
func (o ObjectToWriters) Append(handlers ...ObjectToWriter) ObjectToWriters
func (ObjectToWriters) Prepend ¶
func (o ObjectToWriters) Prepend(handlers ...ObjectToWriter) ObjectToWriters
type ObjectType ¶
type ObjectType interface {
Object
CallerObject
fmt.Stringer
Name() string
Getters() Dict
Setters() Dict
Methods() Dict
Fields() Dict
New(vm *VM, fields Dict) (Object, error)
IsChildOf(t ObjectType) bool
}
func DetectTypeOf ¶
func DetectTypeOf(arg Object) ObjectType
func TypeOf ¶
func TypeOf(arg Object) ObjectType
func TypesOf ¶
func TypesOf(obj Object) (types []ObjectType)
type ObjectTypeArray ¶
type ObjectTypeArray []ObjectType
func (ObjectTypeArray) Array ¶
func (o ObjectTypeArray) Array() Array
func (ObjectTypeArray) Equal ¶
func (o ObjectTypeArray) Equal(right Object) bool
func (ObjectTypeArray) IsFalsy ¶
func (o ObjectTypeArray) IsFalsy() bool
func (ObjectTypeArray) ToString ¶
func (o ObjectTypeArray) ToString() string
func (ObjectTypeArray) Type ¶
func (o ObjectTypeArray) Type() ObjectType
type ObjectTypeNode ¶
type ObjectTypeNode struct {
Type ObjectType
Children []*ObjectTypeNode
}
func (*ObjectTypeNode) Append ¶
func (n *ObjectTypeNode) Append(o MultipleObjectTypes)
func (*ObjectTypeNode) Walk ¶
func (n *ObjectTypeNode) Walk(cb func(types ObjectTypes) any) any
func (*ObjectTypeNode) WalkE ¶
func (n *ObjectTypeNode) WalkE(cb func(types ObjectTypes) any) error
type ObjectTypes ¶
type ObjectTypes []ObjectType
func (ObjectTypes) String ¶
func (t ObjectTypes) String() string
type OpCallFlag ¶
type OpCallFlag byte
const ( OpCallFlagVarArgs OpCallFlag = 1 << iota OpCallFlagNamedArgs OpCallFlagVarNamedArgs )
func (OpCallFlag) Has ¶
func (f OpCallFlag) Has(other OpCallFlag) bool
type Opcode ¶
type Opcode byte
Opcode represents a single byte operation code.
const ( OpNoOp Opcode = iota OpConstant OpCall OpGetGlobal OpSetGlobal OpGetLocal OpSetLocal OpGetBuiltin OpBinary OpUnary OpSelfAssign OpEqual OpNotEqual OpJump OpJumpFalsy OpAndJump OpOrJump OpDict OpArray OpSliceIndex OpGetIndex OpSetIndex OpNil OpStdIn OpStdOut OpStdErr OpDotName OpDotFile OpIsModule OpPop OpGetFree OpSetFree OpGetLocalPtr OpGetFreePtr OpClosure OpIterInit OpIterNext OpIterNextElse OpIterKey OpIterValue OpLoadModule OpStoreModule OpSetupTry OpSetupCatch OpSetupFinally OpThrow OpFinalizer OpReturn OpDefineLocal OpTrue OpFalse OpYes OpNo OpCallName OpJumpNil OpJumpNotNil OpKeyValueArray OpKeyValue OpCallee OpArgs OpNamedArgs OpTextWriter OpIsNil OpNotIsNil )
List of opcodes
type OptimizerError ¶
OptimizerError represents an optimizer error.
func (*OptimizerError) Error ¶
func (e *OptimizerError) Error() string
func (*OptimizerError) Unwrap ¶
func (e *OptimizerError) Unwrap() error
type Param ¶
type Param struct {
Name string
Type ParamType
TypeO ObjectTypes
Var bool
Usage string
}
func NewParam ¶
func NewParam(name string, opt ...ParamOption) *Param
type ParamOption ¶
type ParamOption func(p *Param)
func ParamWithType ¶
func ParamWithType(t ...*SymbolInfo) ParamOption
func ParamWithTypeO ¶
func ParamWithTypeO(t ...ObjectType) ParamOption
type ParamType ¶
type ParamType []*SymbolInfo
type PipedInvokeIterator ¶
type PipedInvokeIterator struct {
// contains filtered or unexported fields
}
func NewPipedInvokeIterator ¶
func NewPipedInvokeIterator(it Iterator, args Array, startArgValueIndex int, caller VMCaller) (fe *PipedInvokeIterator)
func (*PipedInvokeIterator) Call ¶
func (f *PipedInvokeIterator) Call(state *IteratorState) (err error)
func (*PipedInvokeIterator) Handler ¶
func (f *PipedInvokeIterator) Handler() func(state *IteratorState) error
func (*PipedInvokeIterator) Input ¶
func (f *PipedInvokeIterator) Input() Object
func (*PipedInvokeIterator) Next ¶
func (f *PipedInvokeIterator) Next(vm *VM, state *IteratorState) (err error)
func (*PipedInvokeIterator) PostCall ¶
func (f *PipedInvokeIterator) PostCall() func(state *IteratorState, ret Object) error
func (*PipedInvokeIterator) PreCall ¶
func (f *PipedInvokeIterator) PreCall() func(k, v Object) (Object, error)
func (*PipedInvokeIterator) SetHandler ¶
func (f *PipedInvokeIterator) SetHandler(handler func(state *IteratorState) error) *PipedInvokeIterator
func (*PipedInvokeIterator) SetPostCall ¶
func (f *PipedInvokeIterator) SetPostCall(postCall func(state *IteratorState, ret Object) error) *PipedInvokeIterator
func (*PipedInvokeIterator) SetPreCall ¶
func (f *PipedInvokeIterator) SetPreCall(preCall func(k, v Object) (Object, error)) *PipedInvokeIterator
func (*PipedInvokeIterator) SetType ¶
func (f *PipedInvokeIterator) SetType(typ ObjectType) *PipedInvokeIterator
func (*PipedInvokeIterator) Start ¶
func (f *PipedInvokeIterator) Start(vm *VM) (state *IteratorState, err error)
func (*PipedInvokeIterator) Type ¶
func (f *PipedInvokeIterator) Type() ObjectType
type PrintStateOptionSortType ¶
type PrintStateOptionSortType uint8
const ( PrintStateOptionSortTypeAscending PrintStateOptionSortType = iota + 1 PrintStateOptionSortTypeDescending )
func PrintStateOptionsGetSortKeysType ¶
func PrintStateOptionsGetSortKeysType(s *PrinterState) PrintStateOptionSortType
type Printer ¶
type Printer interface {
Print(state *PrinterState) error
}
type PrinterState ¶
type PrinterState struct {
VM *VM
// contains filtered or unexported fields
}
PrinterState represents the printer state passed to custom formatters. It provides access to the io.Writer interface plus information about the flags and options for the operand's format specifier.
func NewPrinterState ¶
func NewPrinterState(VM *VM, writer io.Writer, option ...PrinterStateOption) *PrinterState
func PrinterStateFromCall ¶
func PrinterStateFromCall(c *Call) (state *PrinterState)
func (*PrinterState) BytesWritten ¶
func (s *PrinterState) BytesWritten() int64
func (*PrinterState) Context ¶
func (s *PrinterState) Context() context.Context
func (PrinterState) Copy ¶
func (s PrinterState) Copy() *PrinterState
func (*PrinterState) DoEnter ¶
func (s *PrinterState) DoEnter(f func() error) error
func (*PrinterState) DoVisit ¶
func (s *PrinterState) DoVisit(obj Object, f func() error) (err error)
func (*PrinterState) Enter ¶
func (s *PrinterState) Enter() (leave func())
func (*PrinterState) Equal ¶
func (s *PrinterState) Equal(right Object) bool
func (*PrinterState) Indent ¶
func (s *PrinterState) Indent() []byte
func (*PrinterState) Indented ¶
func (s *PrinterState) Indented() bool
func (*PrinterState) IndexGet ¶
func (s *PrinterState) IndexGet(_ *VM, index Object) (value Object, err error)
func (*PrinterState) IsFalsy ¶
func (s *PrinterState) IsFalsy() bool
func (*PrinterState) Option ¶
func (s *PrinterState) Option(key string) Object
func (*PrinterState) OptionDefault ¶
func (s *PrinterState) OptionDefault(key string, defaul Object) (value Object)
func (*PrinterState) Options ¶
func (s *PrinterState) Options() Dict
func (*PrinterState) Print ¶
func (s *PrinterState) Print(o Object) error
func (*PrinterState) PrintFromArgs ¶
func (s *PrinterState) PrintFromArgs(sep []byte, args Args) (err error)
func (*PrinterState) PrintIndent ¶
func (s *PrinterState) PrintIndent()
func (*PrinterState) PrintLine ¶
func (s *PrinterState) PrintLine()
func (*PrinterState) PrintLineIndent ¶
func (s *PrinterState) PrintLineIndent()
func (*PrinterState) PrintMany ¶
func (s *PrinterState) PrintMany(sep []byte, o ...Object) (err error)
func (*PrinterState) SkipDepth ¶
func (s *PrinterState) SkipDepth() bool
func (*PrinterState) Stack ¶
func (s *PrinterState) Stack() *PrinterStateStack
func (*PrinterState) ToString ¶
func (s *PrinterState) ToString() string
func (*PrinterState) Type ¶
func (s *PrinterState) Type() ObjectType
func (*PrinterState) Value ¶
func (s *PrinterState) Value(key any) (value any)
Value get context value by key or nil
func (*PrinterState) Visited ¶
func (s *PrinterState) Visited(obj Object) bool
func (*PrinterState) WithContext ¶
func (s *PrinterState) WithContext(ctx context.Context) *PrinterState
WithContext override context
func (*PrinterState) WithValue ¶
func (s *PrinterState) WithValue(key, value any) *PrinterState
WithValue add context value by key
func (*PrinterState) WithValueBackup ¶
func (s *PrinterState) WithValueBackup(key, value any) (restore func())
WithValueBackup add context value by key and return restore func
type PrinterStateOption ¶
type PrinterStateOption func(s *PrinterState)
func PrinterStateWithContext ¶
func PrinterStateWithContext(ctx context.Context) PrinterStateOption
func PrinterStateWithIndent ¶
func PrinterStateWithIndent(indent Object) PrinterStateOption
func PrinterStateWithMaxDepth ¶
func PrinterStateWithMaxDepth(depth int) PrinterStateOption
func PrinterStateWithOptions ¶
func PrinterStateWithOptions(options Dict) PrinterStateOption
func PrinterStateWithRaw ¶
func PrinterStateWithRaw(v bool) PrinterStateOption
type PrinterStateStack ¶
type PrinterStateStack struct {
// contains filtered or unexported fields
}
func (*PrinterStateStack) Prev ¶
func (e *PrinterStateStack) Prev() *PrinterStateStack
func (*PrinterStateStack) PrevValue ¶
func (e *PrinterStateStack) PrevValue() Object
func (*PrinterStateStack) Value ¶
func (e *PrinterStateStack) Value() Object
type RangeIteration ¶
type RangeIteration struct {
It Object
ItType ObjectType
Len int
ReadTo func(e *KeyValue, i int) error
// contains filtered or unexported fields
}
func NewRangeIteration ¶
func NewRangeIteration(typ ObjectType, o Object, len int, readTo func(e *KeyValue, i int) error) *RangeIteration
func SliceEntryIteration ¶
func SliceEntryIteration[T any](typ ObjectType, o Object, items []T, get func(v T) (key Object, val Object, err error)) *RangeIteration
func SliceIteration ¶
func SliceIteration[T any](typ ObjectType, o Object, items []T, get func(e *KeyValue, i Int, v T) error) *RangeIteration
func (*RangeIteration) Input ¶
func (it *RangeIteration) Input() Object
func (*RangeIteration) Length ¶
func (it *RangeIteration) Length() int
func (*RangeIteration) Next ¶
func (it *RangeIteration) Next(_ *VM, state *IteratorState) (err error)
func (*RangeIteration) ParseNamedArgs ¶
func (it *RangeIteration) ParseNamedArgs(na *NamedArgs) *RangeIteration
func (*RangeIteration) SetReversed ¶
func (it *RangeIteration) SetReversed(v bool) *RangeIteration
func (*RangeIteration) Start ¶
func (it *RangeIteration) Start(*VM) (state *IteratorState, err error)
func (*RangeIteration) Type ¶
func (it *RangeIteration) Type() ObjectType
type RawStr ¶
type RawStr string
RawStr represents safe string values and implements Object interface.
func (RawStr) Type ¶
func (o RawStr) Type() ObjectType
type ReadWriter ¶
type Reader ¶
func ReaderFrom ¶
type ReflectArray ¶
type ReflectArray struct {
ReflectValue
}
func (*ReflectArray) Copy ¶
func (o *ReflectArray) Copy() (obj Object)
func (*ReflectArray) IndexGet ¶
func (o *ReflectArray) IndexGet(vm *VM, index Object) (value Object, err error)
func (*ReflectArray) IndexSet ¶
func (o *ReflectArray) IndexSet(vm *VM, index, value Object) (err error)
func (*ReflectArray) IsFalsy ¶
func (o *ReflectArray) IsFalsy() bool
func (*ReflectArray) Length ¶
func (o *ReflectArray) Length() int
func (*ReflectArray) Print ¶
func (o *ReflectArray) Print(state *PrinterState) (err error)
func (*ReflectArray) ToString ¶
func (o *ReflectArray) ToString() string
type ReflectField ¶
type ReflectField struct {
BaseType reflect.Type
IsPtr bool
Struct IndexableStructField
Value reflect.Value
}
func (*ReflectField) Equal ¶
func (r *ReflectField) Equal(right Object) bool
func (*ReflectField) IsFalsy ¶
func (r *ReflectField) IsFalsy() bool
func (*ReflectField) String ¶
func (r *ReflectField) String() string
func (*ReflectField) ToString ¶
func (r *ReflectField) ToString() string
func (*ReflectField) Type ¶
func (r *ReflectField) Type() ObjectType
type ReflectFunc ¶
type ReflectFunc struct {
ReflectValue
}
func (*ReflectFunc) ToString ¶
func (r *ReflectFunc) ToString() string
type ReflectMap ¶
type ReflectMap struct {
ReflectValue
}
func (*ReflectMap) Copy ¶
func (o *ReflectMap) Copy() (obj Object)
func (*ReflectMap) IndexDelete ¶
func (o *ReflectMap) IndexDelete(vm *VM, index Object) (err error)
func (*ReflectMap) IndexGet ¶
func (o *ReflectMap) IndexGet(vm *VM, index Object) (value Object, err error)
func (*ReflectMap) IndexSet ¶
func (o *ReflectMap) IndexSet(vm *VM, index, value Object) (err error)
func (*ReflectMap) IsFalsy ¶
func (o *ReflectMap) IsFalsy() bool
func (*ReflectMap) Length ¶
func (o *ReflectMap) Length() int
func (*ReflectMap) Print ¶
func (o *ReflectMap) Print(s *PrinterState) (err error)
func (*ReflectMap) ToString ¶
func (o *ReflectMap) ToString() string
type ReflectMethod ¶
func (*ReflectMethod) Equal ¶
func (r *ReflectMethod) Equal(right Object) bool
func (*ReflectMethod) IsFalsy ¶
func (r *ReflectMethod) IsFalsy() bool
func (*ReflectMethod) ToString ¶
func (r *ReflectMethod) ToString() string
func (*ReflectMethod) Type ¶
func (r *ReflectMethod) Type() ObjectType
type ReflectSlice ¶
type ReflectSlice struct {
ReflectArray
}
func (*ReflectSlice) AppendObjects ¶
func (o *ReflectSlice) AppendObjects(vm *VM, items ...Object) (_ Object, err error)
func (*ReflectSlice) Copy ¶
func (o *ReflectSlice) Copy() (obj Object)
func (*ReflectSlice) Slice ¶
func (o *ReflectSlice) Slice(low, high int) Object
func (*ReflectSlice) ToString ¶
func (o *ReflectSlice) ToString() string
type ReflectStruct ¶
type ReflectStruct struct {
ReflectValue
Data Dict
Interface any
// contains filtered or unexported fields
}
func (*ReflectStruct) CallName ¶
func (s *ReflectStruct) CallName(name string, c Call) (Object, error)
func (*ReflectStruct) CanCall ¶
func (s *ReflectStruct) CanCall() bool
func (*ReflectStruct) CanClose ¶
func (s *ReflectStruct) CanClose() bool
func (*ReflectStruct) CanIterationDone ¶
func (s *ReflectStruct) CanIterationDone() (ok bool)
func (*ReflectStruct) Close ¶
func (s *ReflectStruct) Close() error
func (*ReflectStruct) Copy ¶
func (s *ReflectStruct) Copy() (obj Object)
func (*ReflectStruct) FalbackIndexHandler ¶
func (s *ReflectStruct) FalbackIndexHandler(handler func(vm *VM, s *ReflectStruct, name string) (handled bool, value any, err error)) *ReflectStruct
func (*ReflectStruct) FieldHandler ¶
func (s *ReflectStruct) FieldHandler(handler func(vm *VM, s *ReflectStruct, name string, v any) any) *ReflectStruct
func (*ReflectStruct) IndexGet ¶
func (s *ReflectStruct) IndexGet(vm *VM, index Object) (value Object, err error)
func (*ReflectStruct) IndexGetS ¶
func (s *ReflectStruct) IndexGetS(vm *VM, index string) (value Object, err error)
func (*ReflectStruct) IndexSet ¶
func (s *ReflectStruct) IndexSet(vm *VM, index, value Object) (err error)
func (*ReflectStruct) Init ¶
func (s *ReflectStruct) Init()
func (*ReflectStruct) IterationDone ¶
func (s *ReflectStruct) IterationDone(vm *VM) error
func (*ReflectStruct) Print ¶
func (s *ReflectStruct) Print(state *PrinterState) (err error)
Print prints object writing output to out writer. Options: - anonymous flag: include anonymous fields. - zeros flag: include zero fields. - sortKeys int = 0: fields sorting. 1: ASC, 2: DESC.
func (*ReflectStruct) Reader ¶
func (s *ReflectStruct) Reader() Reader
func (*ReflectStruct) SetFieldValue ¶
func (s *ReflectStruct) SetFieldValue(vm *VM, df *ReflectField, value any) (err error)
func (*ReflectStruct) SetValues ¶
func (s *ReflectStruct) SetValues(vm *VM, values Dict) (err error)
func (*ReflectStruct) ToString ¶
func (s *ReflectStruct) ToString() string
func (*ReflectStruct) UserData ¶
func (s *ReflectStruct) UserData() Indexer
func (*ReflectStruct) Writer ¶
func (s *ReflectStruct) Writer() Writer
type ReflectType ¶
type ReflectType struct {
RType reflect.Type
RMethods map[string]*ReflectMethod
FieldsNames []string
RFields map[string]*ReflectField
CallObject func(obj *ReflectStruct, c Call) (Object, error)
Print func(state *PrinterState, obj *ReflectValue) error
// contains filtered or unexported fields
}
func NewReflectType ¶
func NewReflectType(typ reflect.Type) (rt *ReflectType)
func ReflectTypeOf ¶
func ReflectTypeOf(v any) (rt *ReflectType)
func (*ReflectType) Equal ¶
func (r *ReflectType) Equal(right Object) bool
func (*ReflectType) Fields ¶
func (r *ReflectType) Fields() (fields Dict)
func (*ReflectType) Fqn ¶
func (r *ReflectType) Fqn() string
func (*ReflectType) GetRMethods ¶
func (r *ReflectType) GetRMethods() map[string]*ReflectMethod
func (*ReflectType) Getters ¶
func (r *ReflectType) Getters() Dict
func (*ReflectType) IsChildOf ¶
func (r *ReflectType) IsChildOf(t ObjectType) bool
func (*ReflectType) IsFalsy ¶
func (r *ReflectType) IsFalsy() bool
func (*ReflectType) Methods ¶
func (r *ReflectType) Methods() (m Dict)
func (*ReflectType) Name ¶
func (r *ReflectType) Name() string
func (*ReflectType) Setters ¶
func (r *ReflectType) Setters() Dict
func (*ReflectType) String ¶
func (r *ReflectType) String() string
func (*ReflectType) ToString ¶
func (r *ReflectType) ToString() string
func (*ReflectType) Type ¶
func (r *ReflectType) Type() ObjectType
type ReflectValue ¶
type ReflectValue struct {
RType *ReflectType
RValue reflect.Value
Options *ReflectValueOptions
// contains filtered or unexported fields
}
func (*ReflectValue) CallName ¶
func (r *ReflectValue) CallName(name string, c Call) (Object, error)
func (*ReflectValue) CallNameOf ¶
func (r *ReflectValue) CallNameOf(this ReflectValuer, name string, c Call) (Object, error)
func (*ReflectValue) Copy ¶
func (r *ReflectValue) Copy() (obj Object)
func (*ReflectValue) Equal ¶
func (r *ReflectValue) Equal(right Object) bool
func (*ReflectValue) FalbackNameCallerHandler ¶
func (r *ReflectValue) FalbackNameCallerHandler(handler func(s ReflectValuer, name string, c Call) (handled bool, value Object, err error)) *ReflectValue
func (*ReflectValue) GetRType ¶
func (r *ReflectValue) GetRType() *ReflectType
func (*ReflectValue) GetRValue ¶
func (r *ReflectValue) GetRValue() *ReflectValue
func (*ReflectValue) Init ¶
func (r *ReflectValue) Init()
func (*ReflectValue) IsFalsy ¶
func (r *ReflectValue) IsFalsy() bool
func (*ReflectValue) IsNil ¶
func (r *ReflectValue) IsNil() bool
func (*ReflectValue) IsPtr ¶
func (r *ReflectValue) IsPtr() bool
func (*ReflectValue) Method ¶
func (r *ReflectValue) Method(name string) *ReflectFunc
func (*ReflectValue) Methods ¶
func (r *ReflectValue) Methods() *IndexGetProxy
func (*ReflectValue) Print ¶
func (r *ReflectValue) Print(state *PrinterState) (err error)
func (*ReflectValue) PtrValue ¶
func (r *ReflectValue) PtrValue() reflect.Value
func (*ReflectValue) ToInterface ¶
func (r *ReflectValue) ToInterface() any
func (*ReflectValue) ToString ¶
func (r *ReflectValue) ToString() string
func (*ReflectValue) ToStringW ¶
func (r *ReflectValue) ToStringW(w io.Writer)
func (*ReflectValue) Type ¶
func (r *ReflectValue) Type() ObjectType
func (*ReflectValue) Value ¶
func (r *ReflectValue) Value() reflect.Value
type ReflectValueOptions ¶
type ReflectValuePrinter ¶
type ReflectValuePrinter interface {
GadPrint(state *PrinterState) (err error)
}
type ReflectValuer ¶
type ReflectValuer interface {
Object
Copier
NameCallerObject
ToIterfaceConverter
Value() reflect.Value
GetRValue() *ReflectValue
GetRType() *ReflectType
IsPtr() bool
IsNil() bool
}
func MustNewReflectValue ¶
func MustNewReflectValue(v any, opts ...*ReflectValueOptions) ReflectValuer
func NewReflectValue ¶
func NewReflectValue(v any, opts ...*ReflectValueOptions) (ReflectValuer, error)
type Regexp ¶
func (*Regexp) ToInterface ¶
func (*Regexp) Type ¶
func (o *Regexp) Type() ObjectType
type RegexpBytesResult ¶
type RegexpBytesResult [][]byte
func (RegexpBytesResult) Equal ¶
func (o RegexpBytesResult) Equal(right Object) bool
func (RegexpBytesResult) IsFalsy ¶
func (o RegexpBytesResult) IsFalsy() bool
func (RegexpBytesResult) ToArray ¶
func (o RegexpBytesResult) ToArray() Array
func (RegexpBytesResult) ToString ¶
func (o RegexpBytesResult) ToString() string
func (RegexpBytesResult) Type ¶
func (o RegexpBytesResult) Type() ObjectType
type RegexpBytesSliceResult ¶
type RegexpBytesSliceResult [][][]byte
func (RegexpBytesSliceResult) Equal ¶
func (o RegexpBytesSliceResult) Equal(right Object) bool
func (RegexpBytesSliceResult) IsFalsy ¶
func (o RegexpBytesSliceResult) IsFalsy() bool
func (RegexpBytesSliceResult) ToArray ¶
func (o RegexpBytesSliceResult) ToArray() Array
func (RegexpBytesSliceResult) ToString ¶
func (o RegexpBytesSliceResult) ToString() string
func (RegexpBytesSliceResult) Type ¶
func (o RegexpBytesSliceResult) Type() ObjectType
type RegexpStrsResult ¶
type RegexpStrsResult []string
func (RegexpStrsResult) Equal ¶
func (o RegexpStrsResult) Equal(right Object) bool
func (RegexpStrsResult) IsFalsy ¶
func (o RegexpStrsResult) IsFalsy() bool
func (RegexpStrsResult) ToArray ¶
func (o RegexpStrsResult) ToArray() Array
func (RegexpStrsResult) ToString ¶
func (o RegexpStrsResult) ToString() string
func (RegexpStrsResult) Type ¶
func (o RegexpStrsResult) Type() ObjectType
type RegexpStrsSliceResult ¶
type RegexpStrsSliceResult [][]string
func (RegexpStrsSliceResult) Equal ¶
func (o RegexpStrsSliceResult) Equal(right Object) bool
func (RegexpStrsSliceResult) IsFalsy ¶
func (o RegexpStrsSliceResult) IsFalsy() bool
func (RegexpStrsSliceResult) ToArray ¶
func (o RegexpStrsSliceResult) ToArray() Array
func (RegexpStrsSliceResult) ToString ¶
func (o RegexpStrsSliceResult) ToString() string
func (RegexpStrsSliceResult) Type ¶
func (o RegexpStrsSliceResult) Type() ObjectType
type Representer ¶
type ReverseSorter ¶
type ReverseSorter interface {
Object
// SortReverse sorts object reversely. if `update`, sort self and return then, other else sorts a self copy object.
SortReverse(vm *VM) (Object, error)
}
ReverseSorter is an interface for return reverse sorted values.
type RunOpts ¶
type RunOpts struct {
Globals IndexGetSetter
Args Args
NamedArgs *NamedArgs
StdIn io.Reader
StdOut io.Writer
StdErr io.Writer
ObjectToWriter ObjectToWriter
}
type RuntimeError ¶
type RuntimeError struct {
Err *Error
Trace []source.Pos
// contains filtered or unexported fields
}
RuntimeError represents a runtime error that wraps Error and includes trace information.
func (*RuntimeError) Equal ¶
func (o *RuntimeError) Equal(right Object) bool
Equal implements Object interface.
func (*RuntimeError) Error ¶
func (o *RuntimeError) Error() string
Error implements error interface.
func (*RuntimeError) FileSet ¶
func (o *RuntimeError) FileSet() *source.FileSet
func (*RuntimeError) Format ¶
func (o *RuntimeError) Format(s fmt.State, verb rune)
Format implements fmt.Formater interface.
func (*RuntimeError) IndexGet ¶
func (o *RuntimeError) IndexGet(vm *VM, index Object) (Object, error)
IndexGet implements Object interface.
func (*RuntimeError) IsFalsy ¶
func (o *RuntimeError) IsFalsy() bool
IsFalsy implements Object interface.
func (*RuntimeError) NewError ¶
func (o *RuntimeError) NewError(messages ...string) *RuntimeError
NewError creates a new Error and sets original Error as its cause which can be unwrapped.
func (*RuntimeError) StackTrace ¶
func (o *RuntimeError) StackTrace() source.FilePosStackTrace
StackTrace returns stack trace if set otherwise returns nil.
func (*RuntimeError) ToString ¶
func (o *RuntimeError) ToString() string
func (*RuntimeError) Type ¶
func (*RuntimeError) Type() ObjectType
func (*RuntimeError) Unwrap ¶
func (o *RuntimeError) Unwrap() error
type SelfAssignOperatorHandler ¶
type SelfAssignOperatorHandler interface {
Object
// SelfAssignOp handles self assign operators.
// Returned error stops VM execution if not handled with an error handler
// and VM.Run returns the same error as wrapped.
SelfAssignOp(vm *VM, tok token.Token, right Object) (ret Object, handled bool, err error)
}
type SelfAssignOperatorType ¶
func (SelfAssignOperatorType) Equal ¶
func (b SelfAssignOperatorType) Equal(right Object) bool
func (SelfAssignOperatorType) Fields ¶
func (SelfAssignOperatorType) Fields() Dict
func (SelfAssignOperatorType) Getters ¶
func (SelfAssignOperatorType) Getters() Dict
func (SelfAssignOperatorType) IsChildOf ¶
func (SelfAssignOperatorType) IsChildOf(t ObjectType) bool
func (SelfAssignOperatorType) IsFalsy ¶
func (b SelfAssignOperatorType) IsFalsy() bool
func (SelfAssignOperatorType) Methods ¶
func (SelfAssignOperatorType) Methods() Dict
func (SelfAssignOperatorType) MethodsDisabled ¶
func (SelfAssignOperatorType) MethodsDisabled() bool
func (SelfAssignOperatorType) Name ¶
func (b SelfAssignOperatorType) Name() string
func (SelfAssignOperatorType) Setters ¶
func (SelfAssignOperatorType) Setters() Dict
func (SelfAssignOperatorType) String ¶
func (b SelfAssignOperatorType) String() string
func (SelfAssignOperatorType) ToString ¶
func (b SelfAssignOperatorType) ToString() string
func (SelfAssignOperatorType) Token ¶
func (b SelfAssignOperatorType) Token() token.Token
func (SelfAssignOperatorType) Type ¶
func (b SelfAssignOperatorType) Type() ObjectType
type SimpleOptimizer ¶
type SimpleOptimizer struct {
// contains filtered or unexported fields
}
SimpleOptimizer optimizes given parsed file by evaluating constants and expressions. It is not safe to call methods concurrently.
func NewOptimizer ¶
func NewOptimizer( file *parser.File, base *SymbolTable, opts CompilerOptions, ) *SimpleOptimizer
NewOptimizer creates an Optimizer object.
func (*SimpleOptimizer) Optimize ¶
func (so *SimpleOptimizer) Optimize() error
Optimize optimizes ast tree by simple constant folding and evaluating simple expressions.
func (*SimpleOptimizer) Total ¶
func (so *SimpleOptimizer) Total() int
Total returns total number of evaluated constants and expressions.
type Slicer ¶
type Slicer interface {
LengthGetter
Slice(low, high int) Object
}
type Sorter ¶
type Sorter interface {
Object
// Sort sorts object. if `update`, sort self and return then, other else sorts a self copy object.
Sort(vm *VM, less CallerObject) (Object, error)
}
Sorter is an interface for return sorted values.
type SourceModule ¶
type SourceModule struct {
Src []byte
}
SourceModule is an importable module that's written in Gad.
type StackReader ¶
type StackReader struct {
// contains filtered or unexported fields
}
func NewStackReader ¶
func NewStackReader(readers ...io.Reader) *StackReader
func (*StackReader) Equal ¶
func (s *StackReader) Equal(right Object) bool
func (*StackReader) GoReader ¶
func (s *StackReader) GoReader() io.Reader
func (*StackReader) IsFalsy ¶
func (s *StackReader) IsFalsy() bool
func (*StackReader) Pop ¶
func (s *StackReader) Pop()
func (*StackReader) Push ¶
func (s *StackReader) Push(r io.Reader)
func (*StackReader) ToString ¶
func (s *StackReader) ToString() string
func (*StackReader) Type ¶
func (s *StackReader) Type() ObjectType
type StackWriter ¶
type StackWriter struct {
// contains filtered or unexported fields
}
func NewStackWriter ¶
func NewStackWriter(writers ...io.Writer) *StackWriter
func (*StackWriter) Current ¶
func (w *StackWriter) Current() Writer
func (*StackWriter) Equal ¶
func (w *StackWriter) Equal(right Object) bool
func (*StackWriter) Flush ¶
func (w *StackWriter) Flush() (n Int, err error)
func (*StackWriter) GoWriter ¶
func (w *StackWriter) GoWriter() io.Writer
func (*StackWriter) IsFalsy ¶
func (w *StackWriter) IsFalsy() bool
func (*StackWriter) Old ¶
func (w *StackWriter) Old() Writer
func (*StackWriter) Pop ¶
func (w *StackWriter) Pop() Writer
func (*StackWriter) Push ¶
func (w *StackWriter) Push(sw io.Writer)
func (*StackWriter) ToString ¶
func (w *StackWriter) ToString() string
func (*StackWriter) Type ¶
func (w *StackWriter) Type() ObjectType
type StartIterationHandler ¶
type StartIterationHandler func(vm *VM) (state *IteratorState, err error)
type StateIteratorObject ¶
type StateIteratorObject struct {
Iterator
State *IteratorState
VM *VM
StartHandlers []func(s *StateIteratorObject)
}
func NewStateIteratorObject ¶
func NewStateIteratorObject(vm *VM, it Iterator) *StateIteratorObject
func ToStateIterator ¶
func (*StateIteratorObject) AddStartHandler ¶
func (s *StateIteratorObject) AddStartHandler(f func(s *StateIteratorObject))
func (*StateIteratorObject) Equal ¶
func (s *StateIteratorObject) Equal(right Object) bool
func (*StateIteratorObject) GetIterator ¶
func (s *StateIteratorObject) GetIterator() Iterator
func (*StateIteratorObject) IndexGet ¶
func (s *StateIteratorObject) IndexGet(vm *VM, index Object) (value Object, err error)
func (*StateIteratorObject) Info ¶
func (s *StateIteratorObject) Info() Dict
func (*StateIteratorObject) IsFalsy ¶
func (s *StateIteratorObject) IsFalsy() bool
func (*StateIteratorObject) Key ¶
func (s *StateIteratorObject) Key() Object
func (*StateIteratorObject) Next ¶
func (s *StateIteratorObject) Next(vm *VM, state *IteratorState) (err error)
func (*StateIteratorObject) Read ¶
func (s *StateIteratorObject) Read() (_ bool, err error)
func (*StateIteratorObject) Start ¶
func (s *StateIteratorObject) Start(vm *VM) (state *IteratorState, err error)
func (*StateIteratorObject) ToString ¶
func (s *StateIteratorObject) ToString() string
func (*StateIteratorObject) Type ¶
func (s *StateIteratorObject) Type() ObjectType
func (*StateIteratorObject) Value ¶
func (s *StateIteratorObject) Value() Object
type Str ¶
type Str string
Str represents string values and implements Object interface.
func ToReprTyped ¶
func ToReprTyped(vm *VM, typ ObjectType, o Object) (s Str, err error)
func (Str) Type ¶
func (o Str) Type() ObjectType
type Symbol ¶
type Symbol struct {
SymbolInfo
Assigned bool
Constant bool
Original *Symbol
}
Symbol represents a symbol in the symbol table.
type SymbolInfo ¶
type SymbolInfo struct {
Name string
Index int
Scope SymbolScope
}
func (*SymbolInfo) Equal ¶
func (s *SymbolInfo) Equal(right Object) bool
func (*SymbolInfo) IsFalsy ¶
func (s *SymbolInfo) IsFalsy() bool
func (*SymbolInfo) ToString ¶
func (s *SymbolInfo) ToString() string
func (*SymbolInfo) Type ¶
func (s *SymbolInfo) Type() ObjectType
type SymbolScope ¶
type SymbolScope uint8
SymbolScope represents a symbol scope.
const ( ScopeGlobal SymbolScope = iota + 1 ScopeLocal ScopeBuiltin ScopeFree )
List of symbol scopes
func (SymbolScope) String ¶
func (s SymbolScope) String() string
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
SymbolTable represents a symbol table.
func NewSymbolTable ¶
func NewSymbolTable(builtins *Builtins) *SymbolTable
NewSymbolTable creates new symbol table object.
func (*SymbolTable) Builtins ¶
func (st *SymbolTable) Builtins() *Builtins
func (*SymbolTable) DefineGlobal ¶
func (st *SymbolTable) DefineGlobal(name string) (*Symbol, error)
DefineGlobal adds a new symbol with ScopeGlobal in the current scope.
func (*SymbolTable) DefineGlobals ¶
func (st *SymbolTable) DefineGlobals(names []string) (s []*Symbol, err error)
DefineGlobals adds a new symbols with ScopeGlobal in the current scope.
func (*SymbolTable) DefineLocal ¶
func (st *SymbolTable) DefineLocal(name string) (*Symbol, bool)
DefineLocal adds a new symbol with ScopeLocal in the current scope.
func (*SymbolTable) DisableBuiltin ¶
func (st *SymbolTable) DisableBuiltin(names ...string) *SymbolTable
DisableBuiltin disables given builtin name(s). Compiler returns `Compile Error: unresolved reference "builtin name"` if a disabled builtin is used.
func (*SymbolTable) DisabledBuiltins ¶
func (st *SymbolTable) DisabledBuiltins() []string
DisabledBuiltins returns disabled builtin names.
func (*SymbolTable) EnableParams ¶
func (st *SymbolTable) EnableParams(v bool) *SymbolTable
EnableParams enables or disables definition of parameters.
func (*SymbolTable) Fork ¶
func (st *SymbolTable) Fork(block bool) *SymbolTable
Fork creates a new symbol table for a new scope.
func (*SymbolTable) FreeSymbols ¶
func (st *SymbolTable) FreeSymbols() []*Symbol
FreeSymbols returns registered free symbols for the scope.
func (*SymbolTable) InBlock ¶
func (st *SymbolTable) InBlock() bool
InBlock returns true if symbol table belongs to a block.
func (*SymbolTable) MaxSymbols ¶
func (st *SymbolTable) MaxSymbols() int
MaxSymbols returns the total number of symbols defined in the scope.
func (*SymbolTable) NamedParams ¶
func (st *SymbolTable) NamedParams() NamedParams
NamedParams returns named parameters for the scope.
func (*SymbolTable) NextIndex ¶
func (st *SymbolTable) NextIndex() int
NextIndex returns the next symbol index.
func (*SymbolTable) Params ¶
func (st *SymbolTable) Params() Params
Params returns parameters for the scope.
func (*SymbolTable) Parent ¶
func (st *SymbolTable) Parent(skipBlock bool) *SymbolTable
Parent returns the outer scope of the current symbol table.
func (*SymbolTable) Resolve ¶
func (st *SymbolTable) Resolve(name string) (symbol *Symbol, ok bool)
Resolve resolves a symbol with a given name.
func (*SymbolTable) SetNamedParams ¶
func (st *SymbolTable) SetNamedParams(params ...*NamedParam) (err error)
SetNamedParams sets parameters defined in the scope. This can be called only once.
func (*SymbolTable) SetParams ¶
func (st *SymbolTable) SetParams(varParams bool, params []string, types []ParamType) (err error)
SetParams sets parameters defined in the scope. This can be called only once.
func (*SymbolTable) ShadowedBuiltins ¶
func (st *SymbolTable) ShadowedBuiltins() []string
ShadowedBuiltins returns all shadowed builtin names including parent symbol tables'. Returing slice may contain duplicate names.
func (*SymbolTable) Symbols ¶
func (st *SymbolTable) Symbols() []*Symbol
Symbols returns registered symbols for the scope.
type SyncDict ¶
type SyncDict struct {
Value Dict
// contains filtered or unexported fields
}
SyncDict represents map of objects and implements Object interface.
func ToSyncDict ¶
ToSyncDict will try to convert an Object to Gad syncMap value.
func (*SyncDict) IndexDelete ¶
IndexDelete tries to delete the string value of key from the map.
func (*SyncDict) RUnlock ¶
func (o *SyncDict) RUnlock()
RUnlock unlocks the underlying mutex for reading.
func (*SyncDict) Type ¶
func (o *SyncDict) Type() ObjectType
type SyncIterator ¶
type SyncIterator struct {
*Iteration
// contains filtered or unexported fields
}
SyncIterator represents an iterator for the SyncDict.
func (*SyncIterator) NextIteration ¶
func (it *SyncIterator) NextIteration(vm *VM, state *IteratorState) (err error)
func (*SyncIterator) StartIteration ¶
func (it *SyncIterator) StartIteration(vm *VM) (state *IteratorState, err error)
type ToArrayAppenderObject ¶
type ToArrayConveter ¶
type ToArrayConveter interface {
ToArray() Array
}
type ToDictConveter ¶
type ToIterfaceConverter ¶
type ToIterfaceConverter interface {
ToInterface() any
}
type ToIterfaceVMConverter ¶
type ToReaderConverter ¶
type ToReaderConverter interface {
Reader() Reader
}
type ToWriterConverter ¶
type ToWriterConverter interface {
Writer() Writer
}
type Type ¶
type Type struct {
TypeName string
Parent ObjectType
Constructor CallerObject
Static Dict
// contains filtered or unexported fields
}
func (*Type) AddCallerMethod ¶
func (t *Type) AddCallerMethod(vm *VM, types MultipleObjectTypes, handler CallerObject, override bool) error
func (*Type) AddMethod ¶
func (t *Type) AddMethod(types MultipleObjectTypes, handler CallerObject, override bool) error
func (*Type) Caller ¶
func (t *Type) Caller() CallerObject
func (*Type) CallerMethodOfArgs ¶
func (t *Type) CallerMethodOfArgs(args Args) (co CallerObject)
func (*Type) CallerMethodOfArgsTypes ¶
func (t *Type) CallerMethodOfArgsTypes(types []ObjectType) (co CallerObject)
func (*Type) CallerMethodWithValidationCheckOfArgs ¶
func (t *Type) CallerMethodWithValidationCheckOfArgs(args Args) (co CallerObject, ok bool)
func (*Type) CallerMethodWithValidationCheckOfArgsTypes ¶
func (t *Type) CallerMethodWithValidationCheckOfArgsTypes(types []ObjectType) (co CallerObject, validate bool)
func (*Type) CallerMethods ¶
func (t *Type) CallerMethods() *MethodArgType
func (*Type) HasCallerMethods ¶
func (*Type) IsChildOf ¶
func (t *Type) IsChildOf(ot ObjectType) bool
func (*Type) Type ¶
func (t *Type) Type() ObjectType
func (*Type) WithConstructor ¶
func (t *Type) WithConstructor(handler CallerObject) *Type
func (*Type) WithMethod ¶
func (t *Type) WithMethod(types MultipleObjectTypes, handler CallerObject, override bool) *Type
type TypeAssertion ¶
type TypeAssertion struct {
Types []ObjectType
Handlers TypeAssertionHandlers
}
func NewTypeAssertion ¶
func NewTypeAssertion(handlers TypeAssertionHandlers, types ...ObjectType) *TypeAssertion
func TypeAssertionFlag ¶
func TypeAssertionFlag() *TypeAssertion
func TypeAssertionFromTypes ¶
func TypeAssertionFromTypes(types ...ObjectType) *TypeAssertion
func (*TypeAssertion) Accept ¶
func (a *TypeAssertion) Accept(value Object) (expectedNames string)
func (*TypeAssertion) AcceptHandler ¶
func (a *TypeAssertion) AcceptHandler(name string, handler TypeAssertionHandler) *TypeAssertion
func (*TypeAssertion) AcceptType ¶
func (a *TypeAssertion) AcceptType(value ObjectType) (expectedNames string)
type TypeAssertionHandler ¶
type TypeAssertionHandlers ¶
type TypeAssertionHandlers map[string]TypeAssertionHandler
type Uint ¶
type Uint uint64
Uint represents unsigned integer values and implements Object interface.
func (Uint) Type ¶
func (o Uint) Type() ObjectType
type UpDownLines ¶
type UpDownLines struct {
Up, Down int
}
type UserDataStorage ¶
type VM ¶
type VM struct {
StdOut, StdErr *StackWriter
StdIn *StackReader
ObjectToWriter ObjectToWriter
*SetupOpts
// contains filtered or unexported fields
}
VM executes the instructions in Bytecode.
func (*VM) Abort ¶
func (vm *VM) Abort()
Abort aborts the VM execution. It is safe to call this method from another goroutine.
func (*VM) Aborted ¶
Aborted reports whether VM is aborted. It is safe to call this method from another goroutine.
func (*VM) AddCallerMethod ¶
func (vm *VM) AddCallerMethod(co CallerObject, types MultipleObjectTypes, caller CallerObject) error
func (*VM) AddCallerMethodOverride ¶
func (vm *VM) AddCallerMethodOverride(co CallerObject, types MultipleObjectTypes, override bool, caller CallerObject) error
func (*VM) CallBuiltin ¶
func (*VM) GetLocals ¶
GetLocals returns variables from stack up to the NumLocals of given Bytecode. This must be called after Run() before Clear().
func (*VM) GetSymbolValue ¶
func (vm *VM) GetSymbolValue(symbol *SymbolInfo) (value Object, err error)
func (*VM) RunCompiledFunction ¶
func (vm *VM) RunCompiledFunction( f *CompiledFunction, args ...Object, ) (Object, error)
RunCompiledFunction runs given CompiledFunction as if it is Main function. Bytecode must be set before calling this method, because Fileset and Constants are copied.
func (*VM) RunCompiledFunctionOpts ¶
func (vm *VM) RunCompiledFunctionOpts( f *CompiledFunction, opts *RunOpts, ) (Object, error)
RunCompiledFunctionOpts runs given CompiledFunction as if it is Main function. Bytecode must be set before calling this method, because Fileset and Constants are copied.
func (*VM) RunOpts ¶
RunOpts runs VM and executes the instructions until the OpReturn Opcode or Abort call.
func (*VM) SetBytecode ¶
SetBytecode enables to set a new Bytecode.
func (*VM) SetRecover ¶
SetRecover recovers panic when Run panics and returns panic as an error. If error handler is present `try-catch-finally`, VM continues to run from catch/finally.
func (*VM) ToInterface ¶
func (*VM) ToInterfaceArray ¶
type VMCaller ¶
type VMCaller interface {
Call() (Object, error)
Close()
Callee() CallerObject
}
type ValuesGetter ¶
ValuesGetter is an interface for returns values.
type ValuesIterator ¶
type Writer ¶
func NewTypedWriter ¶
func NewTypedWriter(w io.Writer, typ ObjectType) Writer
func WriterFrom ¶
Source Files
¶
- builtin_operator.go
- builtin_operators.go
- builtin_types.go
- builtins.go
- builtins_funcs.go
- builtins_types.go
- builtins_types_constructors.go
- builtins_zfuncs.go
- bytecode.go
- call.go
- compiler.go
- compiler_nodes.go
- converter.go
- embed.go
- errors.go
- eval.go
- funcdef.go
- gad.go
- helper.go
- helper_foreach.go
- helper_test_compiler.go
- helpers.go
- humanize.go
- iterator.go
- methods.go
- modules.go
- numeric.go
- objects.go
- objects_api.go
- objects_api_common.go
- objects_api_converters.go
- objects_api_funcs.go
- objects_io.go
- objects_namedargs.go
- objects_print.go
- objects_print_helper.go
- objects_reflect.go
- objects_reflect_iterator.go
- objects_regexp.go
- objects_type.go
- objectwriter.go
- opcodes.go
- optimizer.go
- reflect_utils.go
- symbol_table.go
- transpile.go
- vm.go
- vm_caller.go
- vm_helper.go
- vm_invoker.go
- vm_io.go
- vm_loop.go
- vm_run.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gad
command
|
|
|
gaddoc
command
|
|
|
mkcallable
command
|
|
|
mkoptypes
command
|
|
|
strings
Package strings provides strings module implementing simple functions to manipulate UTF-8 encoded strings for Gad script language.
|
Package strings provides strings module implementing simple functions to manipulate UTF-8 encoded strings for Gad script language. |
|
time
Package time provides time module for measuring and displaying time for Gad script language.
|
Package time provides time module for measuring and displaying time for Gad script language. |
