Documentation
¶
Overview ¶
Package time provides time module for measuring and displaying time for Gad script language. It wraps ToInterface's time package functionalities. Note that: Gad's int values are converted to ToInterface's time.Duration values.
Index ¶
- Constants
- Variables
- func AddMethodT[T Object](target T, method ...TypedCallerObjectWithParamTypes) T
- func AddressOf(obj Object) unsafe.Pointer
- func ArrayToString(len int, get func(i int) Object) string
- func ArrayToStringBraces(lb, rb string, len int, get func(i int) Object) string
- 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(builtins *Builtins, constants Array, b []byte, posOffset int) []string
- func FormatReturnVars(vars ReturnVars) string
- func GoTimeArg(arg *Arg) (get func() *Time)
- func IsAssignableTo(typ, refType ObjectType) (ok bool)
- func IsFunction(o Object) (ok bool)
- 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 ObjectType, b TypeAssigner) 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 MethodInterfaceImplements(vm *VM, value Object, ifaces ...*MethodInterface) (bool, error)
- 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 ObjectsStrW(w io.Writer, vm *VM, len int, get func(i int) Object) (err error)
- func Print(state *PrinterState, o ...Object) (err error)
- func ReadOperands(numOperands []int, ins []byte, operands []int) ([]int, int)
- func Readable(o Object) (ok bool)
- func Reducable(obj Object) bool
- func ReprTypeName(o Object) (name string)
- func SplitCaller(vm *VM, caller Object, cb func(co CallerObject, types ParamsTypes) error, ...) (err error)
- 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 ToStrW(w io.Writer, vm *VM, o Object) (err error)
- func ToWritable(obj Object) bool
- func TranspileOptions() *node.TranspileOptions
- func TypeAssignerFullName(t TypeAssigner) string
- func TypeAssignerName(t TypeAssigner) string
- func TypeAssigners(t ObjectType, cb func(t ObjectType) any) (ret any)
- 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 ArgValue
- type Args
- func (o Args) Array() (ret Array)
- func (o Args) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Args) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Args) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Args) BinOpLessEq(_ *VM, 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) DestructureRangeVar(maxVar int, dst ...*Arg) (other Array, 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) DestructureVarMinCb(min int, otherCb func(i int, arg Object) error, dst ...*Arg) (err error)
- func (o Args) DestructureVarRangeCb(min, max int, otherCb func(i int, arg Object) error, dst ...*Arg) (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 *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 ObjectTypeArray)
- 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) BinOpAdd(vm *VM, right Object) (_ Object, err error)
- func (o Array) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Array) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Array) BinOpIn(_ *VM, v Object) (Object, error)
- func (o Array) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Array) BinOpLessEq(_ *VM, right Object) (Object, 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 *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) PrintObject(state *PrinterState, obj Object) (err error)
- func (o Array) SelfAssignOpAdd(_ *VM, value Object) (Object, error)
- func (o Array) SelfAssignOpInc(vm *VM, value Object) (Object, 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 BinaryOperatorType
- func (b BinaryOperatorType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (BinaryOperatorType) Call(Call) (Object, error)
- func (b BinaryOperatorType) CanAssign(obj Object) (bool, error)
- func (b BinaryOperatorType) Equal(right Object) bool
- func (BinaryOperatorType) Fields() Dict
- func (b BinaryOperatorType) FullName() string
- func (BinaryOperatorType) GadObjectType()
- func (BinaryOperatorType) Getters() Dict
- func (b BinaryOperatorType) IsFalsy() bool
- func (BinaryOperatorType) Methods() Dict
- func (BinaryOperatorType) MethodsDisabled() bool
- func (b BinaryOperatorType) Name() string
- 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
- func (o Bool) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpAnd(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpAndNot(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpLess(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpMul(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpOr(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpRem(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Bool) BinOpShl(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpShr(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpSub(vm *VM, right Object) (Object, error)
- func (o Bool) BinOpXor(vm *VM, right Object) (Object, error)
- func (o Bool) Equal(right Object) bool
- func (o Bool) Format(s fmt.State, verb rune)
- func (o Bool) IsFalsy() bool
- func (o Bool) ToString() string
- func (o Bool) Type() ObjectType
- func (o Bool) UnOpAdd(*VM) (Object, error)
- func (o Bool) UnOpSub(*VM) (Object, error)
- func (o Bool) UnOpXor(*VM) (Object, error)
- 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) Print(state *PrinterState) error
- func (o *Buffer) ToBytes() (Bytes, error)
- func (o *Buffer) ToString() string
- func (o *Buffer) Type() ObjectType
- func (o *Buffer) WriteTo(_ *VM, w io.Writer) (int64, error)
- type BuiltinCompilableModule
- type BuiltinCompileModuleContext
- type BuiltinCompileModuleFunc
- type BuiltinFunction
- func (f *BuiltinFunction) Call(c Call) (Object, error)
- func (f *BuiltinFunction) Copy() Object
- func (f *BuiltinFunction) Doc() string
- func (f *BuiltinFunction) Equal(right Object) bool
- func (*BuiltinFunction) IsFalsy() bool
- func (f *BuiltinFunction) MethodsDisabled() bool
- func (f *BuiltinFunction) Name() string
- func (f *BuiltinFunction) ParamTypes() ParamsTypes
- func (f *BuiltinFunction) ReturnVars() ReturnVars
- func (f *BuiltinFunction) String() string
- func (f *BuiltinFunction) ToString() string
- func (*BuiltinFunction) Type() ObjectType
- func (f *BuiltinFunction) WithHeader(do func(h *FunctionHeader)) *BuiltinFunction
- func (f *BuiltinFunction) WithModule(module *ModuleSpec) *BuiltinFunction
- func (f *BuiltinFunction) WithParams(builder func(newParam func(name string) *ParamBuilder)) *BuiltinFunction
- func (f *BuiltinFunction) WithParamsPairs(nameAndType ...any) *BuiltinFunction
- type BuiltinFunctionOption
- type BuiltinFunctionWithMethods
- func (f BuiltinFunctionWithMethods) Copy() Object
- func (f *BuiltinFunctionWithMethods) Equal(right Object) bool
- func (f *BuiltinFunctionWithMethods) FullName() string
- func (f *BuiltinFunctionWithMethods) FuncSpecName() string
- func (f *BuiltinFunctionWithMethods) GetModule() *ModuleSpec
- func (f *BuiltinFunctionWithMethods) Name() string
- func (f *BuiltinFunctionWithMethods) Print(state *PrinterState) (err error)
- func (f *BuiltinFunctionWithMethods) String() string
- func (f *BuiltinFunctionWithMethods) ToString() string
- func (f *BuiltinFunctionWithMethods) Type() ObjectType
- type BuiltinInitModule
- type BuiltinModule
- type BuiltinObjType
- func (t *BuiltinObjType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (t *BuiltinObjType) BuiltinType() BuiltinType
- func (t *BuiltinObjType) CanAssign(obj Object) (bool, error)
- func (t BuiltinObjType) Copy() Object
- func (t *BuiltinObjType) Equal(right Object) bool
- func (t *BuiltinObjType) Fields() Dict
- func (t *BuiltinObjType) FullName() string
- func (t *BuiltinObjType) FuncSpecName() string
- func (t *BuiltinObjType) GadObjectType()
- func (t *BuiltinObjType) GetModule() *ModuleSpec
- func (t *BuiltinObjType) Getters() Dict
- func (t *BuiltinObjType) IsFalsy() bool
- func (t *BuiltinObjType) Methods() Dict
- func (t *BuiltinObjType) Name() string
- func (t *BuiltinObjType) Print(state *PrinterState) (err error)
- func (t *BuiltinObjType) ReprTypeName() string
- func (t *BuiltinObjType) SetModule(m *ModuleSpec)
- func (t *BuiltinObjType) Setters() Dict
- func (t *BuiltinObjType) String() string
- func (t *BuiltinObjType) ToString() string
- func (t *BuiltinObjType) Type() ObjectType
- func (t *BuiltinObjType) TypeKey() BuiltinObjTypeKey
- func (t *BuiltinObjType) WithNew(f CallableFunc) *BuiltinObjType
- type BuiltinObjTypeKey
- func (b BuiltinObjTypeKey) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (b BuiltinObjTypeKey) BType() BuiltinType
- func (b BuiltinObjTypeKey) Call(c Call) (Object, error)
- func (b BuiltinObjTypeKey) CanAssign(obj Object) (bool, error)
- func (b BuiltinObjTypeKey) Equal(right Object) bool
- func (b BuiltinObjTypeKey) FullName() string
- func (BuiltinObjTypeKey) GadObjectType()
- func (b BuiltinObjTypeKey) IsFalsy() bool
- func (b BuiltinObjTypeKey) Name() string
- func (b BuiltinObjTypeKey) Print(state *PrinterState) error
- func (b BuiltinObjTypeKey) String() string
- func (b BuiltinObjTypeKey) ToString() string
- func (b BuiltinObjTypeKey) Type() ObjectType
- type BuiltinObjectsMap
- type BuiltinType
- type Builtins
- func (b *Builtins) AppendMap(m map[string]Object)
- func (b *Builtins) ArgsInvoker(t BuiltinType, c Call) func(arg ...Object) (Object, error)
- func (b *Builtins) Build() (s *StaticBuiltins)
- func (b *Builtins) Call(t BuiltinType, c Call) (Object, error)
- func (b *Builtins) Caller(t BuiltinType) CallerObject
- func (b *Builtins) Get(t BuiltinType) Object
- func (b *Builtins) Invoker(t BuiltinType, c Call) func() (Object, error)
- func (b *Builtins) Set(name string, obj Object) *Builtins
- func (b *Builtins) SetType(typ ObjectType) *Builtins
- type BuiltinsNameSet
- type Bytecode
- func Compile(st *SymbolTable, script []byte, opts CompileOptions) (pf *parser.File, bc *Bytecode, err error)
- func CompileFile(st *SymbolTable, module *ModuleSpec, pf *parser.File, opts CompileOptions) (bc *Bytecode, err error)
- func CompileModule(st *SymbolTable, module *ModuleSpec, script []byte, opts CompileOptions) (pf *parser.File, bc *Bytecode, err error)
- type Bytes
- func (o Bytes) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o Bytes) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Bytes) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Bytes) BinOpIn(_ *VM, v Object) (Object, error)
- func (o Bytes) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Bytes) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o Bytes) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Bytes) Copy() Object
- func (o Bytes) Equal(right Object) bool
- 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) Print(state *PrinterState) (err error)
- func (o Bytes) ToString() string
- func (o Bytes) ToStringF(w io.Writer) (err error)
- func (o Bytes) Type() ObjectType
- func (o Bytes) WriteTo(_ *VM, w io.Writer) (int64, error)
- type BytesConverter
- type CalendarDate
- func (o CalendarDate) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o CalendarDate) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o CalendarDate) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o CalendarDate) BinOpLess(_ *VM, right Object) (Object, error)
- func (o CalendarDate) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o CalendarDate) BinOpSub(_ *VM, right Object) (Object, error)
- func (o CalendarDate) CallName(name string, c Call) (Object, error)
- func (o CalendarDate) Day() int
- func (o CalendarDate) Equal(right Object) bool
- func (o CalendarDate) IsFalsy() bool
- func (o CalendarDate) MarshalJSON() ([]byte, error)
- func (o CalendarDate) Month() int
- func (o CalendarDate) Print(s *PrinterState) error
- func (o CalendarDate) Time(loc *time.Location) time.Time
- func (o CalendarDate) ToString() string
- func (CalendarDate) Type() ObjectType
- func (o CalendarDate) UnOpDec(*VM) (Object, error)
- func (o CalendarDate) UnOpInc(*VM) (Object, error)
- func (o CalendarDate) Year() int
- type CalendarTime
- func (o CalendarTime) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o CalendarTime) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o CalendarTime) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o CalendarTime) BinOpLess(_ *VM, right Object) (Object, error)
- func (o CalendarTime) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o CalendarTime) BinOpSub(_ *VM, right Object) (Object, error)
- func (o CalendarTime) CallName(name string, c Call) (Object, error)
- func (o CalendarTime) Date() CalendarDate
- func (o CalendarTime) Day() int
- func (o CalendarTime) Equal(right Object) bool
- func (o CalendarTime) Hour() int
- func (o CalendarTime) IsFalsy() bool
- func (o CalendarTime) MarshalJSON() ([]byte, error)
- func (o CalendarTime) Minute() int
- func (o CalendarTime) Month() int
- func (o CalendarTime) Nanosecond() int
- func (o CalendarTime) Print(s *PrinterState) error
- func (o CalendarTime) Second() int
- func (o CalendarTime) Time(loc *time.Location) time.Time
- func (o CalendarTime) ToString() string
- func (CalendarTime) Type() ObjectType
- func (o CalendarTime) UnOpDec(*VM) (Object, error)
- func (o CalendarTime) UnOpInc(*VM) (Object, error)
- func (o CalendarTime) Year() int
- type Call
- type CallOpt
- type CallWrapper
- type CallableFunc
- func FuncPTLRO(fn func(*Time, *Location) Object) CallableFunc
- func FuncPTRO(fn func(*Time) Object) CallableFunc
- func FuncPTTRO(fn func(*Time, *Time) Object) CallableFunc
- func FuncPTb2sRO(fn func(*Time, []byte, string) Object) CallableFunc
- func FuncPTi64RO(fn func(*Time, int64) Object) CallableFunc
- func FuncPTiiiRO(fn func(*Time, int, int, int) Object) CallableFunc
- func FuncPTsRO(fn func(*Time, string) Object) CallableFunc
- type CallerMethod
- type CallerMethodDefinition
- type CallerObject
- type CallerObjectWithVMParamTypes
- type CanCallerObject
- type CanCallerObjectMethodsEnabler
- type CanCallerObjectTypesValidation
- type CanCloser
- type CanFilterabler
- type CanIterabler
- type CanIterationDoner
- type CanMapeabler
- type CanReducer
- type CanToWriter
- type Char
- func (o Char) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Char) BinOpAnd(vm *VM, right Object) (Object, error)
- func (o Char) BinOpAndNot(vm *VM, right Object) (Object, error)
- func (o Char) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o Char) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o Char) BinOpLess(vm *VM, right Object) (Object, error)
- func (o Char) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o Char) BinOpMul(vm *VM, right Object) (Object, error)
- func (o Char) BinOpOr(vm *VM, right Object) (Object, error)
- func (o Char) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o Char) BinOpRem(vm *VM, right Object) (Object, error)
- func (o Char) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Char) BinOpShl(vm *VM, right Object) (Object, error)
- func (o Char) BinOpShr(vm *VM, right Object) (Object, error)
- func (o Char) BinOpSub(vm *VM, right Object) (Object, error)
- func (o Char) BinOpXor(vm *VM, right Object) (Object, error)
- func (o Char) Equal(right Object) bool
- func (o Char) Format(s fmt.State, verb rune)
- func (o Char) IsFalsy() bool
- func (o Char) ToBytes() (Bytes, error)
- func (o Char) ToString() string
- func (o Char) Type() ObjectType
- func (o Char) UnOpAdd(*VM) (Object, error)
- func (o Char) UnOpDec(*VM) (Object, error)
- func (o Char) UnOpInc(*VM) (Object, error)
- func (o Char) UnOpSub(*VM) (Object, error)
- func (o Char) UnOpXor(*VM) (Object, error)
- type ClasPropertySetter
- type Class
- func (t *Class) AddCallerMethod(_ *VM, types ParamsTypes, handler CallerObject, override bool, ...) (err error)
- func (t *Class) AddField(field ...*ClassField) error
- func (t *Class) AddMethod(name string) (_ *ClassMethod, err error)
- func (t *Class) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, ...) error
- func (t *Class) AddMethodIndex(c Call) (ret Object, err error)
- func (t *Class) AddProperty(name string, f *Func) (err error)
- func (t *Class) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (t *Class) BinOpGreater(_ *VM, right Object) (Object, error)
- func (t *Class) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (t *Class) BinOpLess(_ *VM, right Object) (Object, error)
- func (t *Class) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (t *Class) Call(c Call) (_ Object, err error)
- func (t *Class) CallAddFields(call Call) (err error)
- func (t *Class) CallAddMethods(call Call) (err error)
- func (t *Class) CallAddNewHandlers(c Call) (err error)
- func (t *Class) CallAddProperties(call Call) (err error)
- func (t *Class) CallAddProperty(c Call) (ret Object, err error)
- func (t *Class) CallExtends(c Call) (err error)
- func (t *Class) CallFieldsOf(c Call) (ret Object, err error)
- func (t *Class) CallGetProperty(c Call) (ret Object, err error)
- func (t *Class) CallName(name string, c Call) (ret Object, err error)
- func (t *Class) CallerMethodDefault() CallerObject
- func (t *Class) CallerMethodOfArgsTypes(types ObjectTypeArray) CallerObject
- func (t *Class) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
- func (t *Class) CallerMethodWithValidationCheckOfArgsTypes(types ObjectTypeArray) (CallerObject, bool)
- func (t *Class) CallerMethods() *MethodArgType
- func (t *Class) CanAssign(obj Object) (ok bool, err error)
- func (t *Class) Construct(c Call) (o Object, err error)
- func (t *Class) Constructor() *ClassConstructor
- func (t *Class) DeclaresField(name string) bool
- func (t *Class) Define(c Call) (err error)
- func (t *Class) Equal(right Object) bool
- func (t *Class) Extends(parent *Class, alias string) *Class
- func (t *Class) Fields() (d Dict)
- func (t *Class) FullName() string
- func (Class) GadObjectType()
- func (t *Class) GetFuncSpec() *FuncSpec
- func (t *Class) GetIndexMethod(_ *VM, index Object) (ret Object, err error)
- func (t *Class) GetProperty(name string) *ClassProperty
- func (t *Class) HasCallerMethods() bool
- func (t *Class) IndexGet(vm *VM, index Object) (value Object, err error)
- func (t *Class) IsChildOf(p ObjectType) bool
- func (Class) IsFalsy() bool
- func (t *Class) Methods() (d Dict)
- func (t *Class) Module() *ModuleSpec
- func (t *Class) Name() string
- func (t *Class) New(c Call) (*ClassInstance, error)
- func (t *Class) NewInstance() (o *ClassInstance)
- func (t *Class) NewInstanceWithFields(vm *VM, fields Dict) (*ClassInstance, error)
- func (t *Class) Parents() (r Array)
- func (t *Class) Print(state *PrinterState) error
- func (t *Class) Properties() (d Dict)
- func (t *Class) RawFields() (r []*ClassField)
- func (t *Class) RawParents() []*ClassParent
- func (t *Class) Repr() string
- func (t *Class) String() string
- func (t *Class) ToString() string
- func (t *Class) Type() ObjectType
- func (t *Class) Walk(cb func(parent *Class) (mode utils.WalkMode))
- type ClassConstructor
- func (c *ClassConstructor) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, ...) error
- func (c *ClassConstructor) Call(c2 Call) (Object, error)
- func (c *ClassConstructor) Equal(right Object) bool
- func (c *ClassConstructor) FullName() string
- func (c *ClassConstructor) FuncSpecName() string
- func (c *ClassConstructor) GetFuncSpec() *FuncSpec
- func (c *ClassConstructor) GetModule() *ModuleSpec
- func (c *ClassConstructor) IsFalsy() bool
- func (c *ClassConstructor) Name() string
- func (c *ClassConstructor) Print(state *PrinterState) (err error)
- func (c *ClassConstructor) String() string
- func (c *ClassConstructor) ToString() string
- func (c *ClassConstructor) Type() ObjectType
- type ClassField
- type ClassGoMethod
- type ClassGoMethodHandler
- type ClassInitiator
- type ClassInstance
- func (o *ClassInstance) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (o *ClassInstance) BinOpIn(_ *VM, v Object) (Object, error)
- func (o *ClassInstance) Call(Call) (Object, error)
- func (o *ClassInstance) CallName(name string, c Call) (_ Object, err error)
- func (o *ClassInstance) CallPrint(c Call) (err error)
- func (o *ClassInstance) Cast(t ObjectType) *ClassInstance
- func (o *ClassInstance) CastTo(_ *VM, t ObjectType) (Object, error)
- func (o *ClassInstance) Copy() Object
- func (o ClassInstance) CopyInstance() *ClassInstance
- func (o *ClassInstance) DeepCopy(vm *VM) (r Object, err error)
- func (o ClassInstance) DeepCopyInstance(vm *VM) (_ *ClassInstance, err error)
- func (o *ClassInstance) Equal(right Object) bool
- func (o *ClassInstance) Fields() Dict
- func (o *ClassInstance) GetFieldValue(vm *VM, name string) (Object, error)
- func (o *ClassInstance) GetMethod(name string) CallerObject
- func (o *ClassInstance) GetPropertyGetter(name string) (handler CallerObject, valid bool)
- func (o *ClassInstance) GetPropertySetter(name string, typ ObjectType) (handler CallerObject, valid bool)
- func (o *ClassInstance) IndexGet(vm *VM, index Object) (Object, error)
- func (o *ClassInstance) IndexSet(vm *VM, index, value Object) (err error)
- func (o *ClassInstance) Init(vm *VM, fields Dict) (err error)
- func (o *ClassInstance) Instances() func(yield func(instance *ClassInstance) bool)
- func (o *ClassInstance) IsFalsy() bool
- func (o *ClassInstance) Items(vm *VM, cb ItemsGetterCallback) (err error)
- func (o *ClassInstance) Keys() Array
- func (o *ClassInstance) Methods() *IndexGetProxy
- func (o *ClassInstance) Name() string
- func (o *ClassInstance) Parent(name string) *ClassInstance
- func (o *ClassInstance) Parents() (d Dict)
- func (o *ClassInstance) Print(state *PrinterState) error
- func (o *ClassInstance) ReprTypeName() string
- func (o *ClassInstance) ResolveField(name string) (inst *ClassInstance)
- func (o *ClassInstance) ResolveMethod(name string) (inst *ClassInstance, m *ClassMethod)
- func (o *ClassInstance) ResolveProperty(name string) (inst *ClassInstance, p *ClassProperty)
- func (o *ClassInstance) SetFieldValue(vm *VM, name string, value Object) error
- func (o *ClassInstance) ToDict() (d Dict)
- func (o *ClassInstance) ToString() string
- func (o *ClassInstance) Type() ObjectType
- func (o *ClassInstance) Values() Array
- func (o *ClassInstance) WalkInstances(cb func(path []*ClassInstance, instance *ClassInstance) (mode utils.WalkMode))
- func (o *ClassInstance) WalkProperty(name string, f func(inst *ClassInstance, p *ClassProperty) (next bool))
- type ClassInstanceMethod
- func (m *ClassInstanceMethod) Call(c Call) (Object, error)
- func (m *ClassInstanceMethod) Equal(right Object) bool
- func (m *ClassInstanceMethod) FullName() string
- func (m *ClassInstanceMethod) FuncSpecName() string
- func (m *ClassInstanceMethod) IsFalsy() bool
- func (m *ClassInstanceMethod) Name() string
- func (m *ClassInstanceMethod) Print(state *PrinterState) (err error)
- func (m *ClassInstanceMethod) String() string
- func (m *ClassInstanceMethod) ToString() string
- func (m *ClassInstanceMethod) Type() ObjectType
- type ClassInstancePropertyGetter
- func (m *ClassInstancePropertyGetter) Call(c Call) (Object, error)
- func (m *ClassInstancePropertyGetter) Equal(right Object) bool
- func (m *ClassInstancePropertyGetter) IndexGet(vm *VM, index Object) (value Object, err error)
- func (m *ClassInstancePropertyGetter) IsFalsy() bool
- func (m *ClassInstancePropertyGetter) Name() string
- func (m *ClassInstancePropertyGetter) Print(state *PrinterState) (err error)
- func (m *ClassInstancePropertyGetter) String() string
- func (m *ClassInstancePropertyGetter) ToString() string
- func (m *ClassInstancePropertyGetter) Type() ObjectType
- type ClassInstancePropertySetter
- func (m *ClassInstancePropertySetter) Equal(right Object) bool
- func (m *ClassInstancePropertySetter) IndexGet(vm *VM, index Object) (value Object, err error)
- func (m *ClassInstancePropertySetter) IsFalsy() bool
- func (m *ClassInstancePropertySetter) Name() string
- func (m *ClassInstancePropertySetter) Print(state *PrinterState) (err error)
- func (m *ClassInstancePropertySetter) Set(v Object) (err error)
- func (m *ClassInstancePropertySetter) String() string
- func (m *ClassInstancePropertySetter) ToString() string
- func (m *ClassInstancePropertySetter) Type() ObjectType
- type ClassMethod
- func (m *ClassMethod) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, ...) error
- func (m *ClassMethod) Call(c Call) (Object, error)
- func (m *ClassMethod) Equal(right Object) bool
- func (m *ClassMethod) FullName() string
- func (m *ClassMethod) FuncSpecName() string
- func (m *ClassMethod) GetFuncSpec() *FuncSpec
- func (m *ClassMethod) IsFalsy() bool
- func (m *ClassMethod) Name() string
- func (m *ClassMethod) NewInstance(this *ClassInstance) *ClassInstanceMethod
- func (m *ClassMethod) Print(state *PrinterState) (err error)
- func (m *ClassMethod) ReprTypeName() string
- func (m *ClassMethod) String() string
- func (m *ClassMethod) ToString() string
- func (m *ClassMethod) Type() ObjectType
- type ClassParent
- type ClassProperty
- func (p *ClassProperty) Add(handler CallerObject, argTypes ParamsTypes) (err error)
- func (p *ClassProperty) AddGetter(v Object, thisType ParamTypes, override bool, ...) (err error)
- func (p *ClassProperty) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, ...) error
- func (p *ClassProperty) AddSetter(v Object, thisType, valueType ParamTypes, override bool, ...) (err error)
- func (p *ClassProperty) Call(c Call) (Object, error)
- func (p *ClassProperty) CallerMethodDefault() CallerObject
- func (p *ClassProperty) CallerMethodOfArgsTypes(types ObjectTypeArray) CallerObject
- func (p *ClassProperty) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
- func (p *ClassProperty) CallerMethodWithValidationCheckOfArgsTypes(types ObjectTypeArray) (CallerObject, bool)
- func (p *ClassProperty) CallerMethods() *MethodArgType
- func (p ClassProperty) Clone() *ClassProperty
- func (p *ClassProperty) Equal(right Object) bool
- func (p *ClassProperty) FullName() string
- func (p *ClassProperty) FuncSpecName() string
- func (p *ClassProperty) GetFuncSpec() *FuncSpec
- func (p *ClassProperty) GetModule() *ModuleSpec
- func (p *ClassProperty) HasCallerMethods() bool
- func (p *ClassProperty) IsFalsy() bool
- func (p *ClassProperty) Name() string
- func (p *ClassProperty) NewGetter(this *ClassInstance) *ClassInstancePropertyGetter
- func (p *ClassProperty) NewSetter(vm *VM, this *ClassInstance) *ClassInstancePropertySetter
- func (p *ClassProperty) Print(state *PrinterState) (err error)
- func (p *ClassProperty) ReprTypeName() string
- func (p *ClassProperty) String() string
- func (p *ClassProperty) ToString() string
- func (p *ClassProperty) Type() ObjectType
- func (p *ClassProperty) VMAdd(vm *VM, v Object) error
- 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) Copy() Object
- func (o *CompiledFunction) Equal(right Object) bool
- func (o *CompiledFunction) Format(f fmt.State, verb rune)
- func (o *CompiledFunction) Fprint(builtins *Builtins, w io.Writer, bc *Bytecode)
- func (o *CompiledFunction) FprintLP(builtins *Builtins, constants Array, linePrefix string, w io.Writer)
- func (o *CompiledFunction) FullName() string
- func (o *CompiledFunction) GetModule() *ModuleSpec
- func (o *CompiledFunction) GetReturnVars() ReturnVars
- func (o *CompiledFunction) HasStructuralParamTypes() bool
- func (o *CompiledFunction) HeaderString() string
- func (*CompiledFunction) IsFalsy() bool
- func (o *CompiledFunction) Name() string
- func (o *CompiledFunction) ParamTypes(vm *VM) (types ParamsTypes, err error)
- func (o *CompiledFunction) Print(state *PrinterState) error
- func (o *CompiledFunction) SetModule(m *ModuleSpec)
- 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) WithNamedParams(names ...string) *CompiledFunction
- func (o *CompiledFunction) WithParams(names ...string) *CompiledFunction
- type Compiler
- func (c *Compiler) BaseEmbedMap() *EmbeddedMap
- func (c *Compiler) BaseModuleMap() *ModuleMap
- func (c *Compiler) Bytecode() *Bytecode
- func (c *Compiler) Compile(nd ast.Node) error
- func (c *Compiler) CompileModule(nd *ModuleStmt) (err error)
- func (c *Compiler) Errorf(nd ast.Node, format string, args ...any) error
- func (c *Compiler) Options() *CompileOptions
- func (c *Compiler) SetGlobalSymbolsIndex()
- type CompilerError
- type CompilerOptions
- type ComputedValue
- func (v *ComputedValue) Call(c Call) (Object, error)
- func (v *ComputedValue) Equal(right Object) bool
- func (v *ComputedValue) IsFalsy() bool
- func (v *ComputedValue) Name() string
- func (v *ComputedValue) Print(state *PrinterState) error
- func (v *ComputedValue) ReprTypeName() string
- func (v *ComputedValue) String() string
- func (v *ComputedValue) ToString() string
- func (ComputedValue) Type() ObjectType
- type Copier
- type DebugFrame
- type DebugStepper
- type Decimal
- func (o Decimal) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpMul(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpPow(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpQuo(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Decimal) BinOpSub(_ *VM, 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
- func (o Decimal) UnOpDec(*VM) (Object, error)
- func (o Decimal) UnOpInc(*VM) (Object, error)
- type DeepCopier
- type Dict
- func AnyMapToMap(src map[string]any) (m Dict, err error)
- func Base64Module() Dict
- func ConvertToDict(vm *VM, o ...Object) (ret Dict, err error)
- func FmtModule() Dict
- func GadModule() Dict
- func MustConvertToDict(vm *VM, o ...Object) Dict
- func StringsModule() Dict
- func TimeModule() Dict
- func ToDict(o Object) (v Dict, ok bool)
- func (o Dict) Backup(key string) func()
- func (o Dict) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Dict) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Dict) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Dict) BinOpIn(_ *VM, v Object) (Object, error)
- func (o Dict) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Dict) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o Dict) BinOpSub(vm *VM, right Object) (Object, 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 *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) PrintObject(state *PrinterState, dot Object) (err error)
- func (o Dict) Set(key string, value Object)
- func (o Dict) SortedKeys() Array
- func (o Dict) ToDict() Dict
- func (o Dict) ToInterface(vm *VM) any
- func (o Dict) ToInterfaceMap(vm *VM) (m map[string]any)
- func (o Dict) ToKeyValueArray() (arr KeyValueArray)
- func (o Dict) ToNamedArgs() *NamedArgs
- func (o Dict) ToString() string
- func (o Dict) Type() ObjectType
- func (o Dict) UpdateIndexSetter(out StringIndexSetter)
- func (o Dict) Values() Array
- type Duration
- func (o Duration) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpMul(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpQuo(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpRem(_ *VM, right Object) (Object, error)
- func (o Duration) BinOpSub(_ *VM, right Object) (Object, error)
- func (o Duration) CallName(name string, c Call) (Object, error)
- func (o Duration) Equal(right Object) bool
- func (o Duration) IsFalsy() bool
- func (o Duration) MarshalJSON() ([]byte, error)
- func (o Duration) Print(s *PrinterState) error
- func (o Duration) ToString() string
- func (Duration) Type() ObjectType
- func (o Duration) UnOpAdd(*VM) (Object, error)
- func (o Duration) UnOpSub(*VM) (Object, error)
- type Embedded
- func (n *Embedded) Dirs(recursive bool) (ret []*Embedded)
- func (n *Embedded) Equal(right Object) bool
- func (n *Embedded) FS() (*EmbeddedNodeFS, error)
- func (n *Embedded) Files(recursive bool) (ret []*Embedded)
- func (n *Embedded) FullPath() string
- func (n *Embedded) Get(pth string) (e *Embedded, err error)
- func (n *Embedded) GetNode(name string) *Embedded
- func (n *Embedded) IndexGet(vm *VM, index Object) (value Object, err error)
- func (n *Embedded) IsDir() bool
- func (n *Embedded) IsFalsy() bool
- func (n *Embedded) JoinToArray() (ret []*Embedded)
- func (n *Embedded) Path() string
- func (n *Embedded) Print(state *PrinterState) (err error)
- func (n *Embedded) Read() (b []byte, err error)
- func (n *Embedded) Reader() (r io.ReadSeeker, err error)
- func (n *Embedded) Size() (_ int64, err error)
- func (n *Embedded) SortedNames() (ret []string)
- func (n *Embedded) ToBytes() (Bytes, error)
- func (n *Embedded) ToString() string
- func (n *Embedded) Type() ObjectType
- func (n *Embedded) Walk(cb func(path []string, n *Embedded) error) (err error)
- func (n *Embedded) WalkR(recursive bool, cb func(path []string, n *Embedded) error) (err error)
- type EmbeddedBytesReaderFactory
- type EmbeddedExtImporter
- type EmbeddedFile
- type EmbeddedFileData
- type EmbeddedFileImporter
- type EmbeddedImportOptions
- type EmbeddedImporter
- type EmbeddedLimittedReaderFactory
- type EmbeddedMap
- func (m *EmbeddedMap) Add(name string, module EmbeddedImporter) *EmbeddedMap
- func (m *EmbeddedMap) AddFile(path string, data []byte) *EmbeddedMap
- func (m *EmbeddedMap) Copy() *EmbeddedMap
- func (m *EmbeddedMap) Get(name string) EmbeddedImporter
- func (m *EmbeddedMap) Remove(name string)
- func (m *EmbeddedMap) SetExtImporter(im EmbeddedExtImporter) *EmbeddedMap
- type EmbeddedNodeFS
- func (e *EmbeddedNodeFS) Equal(right Object) bool
- func (e *EmbeddedNodeFS) IndexGet(_ *VM, index Object) (value Object, err error)
- func (e *EmbeddedNodeFS) IsFalsy() bool
- func (e *EmbeddedNodeFS) Iterate(_ *VM, na *NamedArgs) Iterator
- func (e *EmbeddedNodeFS) Print(state *PrinterState) error
- func (e *EmbeddedNodeFS) ToDict() (d Dict)
- func (e *EmbeddedNodeFS) ToString() string
- func (e *EmbeddedNodeFS) Type() ObjectType
- type EmbeddedOsFileReaderFactory
- type EmbeddedReaderFactory
- type Enum
- func (e *Enum) AddValue(name string, value Object)
- func (e *Enum) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (e *Enum) Call(c Call) (Object, error)
- func (e *Enum) CanAssign(obj Object) (bool, error)
- func (e *Enum) CanCall() bool
- func (e *Enum) Equal(right Object) bool
- func (e *Enum) FullName() string
- func (e *Enum) GadObjectType()
- func (e *Enum) GetModule() *ModuleSpec
- func (e *Enum) IndexGet(vm *VM, index Object) (value Object, err error)
- func (e *Enum) IsFalsy() bool
- func (e *Enum) Iterate(_ *VM, na *NamedArgs) Iterator
- func (e *Enum) Name() string
- func (e *Enum) Print(state *PrinterState) error
- func (e *Enum) ReprTypeName() string
- func (e *Enum) SetModule(m *ModuleSpec)
- func (e *Enum) String() string
- func (e *Enum) ToArray() (arr Array)
- func (e *Enum) ToDict() (d Dict)
- func (e *Enum) ToString() string
- func (e *Enum) Type() ObjectType
- type EnumValue
- 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 NewEmbeddedPathIsDir(path string) *Error
- func NewEmbeddedPathIsNtDir(path string) *Error
- func NewIndexTypeError(expectType, foundType string) *Error
- func NewIndexTypeErrorT(foundType ObjectType, expectType ...ObjectType) *Error
- func NewIndexValueTypeError(index string, 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 NewStructPropertyInstanceError(propertyName, message 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) NewErrorf(format string, arg ...any) *Error
- func (o *Error) ToString() string
- func (o *Error) Type() ObjectType
- func (o *Error) Unwrap() error
- func (o *Error) Wrap(cause error, msg string) *Error
- func (o *Error) Wrapf(cause error, format string, arg ...any) *Error
- type ErrorHumanizing
- type Eval
- type ExtImporter
- type Falser
- type Filterabler
- type Flag
- func (o Flag) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpAnd(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpAndNot(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpLess(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpMul(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpOr(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpRem(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Flag) BinOpShl(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpShr(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpSub(vm *VM, right Object) (Object, error)
- func (o Flag) BinOpXor(vm *VM, right Object) (Object, error)
- func (o Flag) Equal(right Object) bool
- func (o Flag) IsFalsy() bool
- func (o Flag) ToString() string
- func (o Flag) Type() ObjectType
- func (o Flag) UnOpAdd(*VM) (Object, error)
- func (o Flag) UnOpNot(*VM) (Object, error)
- func (o Flag) UnOpXor(*VM) (Object, error)
- type Float
- func (o Float) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Float) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o Float) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o Float) BinOpLess(vm *VM, right Object) (Object, error)
- func (o Float) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o Float) BinOpMul(vm *VM, right Object) (Object, error)
- func (o Float) BinOpPow(vm *VM, right Object) (Object, error)
- func (o Float) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o Float) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Float) BinOpSub(vm *VM, right Object) (Object, error)
- func (o Float) Equal(right Object) bool
- func (o Float) Format(s fmt.State, verb rune)
- func (o Float) IsFalsy() bool
- func (o Float) ToString() string
- func (o Float) Type() ObjectType
- func (o Float) UnOpAdd(*VM) (Object, error)
- func (o Float) UnOpDec(*VM) (Object, error)
- func (o Float) UnOpInc(*VM) (Object, error)
- func (o Float) UnOpSub(*VM) (Object, error)
- type FmtScanArg
- type Func
- func (f *Func) Equal(right Object) bool
- func (f *Func) FullName() string
- func (f *Func) FuncSpecName() string
- func (f *Func) GetModule() *ModuleSpec
- func (f *Func) Name() string
- func (f *Func) Print(state *PrinterState) (err error)
- func (f *Func) String() string
- func (f *Func) ToString() string
- func (f *Func) Type() ObjectType
- type FuncHeaderObject
- func (h *FuncHeaderObject) Equal(right Object) bool
- func (h *FuncHeaderObject) FullName() string
- func (h *FuncHeaderObject) IndexGet(_ *VM, index Object) (Object, error)
- func (h *FuncHeaderObject) IsFalsy() bool
- func (h *FuncHeaderObject) Name() string
- func (h *FuncHeaderObject) String() string
- func (h *FuncHeaderObject) ToString() string
- func (h *FuncHeaderObject) Type() ObjectType
- type FuncSpec
- func (s *FuncSpec) AddMethod(vm *VM, handler CallerObject, override bool, ...) error
- func (s *FuncSpec) AddMethodByTypes(_ *VM, argTypes ParamsTypes, handler CallerObject, override bool, ...) error
- func (s *FuncSpec) Call(c Call) (Object, error)
- func (s *FuncSpec) CallerMethodDefault() CallerObject
- func (s *FuncSpec) CallerMethodOfArgsTypes(types ObjectTypeArray) (co CallerObject)
- func (s *FuncSpec) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
- func (s *FuncSpec) CallerMethodWithValidationCheckOfArgsTypes(types ObjectTypeArray) (co CallerObject, validate bool)
- func (s *FuncSpec) CallerMethods() *MethodArgType
- func (s FuncSpec) CopyWithTarget(target FuncWrapper) *FuncSpec
- func (s *FuncSpec) GetFuncSpec() *FuncSpec
- func (s *FuncSpec) HasCallerMethods() bool
- func (s *FuncSpec) IsFalsy() bool
- func (s *FuncSpec) MethodOrDefault(types ObjectTypeArray) (method *TypedCallerMethod, defaul CallerObject)
- func (s *FuncSpec) PrintFuncWrapper(state *PrinterState, fo FuncWrapper) (err error)
- type FuncSpecOption
- type FuncWrapper
- type Function
- func (f *Function) Call(call Call) (Object, error)
- func (f Function) Copy() Object
- func (f *Function) Equal(right Object) bool
- func (f *Function) GetModule() *ModuleSpec
- func (*Function) IsFalsy() bool
- func (f *Function) Name() string
- func (f *Function) ParamTypes() (types ParamsTypes)
- func (f *Function) ReturnVars() ReturnVars
- func (f *Function) SetModule(m *ModuleSpec)
- func (f *Function) String() string
- func (f *Function) ToString() string
- func (*Function) Type() ObjectType
- func (f *Function) WithHeader(do func(h *FunctionHeader)) *Function
- func (f *Function) WithOption(opt ...FunctionOption) *Function
- func (f *Function) WithParams(builder func(newParam func(name string) *ParamBuilder)) *Function
- func (f *Function) WithParamsPairs(nameAndType ...any) *Function
- type FunctionHeader
- func (h *FunctionHeader) ParamTypes() ParamsTypes
- func (h *FunctionHeader) String() string
- func (h *FunctionHeader) WithNamedParams(builder func(newParam func(name string) *NamedParamBuilder)) *FunctionHeader
- func (h *FunctionHeader) WithParams(builder func(newParam func(name string) *ParamBuilder)) *FunctionHeader
- func (h *FunctionHeader) WithReturnVars(builder func(ret func(name string, typ ...ObjectType))) *FunctionHeader
- type FunctionHeaderParam
- type FunctionOption
- func FunctionWithModule(spec *ModuleSpec) FunctionOption
- func FunctionWithNamedParams(builder func(newParam func(name string) *NamedParamBuilder)) FunctionOption
- func FunctionWithParams(builder func(newParam func(name string) *ParamBuilder)) FunctionOption
- func FunctionWithUsage(usage string) FunctionOption
- type Importable
- type IndexDelProxy
- type IndexDeleteProxy
- func (o *IndexDeleteProxy) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o *IndexDeleteProxy) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o *IndexDeleteProxy) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o *IndexDeleteProxy) BinOpLess(_ *VM, right Object) (Object, error)
- func (o *IndexDeleteProxy) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o *IndexDeleteProxy) BinOpSub(vm *VM, right Object) (_ Object, err error)
- 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) Print(state *PrinterState) error
- func (i *IndexGetProxy) ToInterface() any
- func (i *IndexGetProxy) ToString() string
- func (i *IndexGetProxy) Type() ObjectType
- type IndexGetSetter
- type IndexGetter
- type IndexMethodAdder
- type IndexMethodGetter
- type IndexProxy
- func (o *IndexProxy) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o *IndexProxy) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o *IndexProxy) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o *IndexProxy) BinOpLess(_ *VM, right Object) (Object, error)
- func (o *IndexProxy) BinOpLessEq(_ *VM, right Object) (Object, error)
- type IndexSetProxy
- type IndexSetter
- type IndexSetterUpdater
- type IndexableStructField
- type Indexer
- type Int
- func (o Int) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Int) BinOpAnd(vm *VM, right Object) (Object, error)
- func (o Int) BinOpAndNot(vm *VM, right Object) (Object, error)
- func (o Int) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o Int) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o Int) BinOpLess(vm *VM, right Object) (Object, error)
- func (o Int) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o Int) BinOpMul(vm *VM, right Object) (Object, error)
- func (o Int) BinOpOr(vm *VM, right Object) (Object, error)
- func (o Int) BinOpPow(vm *VM, right Object) (Object, error)
- func (o Int) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o Int) BinOpRem(vm *VM, right Object) (Object, error)
- func (o Int) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Int) BinOpShl(vm *VM, right Object) (Object, error)
- func (o Int) BinOpShr(vm *VM, right Object) (Object, error)
- func (o Int) BinOpSub(vm *VM, right Object) (Object, error)
- func (o Int) BinOpXor(vm *VM, right Object) (Object, error)
- func (o Int) Equal(right Object) bool
- func (o Int) Format(s fmt.State, verb rune)
- func (o Int) IsFalsy() bool
- func (o Int) ToString() string
- func (o Int) Type() ObjectType
- func (o Int) UnOpAdd(*VM) (Object, error)
- func (o Int) UnOpDec(*VM) (Object, error)
- func (o Int) UnOpInc(*VM) (Object, error)
- func (o Int) UnOpSub(*VM) (Object, error)
- func (o Int) UnOpXor(*VM) (Object, error)
- type Interface
- func (i *Interface) AssignTo(vm *VM, obj Object, to TypeAssigner) (Object, error)
- func (i *Interface) CanAssign(obj Object) (bool, error)
- func (i *Interface) CanAssignVM(vm *VM, obj Object) (bool, error)
- func (i *Interface) Equal(right Object) bool
- func (i *Interface) FullName() string
- func (i *Interface) IndexGet(_ *VM, index Object) (Object, error)
- func (i *Interface) IsFalsy() bool
- func (i *Interface) Name() string
- func (i *Interface) String() string
- func (i *Interface) ToString() string
- func (i *Interface) Type() ObjectType
- func (i *Interface) WithField(name string, types ...ObjectType) *Interface
- func (i *Interface) WithGetter(name string, getter *FuncHeaderObject) *Interface
- func (i *Interface) WithMethod(name string, headers ...*FuncHeaderObject) *Interface
- func (i *Interface) WithSetter(name string, setters ...*FuncHeaderObject) *Interface
- type InterfaceField
- type InterfaceMethod
- type InterfaceProp
- 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
- func (inv *Invoker) WithContext(ctx context.Context) *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) Print(state *PrinterState) 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 Iterators
- type KeyValue
- func (o *KeyValue) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o *KeyValue) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o *KeyValue) BinOpLess(vm *VM, right Object) (Object, error)
- func (o *KeyValue) BinOpLessEq(vm *VM, 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) 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) AppendArrayOfPairs(arr Array) error
- func (o KeyValueArray) AppendMap(m Dict) KeyValueArray
- func (o KeyValueArray) AppendObjects(vm *VM, items ...Object) (this Object, err error)
- func (o KeyValueArray) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o KeyValueArray) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o KeyValueArray) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o KeyValueArray) BinOpIn(_ *VM, v Object) (Object, error)
- func (o KeyValueArray) BinOpLess(_ *VM, right Object) (Object, error)
- func (o KeyValueArray) BinOpLessEq(_ *VM, 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 *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) Sort(vm *VM, less CallerObject) (_ Object, err error)
- func (o KeyValueArray) SortReverse(vm *VM) (Object, error)
- func (o KeyValueArray) ToArray() (arr Array)
- func (o KeyValueArray) ToString() string
- func (o KeyValueArray) Type() ObjectType
- func (o KeyValueArray) UpdateIndexSetter(out StringIndexSetter)
- func (o KeyValueArray) Values() (arr Array)
- type KeyValueArrays
- func (o KeyValueArrays) Array() (ret Array)
- func (o KeyValueArrays) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o KeyValueArrays) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o KeyValueArrays) BinOpLess(_ *VM, right Object) (Object, error)
- func (o KeyValueArrays) BinOpLessEq(_ *VM, 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 *VM, na *NamedArgs) Iterator
- func (o KeyValueArrays) Length() int
- func (o KeyValueArrays) Print(state *PrinterState) (err error)
- func (o KeyValueArrays) ToString() string
- func (KeyValueArrays) Type() ObjectType
- type KeysGetter
- type LengthGetter
- type LengthIterator
- type LimitedIterator
- type Location
- type Mapabler
- type MethodAdder
- type MethodArgType
- func (at *MethodArgType) Add(types ParamsTypes, m *CallerMethod, override bool, ...) (err error)
- func (at *MethodArgType) ArgWalk(f func(m *MethodArgType) any) (r any)
- func (at MethodArgType) Copy() *MethodArgType
- func (at *MethodArgType) EachMethods() func(func(i int, m *MethodArgType) bool)
- func (at *MethodArgType) GetMethod(types ObjectTypeArray) *TypedCallerMethod
- func (at *MethodArgType) IsZero() (ok bool)
- func (at *MethodArgType) MethodsWalk(f func(m *MethodArgType) any) (r any)
- func (at *MethodArgType) NumMethods() (i int)
- func (at *MethodArgType) Parents() (parents []*MethodArgType)
- func (at *MethodArgType) Path() (path []*MethodArgType)
- func (at *MethodArgType) ToString() string
- func (at *MethodArgType) Walk(cb func(m *TypedCallerMethod) any) (v any)
- func (at *MethodArgType) WalkSorted(cb func(m *TypedCallerMethod) any) (v any)
- type MethodCaller
- type MethodDefinition
- type MethodInterface
- func (m *MethodInterface) AssignTo(vm *VM, obj Object, to TypeAssigner) (Object, error)
- func (m *MethodInterface) BinOpAdd(_ *VM, right Object) (Object, error)
- func (m *MethodInterface) BinOpIn(_ *VM, v Object) (Object, error)
- func (m *MethodInterface) CanAssign(obj Object) (bool, error)
- func (m *MethodInterface) CanAssignVM(vm *VM, obj Object) (bool, error)
- func (m *MethodInterface) Equal(right Object) bool
- func (m *MethodInterface) HeadersArray() Array
- func (m *MethodInterface) IndexGet(_ *VM, index Object) (Object, error)
- func (m *MethodInterface) IsFalsy() bool
- func (m *MethodInterface) Name() string
- func (m *MethodInterface) String() string
- func (m *MethodInterface) ToString() string
- func (m *MethodInterface) Type() ObjectType
- type Methods
- type MixedParams
- 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) Print(state *PrinterState) error
- func (m *MixedParams) ToDict() (d Dict)
- func (m *MixedParams) ToString() string
- func (m *MixedParams) Type() ObjectType
- func (m *MixedParams) UpdateIndexSetter(out StringIndexSetter)
- type Module
- func (m *Module) CanCall() bool
- func (m *Module) CanIterate() bool
- func (m *Module) Equal(right Object) bool
- func (m *Module) File() string
- func (m *Module) IndexGet(vm *VM, index Object) (value Object, err error)
- func (m *Module) IndexSet(vm *VM, index, value Object) error
- func (m *Module) IsFalsy() bool
- func (m *Module) Items(vm *VM, cb ItemsGetterCallback) (err error)
- func (m *Module) Iterate(vm *VM, na *NamedArgs) Iterator
- func (m *Module) Keys() (arr Array)
- func (m *Module) Length() int
- func (m *Module) MergeData(d Dict)
- func (m *Module) Name() string
- func (m *Module) Print(state *PrinterState) (err error)
- func (m *Module) Set(key string, value Object)
- func (m *Module) String() string
- func (m *Module) ToDict() Dict
- func (m *Module) ToString() string
- func (m *Module) Type() ObjectType
- func (m *Module) UpdateIndexSetter(out StringIndexSetter)
- func (m *Module) Values() (arr Array)
- type ModuleData
- type ModuleGetter
- type ModuleInfo
- type ModuleInitFunc
- type ModuleMap
- func (m *ModuleMap) Add(name string, module Importable) *ModuleMap
- func (m *ModuleMap) AddBuiltinCompilableModule(name string, compile BuiltinCompileModuleFunc) *ModuleMap
- func (m *ModuleMap) AddBuiltinModule(name string, attrs map[string]Object) *ModuleMap
- func (m *ModuleMap) AddBuiltinModuleInit(name string, init ModuleInitFunc) *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) Importers() map[string]Importable
- func (m *ModuleMap) Remove(name string)
- func (m *ModuleMap) SetExtImporter(im ExtImporter) *ModuleMap
- type ModuleSetter
- type ModuleSpec
- type ModuleStmt
- type Modules
- type NameCallerObject
- type NamedArgVar
- type NamedArgs
- func (o *NamedArgs) Add(obj Object) (err error)
- func (o *NamedArgs) AllDict() (ret Dict)
- func (o *NamedArgs) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o *NamedArgs) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o *NamedArgs) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o *NamedArgs) BinOpLess(_ *VM, right Object) (Object, error)
- func (o *NamedArgs) BinOpLessEq(_ *VM, 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) GetDo(dst ...*NamedArgVar) (err error)
- func (o *NamedArgs) GetDoCheck(check bool, dst ...*NamedArgVar) (err error)
- func (o *NamedArgs) GetOne(dst ...*NamedArgVar) (err error)
- func (o *NamedArgs) GetOneDo(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) IsReadOnly() 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) Print(state *PrinterState) (err error)
- func (o *NamedArgs) Ready() (arr KeyValueArray)
- func (o *NamedArgs) SetReadOnly(v bool)
- 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)
- func (o *NamedArgs) WithReadOnly(v bool) *NamedArgs
- type NamedParam
- type NamedParamBuilder
- type NamedParams
- func (n *NamedParams) ByName() map[string]int
- func (n *NamedParams) EachNonVar(cb func(i int, p *NamedParam))
- func (n *NamedParams) Len() int
- func (n *NamedParams) Names() (names []string)
- func (n *NamedParams) String() string
- func (n *NamedParams) ToMap() (np map[string]*NamedParam)
- func (n *NamedParams) Variadic() bool
- type NamedParamsVar
- type NextIterationHandler
- type NilType
- func (o *NilType) BinOpGreater(_ *VM, _ Object) (Object, error)
- func (o *NilType) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o *NilType) BinOpLess(_ *VM, right Object) (Object, error)
- func (o *NilType) BinOpLessEq(_ *VM, _ Object) (Object, error)
- func (o *NilType) BinOpSame(_ *VM, right Object) (Object, error)
- func (o *NilType) Equal(right Object) bool
- func (o *NilType) Format(f fmt.State, verb rune)
- func (o *NilType) IsNil() bool
- func (o *NilType) Print(state *PrinterState) error
- func (o *NilType) ToString() string
- func (o *NilType) Type() ObjectType
- type Niler
- type Object
- func AddMethod(target Object, method ...TypedCallerObjectWithParamTypes) Object
- func AddMethodOverride(override bool, target Object, method ...TypedCallerObjectWithParamTypes) Object
- func AssignToType(vm *VM, obj, to Object) (Object, error)
- func BinaryOp(vm *VM, tok token.Token, left, right Object) (Object, error)
- func BuiltinAddMethodFunc(c Call) (ret Object, err error)
- 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 BuiltinEnterFunc(c Call) (ret Object, err error)
- func BuiltinEnumerateFunc(c Call) (_ Object, err error)
- func BuiltinExitFunc(c Call) (ret Object, err error)
- func BuiltinFilterFunc(c Call) (_ Object, err error)
- func BuiltinFlushFunc(c Call) (Object, error)
- func BuiltinImplementsFunc(c Call) (_ Object, err 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(c Call) (_ Object, err error)
- func BuiltinMakeArrayFunc(n int, arg Object) (Object, error)
- func BuiltinMakeArrayRestFunc(n int, arg Object) (Object, error)
- func BuiltinMapFunc(c Call) (_ Object, err error)
- func BuiltinMethodFromArgsFunc(c Call) (ret Object, err error)
- func BuiltinMultiValueDictFunc(c Call) (ret Object, err error)
- func BuiltinNamedParamTypeCheckFunc(c Call) (val 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 BuiltinToArrayFunc(c Call) (_ Object, err error)
- func BuiltinTypeNameFunc(arg Object) Object
- func BuiltinTypeOfFunc(c Call) (_ Object, err error)
- func BuiltinUnaryOperatorFunc(c Call) (ret 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 NewCalendarDateFunc(c Call) (Object, error)
- func NewCalendarTimeFunc(c Call) (Object, error)
- func NewClassFunc(c Call) (ret Object, err error)
- func NewComputedValue(c Call) (_ Object, err error)
- func NewDictFunc(c Call) (ret Object, err error)
- func NewDurationFunc(c Call) (Object, error)
- func NewErrorFunc(c Call) (ret Object, err error)
- func NewFuncFunc(c Call) (_ Object, err error)
- func NewFunctionHeaderFunc(c Call) (_ Object, err error)
- func NewKeyValueArrayFunc(c Call) (ret Object, err error)
- func NewKeyValueFunc(c Call) (ret Object, err error)
- func NewLocationFunc(c Call) (Object, error)
- func NewMethodInterfaceFunc(c Call) (_ Object, err error)
- func NewMixedParamsFunc(c Call) (ret Object, err error)
- func NewPrinterStateFunc(c Call) (ret Object, err error)
- func NewPropFunc(c Call) (_ Object, err error)
- func NewRangeFunc(c Call) (Object, 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 NewTimeFunc(c Call) (Object, error)
- func NewTypedIdentFunc(c Call) (ret Object, err error)
- func ObjectOrNil(v Object) Object
- func TimeAdd(t *Time, duration int64) Object
- func TimeAddDate(t *Time, years, months, days int) Object
- func TimeAfter(t1, t2 *Time) Object
- func TimeAppendFormat(t *Time, b []byte, layout string) Object
- func TimeBefore(t1, t2 *Time) Object
- func TimeDateFunc(c Call) (Object, error)
- func TimeDurationHoursFunc(d int64) Object
- func TimeDurationMicrosecondsFunc(d int64) Object
- func TimeDurationMillisecondsFunc(d int64) Object
- func TimeDurationMinutesFunc(d int64) Object
- func TimeDurationNanosecondsFunc(d int64) Object
- func TimeDurationRoundFunc(d, m int64) Object
- func TimeDurationSecondsFunc(d int64) Object
- func TimeDurationStringFunc(d int64) Object
- func TimeDurationTruncateFunc(d, m int64) Object
- func TimeEqual(t1, t2 *Time) Object
- func TimeFixedZoneFunc(name string, sec int) Object
- func TimeFormat(t *Time, layout string) Object
- func TimeIn(t *Time, loc *Location) Object
- func TimeIsLocationFunc(o Object) Object
- func TimeIsTimeFunc(o Object) Object
- func TimeLoadLocationFunc(name string) (Object, error)
- func TimeLocalFunc() Object
- func TimeMonthStringFunc(m int) Object
- func TimeNewArgTypeErr(pos, want, got string) (Object, error)
- func TimeNowFunc() Object
- func TimeParseDurationFunc(s string) (Object, error)
- func TimeParseFunc(c Call) (Object, error)
- func TimeRound(t *Time, duration int64) Object
- func TimeSinceFunc(t *Time) Object
- func TimeSleepFunc(c Call) (Object, error)
- func TimeSub(t1, t2 *Time) Object
- func TimeTruncate(t *Time, duration int64) Object
- func TimeUnixFunc(c Call) (Object, error)
- func TimeUntilFunc(t *Time) Object
- func TimeUtcFunc() Object
- func TimeWeekdayStringFunc(w int) Object
- func TimeZerotimeFunc() Object
- 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
- func (oc *ObjectConverters) Register(objType ObjectType, togo func(vm *VM, v Object) any, goType reflect.Type, ...) *ObjectConverters
- func (oc *ObjectConverters) RegisterToGo(objType ObjectType, togo func(vm *VM, v Object) any) *ObjectConverters
- func (oc *ObjectConverters) RegisterToObject(goType reflect.Type, toObject func(vm *VM, v any) (Object, error)) *ObjectConverters
- func (oc *ObjectConverters) ToInterface(vm *VM, v Object) any
- func (oc *ObjectConverters) ToObject(vm *VM, v any) (Object, error)
- type ObjectEnter
- type ObjectExit
- type ObjectImpl
- type ObjectIterator
- type ObjectPtr
- func (o *ObjectPtr) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpAnd(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpAndNot(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpLess(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpMul(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpOr(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpPow(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpRem(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpShl(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpShr(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpSub(vm *VM, right Object) (Object, error)
- func (o *ObjectPtr) BinOpXor(vm *VM, 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 ObjectToWriter
- type ObjectToWriterFunc
- type ObjectToWriters
- type ObjectType
- type ObjectTypeArray
- func (t ObjectTypeArray) Array() Array
- func (t ObjectTypeArray) Assign(ot ObjectType) (ok bool)
- func (t ObjectTypeArray) Equal(right Object) bool
- func (t ObjectTypeArray) Get(i int) ObjectType
- func (t ObjectTypeArray) HasVar() (ok bool)
- func (t ObjectTypeArray) IsFalsy() bool
- func (t ObjectTypeArray) IsZero() bool
- func (t ObjectTypeArray) Items() ObjectTypeArray
- func (t ObjectTypeArray) Keys() (keys ObjectTypeKeys)
- func (t ObjectTypeArray) Last() ObjectType
- func (t ObjectTypeArray) Len() int
- func (t ObjectTypeArray) Print(state *PrinterState) error
- func (t ObjectTypeArray) String() string
- func (t ObjectTypeArray) ToString() string
- func (t ObjectTypeArray) Type() ObjectType
- func (t ObjectTypeArray) Var() (_ ObjectType)
- func (t ObjectTypeArray) VarSplit() (nonVar ObjectTypeArray, varType ObjectType)
- type ObjectTypeAssignersGetter
- type ObjectTypeKey
- type ObjectTypeKeys
- type ObjectTypeNode
- type ObjectTypes
- func (t ObjectTypes) Get(i int) ObjectType
- func (t ObjectTypes) HasVar() (ok bool)
- func (t ObjectTypes) IsZero() bool
- func (t ObjectTypes) Items() ObjectTypes
- func (t ObjectTypes) Last() ObjectType
- func (t ObjectTypes) Len() int
- func (t ObjectTypes) Multi() (m ParamsTypes)
- func (t ObjectTypes) String() string
- func (t ObjectTypes) Var() (_ ObjectType)
- func (t ObjectTypes) VarSplit() (nonVar ObjectTypes, varType ObjectType)
- type ObjectWithAddBinOperator
- type ObjectWithAddSelfAssignOperator
- type ObjectWithAddUnaryOperator
- type ObjectWithAinBinOperator
- type ObjectWithAndBinOperator
- type ObjectWithAndNotBinOperator
- type ObjectWithAndNotSelfAssignOperator
- type ObjectWithAndSelfAssignOperator
- type ObjectWithDecBinOperator
- type ObjectWithDecSelfAssignOperator
- type ObjectWithDecUnaryOperator
- type ObjectWithDotDotBinOperator
- type ObjectWithDoubleModBinOperator
- type ObjectWithDoubleModSelfAssignOperator
- type ObjectWithDoubleTildeBinOperator
- type ObjectWithEqualBinOperator
- type ObjectWithGreaterBinOperator
- type ObjectWithGreaterEqBinOperator
- type ObjectWithInBinOperator
- type ObjectWithIncBinOperator
- type ObjectWithIncSelfAssignOperator
- type ObjectWithIncUnaryOperator
- type ObjectWithLAndBinOperator
- type ObjectWithLOrSelfAssignOperator
- type ObjectWithLambdaBinOperator
- type ObjectWithLessBinOperator
- type ObjectWithLessEqBinOperator
- type ObjectWithMulBinOperator
- type ObjectWithMulSelfAssignOperator
- type ObjectWithNotEqualBinOperator
- type ObjectWithNotSameBinOperator
- type ObjectWithNotUnaryOperator
- type ObjectWithOrBinOperator
- type ObjectWithOrSelfAssignOperator
- type ObjectWithPowBinOperator
- type ObjectWithPowSelfAssignOperator
- type ObjectWithQuoBinOperator
- type ObjectWithQuoSelfAssignOperator
- type ObjectWithRemBinOperator
- type ObjectWithRemSelfAssignOperator
- type ObjectWithSameBinOperator
- type ObjectWithShlBinOperator
- type ObjectWithShlSelfAssignOperator
- type ObjectWithShrBinOperator
- type ObjectWithShrSelfAssignOperator
- type ObjectWithSubBinOperator
- type ObjectWithSubSelfAssignOperator
- type ObjectWithSubUnaryOperator
- type ObjectWithTildeBinOperator
- type ObjectWithTripleGreaterBinOperator
- type ObjectWithTripleGreaterSelfAssignOperator
- type ObjectWithTripleLessBinOperator
- type ObjectWithTripleLessSelfAssignOperator
- type ObjectWithTripleTildeBinOperator
- type ObjectWithXorBinOperator
- type ObjectWithXorSelfAssignOperator
- type ObjectWithXorUnaryOperator
- type Objector
- type OpCallFlag
- type Opcode
- type OptimizerError
- type Param
- type ParamBuilder
- type ParamOption
- type ParamType
- type ParamTypes
- type Params
- func (p *Params) BuildTypes() (t ParamsTypes)
- func (p *Params) ByName() map[string]int
- func (p *Params) Empty() bool
- func (p *Params) Len() int
- func (p *Params) Names() (names []string)
- func (p *Params) PosLen() int
- func (p Params) RequiredCount() (n int)
- func (p *Params) String() string
- func (p *Params) ToMap() (np map[string]*Param)
- func (p *Params) Typed() bool
- func (p *Params) Var() bool
- func (p *Params) Variadic() bool
- type ParamsTypes
- type PipedInvokeIterator
- func (i *PipedInvokeIterator) Call(state *IteratorState) (err error)
- func (i *PipedInvokeIterator) Handler() func(state *IteratorState) error
- func (i *PipedInvokeIterator) Input() Object
- func (i *PipedInvokeIterator) Next(vm *VM, state *IteratorState) (err error)
- func (i *PipedInvokeIterator) PostCall() func(state *IteratorState, ret Object) error
- func (i *PipedInvokeIterator) PreCall() func(k, v Object) (Object, error)
- func (i *PipedInvokeIterator) Print(state *PrinterState) error
- func (i *PipedInvokeIterator) SetHandler(handler func(state *IteratorState) error) *PipedInvokeIterator
- func (i *PipedInvokeIterator) SetPostCall(postCall func(state *IteratorState, ret Object) error) *PipedInvokeIterator
- func (i *PipedInvokeIterator) SetPreCall(preCall func(k, v Object) (Object, error)) *PipedInvokeIterator
- func (i *PipedInvokeIterator) SetType(typ ObjectType) *PipedInvokeIterator
- func (i *PipedInvokeIterator) Start(vm *VM) (state *IteratorState, err error)
- func (i *PipedInvokeIterator) Type() ObjectType
- type PrintBuilder
- func (b *PrintBuilder) MustString(o ...Object) string
- func (b *PrintBuilder) Options(f func(opts PrinterStateOptions)) *PrintBuilder
- func (b *PrintBuilder) Print(w io.Writer, o ...Object) (err error)
- func (b *PrintBuilder) State(f func(s *PrinterState)) *PrintBuilder
- func (b *PrintBuilder) String(o ...Object) (_ string, err error)
- type PrintStateDictEntries
- type PrintStateDictEntry
- type PrintStateOptionSortType
- type Printabler
- type PrinterState
- func (s *PrinterState) BytesWritten() int64
- func (s *PrinterState) Context() context.Context
- func (s PrinterState) Copy() *PrinterState
- func (s *PrinterState) Do(f func(s *PrinterState)) *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) GoWriter() io.Writer
- 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) OnVisite(f func(old func(o Object) (done func())) func(o Object) (done func()))
- 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() PrinterStateOptions
- func (s *PrinterState) ParseOptions(na *NamedArgs) *PrinterState
- func (s *PrinterState) Print(o Object) (err error)
- func (s *PrinterState) PrintArray(l int, get func(i int) (Object, error)) (err error)
- func (s *PrinterState) PrintDict(l int, key, value func(i int) (Object, error)) (err error)
- func (s *PrinterState) PrintDictEntries(entries PrintStateDictEntries) (err error)
- func (s *PrinterState) PrintFromArgs(sep []byte, args Args) (err error)
- func (s *PrinterState) PrintIndent()
- func (s *PrinterState) PrintKey(o Object) (err error)
- func (s *PrinterState) PrintKeySafe(safe bool, o Object) (err error)
- func (s *PrinterState) PrintLine()
- func (s *PrinterState) PrintLineIndent()
- func (s *PrinterState) PrintMany(sep []byte, o ...Object) (err error)
- func (s *PrinterState) PrintPairs(l int, safeKey bool, open, close, keySep, itemSep []byte, ...) (err error)
- func (s *PrinterState) PrintValues(l int, open, close, itemSep []byte, get func(i int) (Object, error)) (err error)
- func (s *PrinterState) QuoteNextStr(level int64)
- func (s *PrinterState) Repr(o Object) error
- func (s *PrinterState) SkipDepth() bool
- func (s *PrinterState) SkipNexDepth() bool
- func (s *PrinterState) Stack() *PrinterStateStack
- func (s *PrinterState) ToString() string
- func (s *PrinterState) Type() ObjectType
- func (s *PrinterState) Update() *PrinterState
- 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) WithRepr(cb func(s *PrinterState) error) error
- func (s *PrinterState) WithValue(key, value any) *PrinterState
- func (s *PrinterState) WithValueBackup(key, value any) (restore func())
- func (s *PrinterState) WithoutRepr(cb func(s *PrinterState) error) error
- func (s *PrinterState) WrapIndentedReprString(str string) func()
- func (s *PrinterState) WrapRepr(o Object) func()
- func (s *PrinterState) WrapReprString(str string) func()
- func (s *PrinterState) Write(b []byte) (n int, err error)
- func (s *PrinterState) WriteByte(c byte) (err error)
- func (s *PrinterState) WriteString(b string) (err error)
- type PrinterStateOption
- type PrinterStateOptions
- func (o PrinterStateOptions) Anonymous() (v bool, ok bool)
- func (o PrinterStateOptions) Backup(key string) (restore func())
- func (o PrinterStateOptions) BytesToHex() (v bool, ok bool)
- func (o PrinterStateOptions) DefaultIndent()
- func (o PrinterStateOptions) Dict() Dict
- func (o PrinterStateOptions) Indent() (v string, ok bool)
- func (o PrinterStateOptions) Indexes() (v bool, ok bool)
- func (o PrinterStateOptions) IsAnonymous() (v bool)
- func (o PrinterStateOptions) IsBytesToHex() (is bool)
- func (o PrinterStateOptions) IsIndexes() (v bool)
- func (o PrinterStateOptions) IsQuoteStr() (is bool)
- func (o PrinterStateOptions) IsSortKeys() (v PrintStateOptionSortType)
- func (o PrinterStateOptions) IsTypesAsFullNames() (v bool)
- func (o PrinterStateOptions) IsZeros() (v bool)
- func (o PrinterStateOptions) MaxDepth() (v int64, ok bool)
- func (o PrinterStateOptions) QuoteStr() (v bool, ok bool)
- func (o PrinterStateOptions) Raw() (v bool, ok bool)
- func (o PrinterStateOptions) Repr() (v bool, ok bool)
- func (o PrinterStateOptions) SetAnonymous(v bool)
- func (o PrinterStateOptions) SetBytesToHex(v bool)
- func (o PrinterStateOptions) SetIndent(v Object)
- func (o PrinterStateOptions) SetIndexes(v bool)
- func (o PrinterStateOptions) SetMaxDepth(v int64)
- func (o PrinterStateOptions) SetQuoteStr(v bool)
- func (o PrinterStateOptions) SetRaw(v bool)
- func (o PrinterStateOptions) SetRepr(v bool)
- func (o PrinterStateOptions) SetSortKeys(v PrintStateOptionSortType)
- func (o PrinterStateOptions) SetTrimEmbedPath(v Array)
- func (o PrinterStateOptions) SetTypesAsFullNames(v bool)
- func (o PrinterStateOptions) SetZeros(v bool)
- func (o PrinterStateOptions) SortKeys() (v PrintStateOptionSortType, ok bool)
- func (o PrinterStateOptions) TrimEmbedPath() (v Array, ok bool)
- func (o PrinterStateOptions) TypesAsFullNames() (v bool, ok bool)
- func (o PrinterStateOptions) WithAnonymous() PrinterStateOptions
- func (o PrinterStateOptions) WithBackup(key string, value Object) (restore func())
- func (o PrinterStateOptions) WithBytesToHex()
- func (o PrinterStateOptions) WithIndent() PrinterStateOptions
- func (o PrinterStateOptions) WithIndexes() PrinterStateOptions
- func (o PrinterStateOptions) WithMaxDepth(v int64) PrinterStateOptions
- func (o PrinterStateOptions) WithQuoteStr()
- func (o PrinterStateOptions) WithRaw()
- func (o PrinterStateOptions) WithRepr() PrinterStateOptions
- func (o PrinterStateOptions) WithTrimEmbedPath(v Array) PrinterStateOptions
- func (o PrinterStateOptions) WithTypesAsFullNames() PrinterStateOptions
- func (o PrinterStateOptions) WithZeros() PrinterStateOptions
- func (o PrinterStateOptions) Zeros() (v bool, ok bool)
- type PrinterStateStack
- type Prop
- func (p *Prop) Add(handler CallerObject, argTypes ParamsTypes) (err error)
- func (p *Prop) AddGetter(v Object, onAdd func(method *TypedCallerMethod) error) (err error)
- func (p *Prop) AddMethodByTypes(_ *VM, argTypes ParamsTypes, handler CallerObject, override bool, ...) error
- func (p *Prop) AddSetter(v Object, valueType ParamTypes, override bool, ...) (err error)
- func (p *Prop) Call(c Call) (Object, error)
- func (p Prop) Clone() *Prop
- func (p *Prop) Equal(right Object) bool
- func (p *Prop) FullName() string
- func (p *Prop) FuncSpecName() string
- func (p *Prop) GetModule() *ModuleSpec
- func (p *Prop) IsFalsy() bool
- func (p *Prop) Name() string
- func (p *Prop) Print(state *PrinterState) (err error)
- func (p *Prop) SetModule(m *ModuleSpec)
- func (p *Prop) String() string
- func (p *Prop) ToString() string
- func (p *Prop) Type() ObjectType
- func (p *Prop) VMAdd(vm *VM, v Object) error
- type Range
- func (o *Range) BinOpQuo(_ *VM, right Object) (Object, error)
- func (o *Range) Equal(right Object) bool
- func (o *Range) IndexGet(_ *VM, index Object) (Object, error)
- func (o *Range) IsFalsy() bool
- func (o *Range) Iterate(_ *VM, _ *NamedArgs) Iterator
- func (o *Range) ToString() string
- func (o *Range) Type() ObjectType
- 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) Print(state *PrinterState) error
- func (it *RangeIteration) SetReversed(v bool) *RangeIteration
- func (it *RangeIteration) Start(*VM) (state *IteratorState, err error)
- func (it *RangeIteration) Type() ObjectType
- type RawCallerWithMethods
- type RawStr
- func (o RawStr) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o RawStr) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o RawStr) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o RawStr) BinOpIn(_ *VM, v Object) (Object, error)
- func (o RawStr) BinOpLess(_ *VM, right Object) (Object, error)
- func (o RawStr) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o RawStr) BinOpSame(_ *VM, 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) 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) 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) ToString() string
- type ReflectField
- type ReflectFunc
- type ReflectMap
- func (o *ReflectMap) Copy() (obj Object)
- 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(state *PrinterState) (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) Insert(vm *VM, at int, items ...Object) (_ Object, err error)
- func (o *ReflectSlice) Print(state *PrinterState) (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) Name() string
- func (s *ReflectStruct) Print(state *PrinterState) (err error)
- func (s *ReflectStruct) Reader() Reader
- func (s *ReflectStruct) ReprTypeName() string
- 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 (t *ReflectType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (t *ReflectType) Call(c Call) (_ Object, err error)
- func (t *ReflectType) CanAssign(obj Object) (bool, error)
- func (t *ReflectType) Equal(right Object) bool
- func (t *ReflectType) Fields() (fields Dict)
- func (t *ReflectType) Fqn() string
- func (t *ReflectType) FullName() string
- func (t *ReflectType) FuncSpecName() string
- func (ReflectType) GadObjectType()
- func (t *ReflectType) GetRMethods() map[string]*ReflectMethod
- func (t *ReflectType) Name() string
- func (t *ReflectType) New(vm *VM, m Dict) (_ Object, err error)
- func (t *ReflectType) NewDefault(c Call) (Object, error)
- func (t *ReflectType) Print(state *PrinterState) (err error)
- func (t *ReflectType) StaticMethod(name string, co CallerObject)
- func (t *ReflectType) String() string
- func (t *ReflectType) ToString() string
- func (t *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) ToInterface() any
- func (r *ReflectValue) ToString() string
- func (r *ReflectValue) Type() ObjectType
- func (r *ReflectValue) Value() reflect.Value
- type ReflectValueOptions
- type ReflectValuePrinter
- type ReflectValuer
- type Regexp
- func (o *Regexp) BinOpDoubleTilde(_ *VM, right Object) (Object, error)
- func (o *Regexp) BinOpOr(_ *VM, right Object) (Object, error)
- func (o *Regexp) BinOpTilde(_ *VM, right Object) (Object, error)
- func (o *Regexp) BinOpTripleTilde(_ *VM, right Object) (Object, 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) Print(state *PrinterState) error
- func (o *Regexp) Replace(vm *VM, subject, repl Object) (Object, error)
- func (o *Regexp) ToInterface() any
- func (o *Regexp) ToString() string
- func (o *Regexp) Type() ObjectType
- type RegexpBytesResult
- func (o RegexpBytesResult) Equal(right Object) bool
- func (o RegexpBytesResult) IndexGet(_ *VM, index Object) (Object, error)
- func (o RegexpBytesResult) IsFalsy() bool
- func (o RegexpBytesResult) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o RegexpBytesResult) Length() int
- func (o RegexpBytesResult) Print(state *PrinterState) error
- func (o RegexpBytesResult) ToArray() Array
- func (o RegexpBytesResult) ToString() string
- func (o RegexpBytesResult) Type() ObjectType
- type RegexpBytesSliceResult
- func (o RegexpBytesSliceResult) Equal(right Object) bool
- func (o RegexpBytesSliceResult) IndexGet(_ *VM, index Object) (Object, error)
- func (o RegexpBytesSliceResult) IsFalsy() bool
- func (o RegexpBytesSliceResult) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o RegexpBytesSliceResult) Length() int
- func (o RegexpBytesSliceResult) Print(state *PrinterState) error
- func (o RegexpBytesSliceResult) ToArray() Array
- func (o RegexpBytesSliceResult) ToString() string
- func (o RegexpBytesSliceResult) Type() ObjectType
- type RegexpStrsResult
- func (o RegexpStrsResult) Equal(right Object) bool
- func (o RegexpStrsResult) IndexGet(_ *VM, index Object) (Object, error)
- func (o RegexpStrsResult) IsFalsy() bool
- func (o RegexpStrsResult) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o RegexpStrsResult) Length() int
- func (o RegexpStrsResult) Print(state *PrinterState) error
- func (o RegexpStrsResult) ToArray() Array
- func (o RegexpStrsResult) ToString() string
- func (o RegexpStrsResult) Type() ObjectType
- type RegexpStrsSliceResult
- func (o RegexpStrsSliceResult) Equal(right Object) bool
- func (o RegexpStrsSliceResult) IndexGet(_ *VM, index Object) (Object, error)
- func (o RegexpStrsSliceResult) IsFalsy() bool
- func (o RegexpStrsSliceResult) Iterate(_ *VM, na *NamedArgs) Iterator
- func (o RegexpStrsSliceResult) Length() int
- func (o RegexpStrsSliceResult) Print(state *PrinterState) error
- func (o RegexpStrsSliceResult) ToArray() Array
- func (o RegexpStrsSliceResult) ToString() string
- func (o RegexpStrsSliceResult) Type() ObjectType
- type ReprTypeNamer
- type ReturnVar
- type ReturnVars
- 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 SelfAssignOperatorType
- func (b SelfAssignOperatorType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (SelfAssignOperatorType) Call(Call) (Object, error)
- func (b SelfAssignOperatorType) CanAssign(obj Object) (bool, error)
- func (b SelfAssignOperatorType) Equal(right Object) bool
- func (SelfAssignOperatorType) Fields() Dict
- func (b SelfAssignOperatorType) FullName() string
- func (b SelfAssignOperatorType) GadObjectType()
- func (SelfAssignOperatorType) Getters() Dict
- func (b SelfAssignOperatorType) IsFalsy() bool
- func (SelfAssignOperatorType) Methods() Dict
- func (SelfAssignOperatorType) MethodsDisabled() bool
- func (b SelfAssignOperatorType) Name() string
- 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) Start(vm *VM) (state *IteratorState, err error)
- func (s *StateIteratorObject) ToString() string
- func (s *StateIteratorObject) Type() ObjectType
- func (s *StateIteratorObject) Value() Object
- type StaticBuiltins
- func (b *StaticBuiltins) ArgsInvoker(t BuiltinType, c Call) func(arg ...Object) (Object, error)
- func (b *StaticBuiltins) Builtins() *Builtins
- func (b *StaticBuiltins) Call(t BuiltinType, c Call) (Object, error)
- func (b *StaticBuiltins) Caller(t BuiltinType) CallerObject
- func (b *StaticBuiltins) Get(t BuiltinType) Object
- func (b *StaticBuiltins) Invoker(t BuiltinType, c Call) func() (Object, error)
- func (b *StaticBuiltins) OpMethoded(bt BuiltinType) callerMethoded
- func (b *StaticBuiltins) Set(name string, obj Object) BuiltinType
- func (b *StaticBuiltins) Update(key BuiltinType, value Object)
- type StaticTypeKey
- type StaticTypes
- type Str
- func (o Str) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o Str) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o Str) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o Str) BinOpIn(_ *VM, v Object) (Object, error)
- func (o Str) BinOpLess(_ *VM, right Object) (Object, error)
- func (o Str) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o Str) BinOpSame(_ *VM, 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) Print(state *PrinterState) error
- func (o Str) Quoted() string
- func (o Str) ToString() string
- func (o Str) Type() ObjectType
- type StringIndexSetter
- type Symbol
- type SymbolInfo
- type SymbolScope
- type SymbolTable
- func (st *SymbolTable) Builtins() BuiltinsNameSet
- 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) DefineParams(positional *Params, named *NamedParams) (err error)
- 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) LocalNames() map[int]string
- 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) ShadowedBuiltins() []string
- func (st *SymbolTable) Symbols() []*Symbol
- type SyncDict
- func (o *SyncDict) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o *SyncDict) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o *SyncDict) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o *SyncDict) BinOpIn(vm *VM, v Object) (Object, error)
- func (o *SyncDict) BinOpLess(vm *VM, right Object) (Object, error)
- func (o *SyncDict) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o *SyncDict) BinOpSub(vm *VM, 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 TestBytecodesEqualOptions
- type Time
- func (o *Time) BinOpAdd(_ *VM, right Object) (Object, error)
- func (o *Time) BinOpGreater(_ *VM, right Object) (Object, error)
- func (o *Time) BinOpGreaterEq(_ *VM, right Object) (Object, error)
- func (o *Time) BinOpLess(_ *VM, right Object) (Object, error)
- func (o *Time) BinOpLessEq(_ *VM, right Object) (Object, error)
- func (o *Time) BinOpSub(_ *VM, right Object) (Object, error)
- func (o *Time) CallName(name string, c Call) (Object, error)
- func (o *Time) Equal(right Object) bool
- func (o *Time) IndexGet(_ *VM, index Object) (Object, error)
- func (o *Time) IsFalsy() bool
- func (o *Time) MarshalBinary() ([]byte, error)
- func (o *Time) MarshalJSON() ([]byte, error)
- func (o *Time) Print(s *PrinterState) error
- func (o *Time) ToString() string
- func (*Time) Type() ObjectType
- func (o *Time) UnOpDec(*VM) (Object, error)
- func (o *Time) UnOpInc(*VM) (Object, error)
- func (o *Time) UnmarshalBinary(data []byte) error
- func (o *Time) UnmarshalJSON(data []byte) error
- type ToArrayAppenderObject
- type ToArrayConveter
- type ToDictConverter
- type ToIterfaceConverter
- type ToIterfaceVMConverter
- type ToReaderConverter
- type ToWriter
- type ToWriterConverter
- type Type
- func (t *Type) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (t *Type) Caller() CallerObject
- func (t *Type) CanAssign(obj Object) (bool, error)
- func (t *Type) Constructor() CallerObject
- func (t Type) Copy() Object
- func (t *Type) Equal(right Object) bool
- func (Type) Fields() Dict
- func (t Type) FullName() string
- func (t *Type) FuncSpecName() string
- func (Type) GadObjectType()
- func (t *Type) GetModule() *ModuleSpec
- func (Type) Getters() Dict
- 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) IsFalsy() bool
- func (Type) Methods() Dict
- func (t Type) Name() string
- func (Type) New(*VM, Dict) (Object, error)
- func (t *Type) Print(state *PrinterState) (err 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) WithStatic(d Dict) *Type
- type TypeAssertion
- func (a *TypeAssertion) Accept(value Object) (expectedNames string)
- func (a *TypeAssertion) AcceptHandler(name string, handler TypeAssertionHandler) *TypeAssertion
- func (a *TypeAssertion) AcceptType(value ObjectType) (expectedNames string)
- func (a *TypeAssertion) Options(opt ...TypeAsssertionOption) *TypeAssertion
- type TypeAssertionHandler
- type TypeAssertionHandlers
- type TypeAssigner
- type TypeAssignerArray
- type TypeAsssertionOption
- func WithArray() TypeAsssertionOption
- func WithCallable() TypeAsssertionOption
- func WithFlag() TypeAsssertionOption
- func WithIsAssignable(types ...ObjectType) TypeAsssertionOption
- func WithMethodAdder() TypeAsssertionOption
- func WithMethodCaller() TypeAsssertionOption
- func WithRawCallable() TypeAsssertionOption
- type TypedCallerMethod
- func (o *TypedCallerMethod) IndexGet(vm *VM, index Object) (value Object, err error)
- func (o *TypedCallerMethod) IsVar() bool
- func (o *TypedCallerMethod) Print(state *PrinterState) error
- func (o *TypedCallerMethod) String() string
- func (o *TypedCallerMethod) StringTarget(target bool) string
- func (o *TypedCallerMethod) ToString() string
- func (o *TypedCallerMethod) Types() ObjectTypeArray
- type TypedCallerMethods
- type TypedCallerObjectWithParamTypes
- type TypedIdent
- func (t *TypedIdent) Equal(right Object) bool
- func (t *TypedIdent) IndexGet(vm *VM, index Object) (value Object, err error)
- func (t *TypedIdent) IndexSet(_ *VM, index, value Object) (err error)
- func (t *TypedIdent) IsFalsy() bool
- func (t *TypedIdent) Print(state *PrinterState) error
- func (t *TypedIdent) ToString() string
- func (t *TypedIdent) Type() ObjectType
- type Uint
- func (o Uint) BinOpAdd(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpAnd(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpAndNot(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpGreater(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpGreaterEq(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpLess(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpLessEq(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpMul(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpOr(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpPow(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpQuo(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpRem(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpSame(_ *VM, right Object) (Object, error)
- func (o Uint) BinOpShl(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpShr(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpSub(vm *VM, right Object) (Object, error)
- func (o Uint) BinOpXor(vm *VM, right Object) (Object, error)
- func (o Uint) Equal(right Object) bool
- func (o Uint) Format(s fmt.State, verb rune)
- func (o Uint) IsFalsy() bool
- func (o Uint) ToString() string
- func (o Uint) Type() ObjectType
- func (o Uint) UnOpAdd(*VM) (Object, error)
- func (o Uint) UnOpDec(*VM) (Object, error)
- func (o Uint) UnOpInc(*VM) (Object, error)
- func (o Uint) UnOpSub(*VM) (Object, error)
- func (o Uint) UnOpXor(*VM) (Object, error)
- type UnaryOperatorType
- func (b UnaryOperatorType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
- func (UnaryOperatorType) Call(Call) (Object, error)
- func (b UnaryOperatorType) CanAssign(obj Object) (bool, error)
- func (b UnaryOperatorType) Equal(right Object) bool
- func (UnaryOperatorType) Fields() Dict
- func (b UnaryOperatorType) FullName() string
- func (b UnaryOperatorType) GadObjectType()
- func (UnaryOperatorType) Getters() Dict
- func (b UnaryOperatorType) IsFalsy() bool
- func (UnaryOperatorType) Methods() Dict
- func (UnaryOperatorType) MethodsDisabled() bool
- func (b UnaryOperatorType) Name() string
- func (UnaryOperatorType) Setters() Dict
- func (b UnaryOperatorType) String() string
- func (b UnaryOperatorType) ToString() string
- func (b UnaryOperatorType) Token() token.Token
- func (b UnaryOperatorType) Type() ObjectType
- type UpDownLines
- type UserDataStorage
- type VM
- func (vm *VM) Abort()
- func (vm *VM) Aborted() bool
- func (vm *VM) AddCallerMethod(co CallerObject, types ParamsTypes, caller CallerObject, ...) (err error)
- func (vm *VM) AddCallerMethodOverride(co CallerObject, types ParamsTypes, override bool, caller CallerObject, ...) (err error)
- func (vm *VM) CallBuiltin(t BuiltinType, namedArgs *NamedArgs, args ...Object) (Object, error)
- func (vm *VM) Clear() *VM
- func (vm *VM) CurrentModule() *Module
- func (vm *VM) CurrentModuleSpec() *ModuleSpec
- func (vm *VM) DebugAbort()
- func (vm *VM) DebugFrames() []DebugFrame
- func (vm *VM) DebugIP() int
- func (vm *VM) DebugLocalNames() []string
- func (vm *VM) DebugLocals() []Object
- func (vm *VM) DebugOpcode() Opcode
- func (vm *VM) DebugSourcePos() source.FilePos
- func (vm *VM) Debugger() DebugStepper
- func (vm *VM) Fork(cf *CompiledFunction, usePool bool) (child *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) ModuleByIndex(ix int) *Module
- func (vm *VM) ModuleFromIndex(index int) *Module
- func (vm *VM) Read(b []byte) (int, error)
- func (vm *VM) ResolveType(ot ObjectType) ObjectType
- 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) SetDebugger(d DebugStepper)
- 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 VarObjectType
- type VarParamTypes
- type Writer
Examples ¶
Constants ¶
const ( // AttrName is a special attribute injected into modules to identify // the modules by name. AttrName = "@name" // AttrFile is a special attribute injected into modules to identify // the module file path. AttrFile = "@file" // AttrParams is a special attribute injected into modules to identify // the module params. AttrParams = "@params" )
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" PrintStateOptionTrimEmbedPath = "trimEmbedPath" PrintStateOptionRaw = "raw" PrintStateOptionZeros = "zeros" PrintStateOptionAnonymous = "anonymous" PrintStateOptionSortKeys = "sortKeys" PrintStateOptionIndexes = "indexes" PrintStateOptionTypesAsFullNames = "typesAsFullNames" PrintStateOptionRepr = "repr" PrintStateOptionBytesToHex = "bytesToHex" PrintStateOptionQuoteStr = "quoteStr" )
const (
MainName = parser.MainName
)
const ObjectMethodsGetterFieldName = "__methods__"
const PrintLoop = repr.QuotePrefix + "↶" + repr.QuoteSufix
const TestRegistryPrefix = "__gadTest_"
TestRegistryPrefix marks the top-level const bindings that `test`/`bench` statements lower to. The `gad test` runner discovers them by this prefix. Each binds a `[kind, name, func(t){…}, doc]` array.
Variables ¶
var ( TAny = NewType("any") TModule = NewType("Module") TStaticModule = NewType("ModuleSpec") TSymbol = NewType("Symbol", TAny) TIterationStateFlag = NewType("IterationStateFlag", TAny) IterationStop = NewType("IterationStop", TIterationStateFlag) IterationSkip = NewType("IterationSkip", TIterationStateFlag) TBase = NewType("Base", TAny) TClass = NewType("Class", TBase) TClassConstructor = NewType("ClassConstructor", TBase) TClassInitiator = NewType("ClassInitiator", TBase) TClassProperty = NewType("ClassProperty", TBase) TClassMethod = NewType("ClassMethod", TBase) TClassField = NewType("ClassField", TBase) TClassInstanceMethod = NewType("ClassInstanceMethod", TBase) TClassInstancePropertyGetter = NewType("ClassInstancePropertyGetter", TBase) TClassInstancePropertySetter = NewType("ClassInstancePropertySetter", TBase) TEmbedded = NewType("Embedded", TBase) TEmbeddedFS = NewType("EmbeddedFS", TBase) TIterator = NewType("Iterator", TAny) TIterabler = NewType("Iterabler", TAny) TNilIterator = NewType("NilIterator", TIterator) TStateIterator = NewType("StateIterator", TIterator) TStrIterator = NewType("StrIterator", TIterator) TRawStrIterator = NewType("RawStrIterator", TIterator) TArrayIterator = NewType("ArrayIterator", TIterator) TDictIterator = NewType("DictIterator", TIterator) TBytesIterator = NewType("BytesIterator", TIterator) TKeyValueArrayIterator = NewType("KeyValueArrayIterator", TIterator) TKeyValueArraysIterator = NewType("KeyValueArraysIterator", TIterator) TArgsIterator = NewType("ArgsIterator", TIterator) TReflectArrayIterator = NewType("ReflectArrayIterator", TIterator) TReflectMapIterator = NewType("ReflectMapIterator", TIterator) TReflectStructIterator = NewType("ReflectStructIterator", TIterator) TKeysIterator = NewType("KeysIterator", TIterator) TValuesIterator = NewType("ValuesIterator", TIterator) TEnumerateIterator = NewType("EnumerateIterator", TIterator) TItemsIterator = NewType("ItemsIterator", TIterator) TCallbackIterator = NewType("CallbackIterator", TIterator) TEachIterator = NewType("EachIterator", TIterator) TMapIterator = NewType("MapIterator", TIterator) TFilterIterator = NewType("FilterIterator", TIterator) TZipIterator = NewType("ZipIterator", TIterator) TPipedInvokeIterator = NewType("PipedInvokeIterator", TIterator) TEmbeddedNodeEntriesIterator = NewType("EmbeddedNodeEntries", TIterator) TEnum = NewType("Enum", TIterator) )
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).BinOpAdd(vm, 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"} // ErrNotLengther is an error where an Object is not lengther. ErrNotLengther = &Error{Name: "NotLengther"} // 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"} // ErrCall is an error where call Object ErrCall = &Error{Name: "ErrCall"} // 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"} // ErrIncompatibleAssign is an error where incompatible assign. ErrIncompatibleAssign = &Error{Name: "ErrIncompatibleAssign"} // 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"} // ErrNoMethodFound is an error where no method found. ErrNoMethodFound = &Error{Name: "ErrNoMethodFound"} // ErrConstructorRecursiveCall is an error where call recursive constructor. ErrConstructorRecursiveCall = &Error{Name: "ErrConstructorRecursiveCall"} // ErrConstructorMethodFound is an error where no constructor method found. ErrConstructorMethodFound = &Error{Name: "ErrConstructorMethodFound"} // ErrType represents a type error. ErrType = &Error{Name: "TypeError"} // ErrArgument represents a argument error. ErrArgument = &Error{Name: "ArgumentError"} // ErrNotInitializable represents a not initializable type error. ErrNotInitializable = &Error{Name: "ErrNotInitializable"} // ErrNotWriteable represents a not writeable type error. ErrNotWriteable = &Error{Name: "ErrNotWriteable"} // ErrDefineClass represents an error for define class. ErrDefineClass = &Error{Name: "ErrDefineClass"} // ErrNewClassInstance represents an error for create new ClassInstance. ErrNewClassInstance = &Error{Name: "ErrNewClassInstance"} // ErrClassInstanceInitialized represents an error for initialized ClassInstance. ErrClassInstanceInitialized = &Error{Name: "ErrClassInstanceInitialized"} // ErrClassInstanceProperty represents an error of ClassInstance property. ErrClassInstanceProperty = &Error{Name: "ErrClassInstanceProperty"} // ErrClassPropertyChange represents an error on change ClassProperty. ErrClassPropertyChange = &Error{Name: "ErrClassPropertyChange"} // ErrClassPropertyRegister represents an error on change ClassProperty. ErrClassPropertyRegister = &Error{Name: "ErrClassPropertyRegister"} // ErrClassMethodRegister represents an error on register method. ErrClassMethodRegister = &Error{Name: "ErrClassMethodRegister"} // ErrEmbedded represents an embeddedNode errors ErrEmbedded = &Error{Name: "ErrEmbeddedNode"} // ErrProp represents an error of Prop. ErrProp = &Error{Name: "ErrProp"} )
var ( ReprQuote = repr.Quote ReprQuoteTyped = repr.QuoteTyped )
var ( TInterfaceField = NewBuiltinObjType("InterfaceField") TInterfaceProp = NewBuiltinObjType("InterfaceProp") TInterfaceMethod = NewBuiltinObjType("InterfaceMethod") )
Object types for the interface members. They are internal representations carried inside an Interface constant, not user-constructible.
var BuiltinObjects = BuiltinObjectsMap{ BuiltinMakeArray: &BuiltinFunction{ FuncName: ":makeArray", Value: funcPiOROe(BuiltinMakeArrayFunc), AcceptMethodsDisabled: true, }, BuiltinMakeArrayRest: &BuiltinFunction{ FuncName: ":makeArrayRest", Value: funcPiOROe(BuiltinMakeArrayRestFunc), AcceptMethodsDisabled: true, }, BuiltinBinaryOperator: &BuiltinFunction{ FuncName: "binOp", Value: BuiltinBinaryOperatorFunc, }, BuiltinSelfAssignOperator: &BuiltinFunction{ FuncName: "selfAssignOp", Value: BuiltinSelfAssignOperatorFunc, }, BuiltinUnaryOperator: &BuiltinFunction{ FuncName: "unOp", Value: BuiltinUnaryOperatorFunc, }, BuiltinEnter: &BuiltinFunction{ FuncName: "enter", Value: BuiltinEnterFunc, }, BuiltinExit: &BuiltinFunction{ FuncName: "exit", Value: BuiltinExitFunc, }, BuiltinCast: &BuiltinFunction{ FuncName: "cast", Value: BuiltinCastFunc, }, BuiltinChars: &BuiltinFunction{ FuncName: "chars", Value: funcPOROe(BuiltinCharsFunc), }, BuiltinAppend: &BuiltinFunction{ FuncName: "append", Value: BuiltinAppendFunc, }, BuiltinDelete: &BuiltinFunction{ FuncName: "delete", Value: BuiltinDeleteFunc, }, BuiltinCopy: &BuiltinFunction{ FuncName: "copy", Value: BuiltinCopyFunc, }, BuiltinDeepCopy: &BuiltinFunction{ FuncName: "dcopy", Value: BuiltinDeepCopyFunc, }, BuiltinRepeat: &BuiltinFunction{ FuncName: "repeat", Value: funcPOiROe(BuiltinRepeatFunc), }, BuiltinContains: &BuiltinFunction{ FuncName: "contains", Value: funcPOOROe(BuiltinContainsFunc), }, BuiltinLen: &BuiltinFunction{ FuncName: "len", Value: BuiltinLenFunc, Header: NewFunctionHeader(). WithParams(func(np func(name string) *ParamBuilder) { np("val").Usage("The value") }). WithNamedParams(func(np func(name string) *NamedParamBuilder) { np("check"). Type(TFlag). Usage("When Yes and value not implements LengthGetter interface return error ErrNotLengther, otherwise return 0.") }), }, BuiltinCap: &BuiltinFunction{ FuncName: "cap", Value: funcPORO(BuiltinCapFunc), }, BuiltinSort: &BuiltinFunction{ FuncName: "sort", Value: funcPpVM_OCo_less_ROe(BuiltinSortFunc), }, BuiltinSortReverse: &BuiltinFunction{ FuncName: "sortReverse", Value: funcPpVM_OCo_less_ROe(BuiltinSortReverseFunc), }, BuiltinTypeName: &BuiltinFunction{ FuncName: "typeName", Value: funcPORO(BuiltinTypeNameFunc), AcceptMethodsDisabled: true, }, BuiltinPrint: &BuiltinFunction{ FuncName: "print", Value: BuiltinPrintFunc, }, BuiltinPrintf: &BuiltinFunction{ FuncName: "printf", Value: BuiltinPrintfFunc, }, BuiltinPrintln: &BuiltinFunction{ FuncName: "println", Value: BuiltinPrintlnFunc, }, BuiltinSprintf: &BuiltinFunction{ FuncName: "sprintf", Value: BuiltinSprintfFunc, AcceptMethodsDisabled: true, }, BuiltinRepr: &BuiltinFunction{ FuncName: "repr", Value: BuiltinReprFunc, }, BuiltinNamedParamTypeCheck: &BuiltinFunction{ FuncName: "namedParamTypeCheck", Value: BuiltinNamedParamTypeCheckFunc, AcceptMethodsDisabled: true, }, BuiltinIs: &BuiltinFunction{ FuncName: "is", Value: BuiltinIsFunc, AcceptMethodsDisabled: true, Usage: ``, }, BuiltinIsError: &BuiltinFunction{ FuncName: "isError", Value: BuiltinIsErrorFunc, AcceptMethodsDisabled: true, }, BuiltinIsInt: &BuiltinFunction{ FuncName: "isInt", Value: funcPORO(BuiltinIsIntFunc), AcceptMethodsDisabled: true, }, BuiltinIsUint: &BuiltinFunction{ FuncName: "isUint", Value: funcPORO(BuiltinIsUintFunc), AcceptMethodsDisabled: true, }, BuiltinIsFloat: &BuiltinFunction{ FuncName: "isFloat", Value: funcPORO(BuiltinIsFloatFunc), AcceptMethodsDisabled: true, }, BuiltinIsChar: &BuiltinFunction{ FuncName: "isChar", Value: funcPORO(BuiltinIsCharFunc), AcceptMethodsDisabled: true, }, BuiltinIsBool: &BuiltinFunction{ FuncName: "isBool", Value: funcPORO(BuiltinIsBoolFunc), AcceptMethodsDisabled: true, }, BuiltinIsStr: &BuiltinFunction{ FuncName: "isStr", Value: funcPORO(BuiltinIsStrFunc), AcceptMethodsDisabled: true, }, BuiltinIsRawStr: &BuiltinFunction{ FuncName: "isRawStr", Value: funcPORO(BuiltinIsRawStrFunc), AcceptMethodsDisabled: true, }, BuiltinIsBytes: &BuiltinFunction{ FuncName: "isBytes", Value: funcPORO(BuiltinIsBytesFunc), AcceptMethodsDisabled: true, }, BuiltinIsDict: &BuiltinFunction{ FuncName: "isDict", Value: funcPORO(BuiltinIsDictFunc), AcceptMethodsDisabled: true, }, BuiltinIsSyncDict: &BuiltinFunction{ FuncName: "isSyncDict", Value: funcPORO(BuiltinIsSyncDictFunc), AcceptMethodsDisabled: true, }, BuiltinIsArray: &BuiltinFunction{ FuncName: "isArray", Value: funcPORO(BuiltinIsArrayFunc), AcceptMethodsDisabled: true, }, BuiltinIsNil: &BuiltinFunction{ FuncName: "isNil", Value: funcPORO(BuiltinIsNilFunc), AcceptMethodsDisabled: true, }, BuiltinIsFunction: &BuiltinFunction{ FuncName: "isFunction", Value: funcPORO(BuiltinIsFunctionFunc), AcceptMethodsDisabled: true, }, BuiltinIsCallable: &BuiltinFunction{ FuncName: "isCallable", Value: funcPORO(BuiltinIsCallableFunc), }, BuiltinIsIterable: &BuiltinFunction{ FuncName: "isIterable", Value: funcPpVM_ORO(BuiltinIsIterableFunc), }, BuiltinIsIterator: &BuiltinFunction{ FuncName: "isIterator", Value: funcPORO(BuiltinIsIteratorFunc), }, BuiltinImplements: &BuiltinFunction{ FuncName: "implements", Value: BuiltinImplementsFunc, }, BuiltinStdIO: &BuiltinFunction{ FuncName: "stdio", Value: BuiltinStdIOFunc, }, BuiltinWrap: &BuiltinFunction{ FuncName: "wrap", Value: BuiltinWrapFunc, }, BuiltinNewClass: &BuiltinFunction{ FuncName: "Class", Value: NewClassFunc, AcceptMethodsDisabled: true, }, BuiltinTypeOf: &BuiltinFunction{ FuncName: "typeof", Value: BuiltinTypeOfFunc, AcceptMethodsDisabled: true, }, BuiltinAddMethod: &BuiltinFunction{ FuncName: "addMethod", Value: BuiltinAddMethodFunc, AcceptMethodsDisabled: true, }, BuiltinMethodFromArgs: &BuiltinFunction{ FuncName: "methodFromArgs", Value: BuiltinMethodFromArgsFunc, AcceptMethodsDisabled: true, }, BuiltinRawCaller: &BuiltinFunction{ FuncName: "rawCaller", Value: BuiltinRawCallerFunc, AcceptMethodsDisabled: true, }, BuiltinVMPushWriter: &BuiltinFunction{ FuncName: "vmPushWriter", Value: BuiltinPushWriterFunc, AcceptMethodsDisabled: true, }, BuiltinVMPopWriter: &BuiltinFunction{ FuncName: "vmPopWriter", Value: BuiltinPopWriterFunc, }, BuiltinOBStart: &BuiltinFunction{ FuncName: "obstart", Value: BuiltinOBStartFunc, AcceptMethodsDisabled: true, }, BuiltinOBEnd: &BuiltinFunction{ FuncName: "obend", Value: BuiltinOBEndFunc, AcceptMethodsDisabled: true, }, BuiltinFlush: &BuiltinFunction{ FuncName: "flush", Value: BuiltinFlushFunc, }, BuiltinUserData: &BuiltinFunction{ FuncName: "userData", Value: BuiltinUserDataFunc, }, BuiltinClose: &BuiltinFunction{ FuncName: "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{ "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, "stdio": BuiltinStdIO, "wrap": BuiltinWrap, "Class": BuiltinNewClass, "typeof": BuiltinTypeOf, "addMethod": BuiltinAddMethod, "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, "implements": BuiltinImplements, "WrongNumArgumentsError": BuiltinWrongNumArgumentsError, "InvalidOperatorError": BuiltinInvalidOperatorError, "IndexOutOfBoundsError": BuiltinIndexOutOfBoundsError, "NotIterableError": BuiltinNotIterableError, "NotIndexableError": BuiltinNotIndexableError, "NotIndexAssignableError": BuiltinNotIndexAssignableError, "NotCallableError": BuiltinNotCallableError, "NotImplementedError": BuiltinNotImplementedError, "ZeroDivisionError": BuiltinZeroDivisionError, "TypeError": BuiltinTypeError, ":makeArray": BuiltinMakeArray, ":makeArrayRest": BuiltinMakeArrayRest, "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 CalendarDateType = NewBuiltinObjType("calendarDate").WithNew(NewCalendarDateFunc)
CalendarDateType is the object type of CalendarDate values (the gad `calendarDate` type). It is callable as a constructor: CalendarDate(uint|int) from a YYYYMMDD integer, or CalendarDate(str) parsing "YYYYMMDD"/"YYYY-MM-DD". See also strToDate.
var CalendarTimeType = NewBuiltinObjType("calendarTime").WithNew(NewCalendarTimeFunc)
CalendarTimeType is the object type of CalendarTime values (the gad `calendarTime` type). It is callable as a constructor: CalendarTime(uint|int) from a nanosecond count, or CalendarTime(str) parsing a zone-less timestamp. See also strToCalendarTime.
var DecimalZero = Decimal(decimal.Zero)
var DefaultStaticTypes = NewStaticTypes()
var DiscardWriter = NewWriter(io.Discard)
var DurationType = NewBuiltinObjType("duration").WithNew(NewDurationFunc)
DurationType is the object type of Duration values (the gad `duration` type). It is callable as a constructor: Duration(int) from a nanosecond count, or Duration(str) parsing a Go duration string ("1h30m"). See also strToDuration.
var EmptyNamedArgs = &NamedArgs{ro: true}
var MethodTable = map[string]func(*Time, *Call) (Object, error){ "Add": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } d, ok := ToGoInt64(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "int", c.Args.Get(0).Type().Name()) } return TimeAdd(o, d), nil }, "Sub": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } t2, ok := ToTime(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "time", c.Args.Get(0).Type().Name()) } return TimeSub(o, t2), nil }, "AddDate": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(3); err != nil { return Nil, err } year, ok := ToGoInt(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "int", c.Args.Get(0).Type().Name()) } month, ok := ToGoInt(c.Args.Get(1)) if !ok { return TimeNewArgTypeErr("2nd", "int", c.Args.Get(1).Type().Name()) } day, ok := ToGoInt(c.Args.Get(2)) if !ok { return TimeNewArgTypeErr("3rd", "int", c.Args.Get(2).Type().Name()) } return TimeAddDate(o, year, month, day), nil }, "After": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } t2, ok := ToTime(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "time", c.Args.Get(0).Type().Name()) } return TimeAfter(o, t2), nil }, "Before": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } t2, ok := ToTime(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "time", c.Args.Get(0).Type().Name()) } return TimeBefore(o, t2), nil }, "Format": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } format, ok := ToGoString(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "str", c.Args.Get(0).Type().Name()) } return TimeFormat(o, format), nil }, "AppendFormat": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(2); err != nil { return Nil, err } b, ok := ToGoByteSlice(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "bytes", c.Args.Get(0).Type().Name()) } format, ok := ToGoString(c.Args.Get(1)) if !ok { return TimeNewArgTypeErr("2nd", "str", c.Args.Get(1).Type().Name()) } return TimeAppendFormat(o, b, format), nil }, "In": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } loc, ok := ToLocation(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "Location", c.Args.Get(0).Type().Name()) } return TimeIn(o, loc), nil }, "Round": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } d, ok := ToGoInt64(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "int", c.Args.Get(0).Type().Name()) } return TimeRound(o, d), nil }, "Truncate": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } d, ok := ToGoInt64(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "int", c.Args.Get(0).Type().Name()) } return TimeTruncate(o, d), nil }, "trunc": func(o *Time, c *Call) (Object, error) { unit, err := truncateUnitArg(*c) if err != nil { return Nil, err } t, err := truncateTimeUnit(o.Value, unit) if err != nil { return Nil, err } return &Time{Value: t}, nil }, "round": func(o *Time, c *Call) (Object, error) { unit, err := truncateUnitArg(*c) if err != nil { return Nil, err } t, err := roundTimeUnit(o.Value, unit) if err != nil { return Nil, err } return &Time{Value: t}, nil }, "Equal": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(1); err != nil { return Nil, err } t2, ok := ToTime(c.Args.Get(0)) if !ok { return TimeNewArgTypeErr("1st", "time", c.Args.Get(0).Type().Name()) } return TimeEqual(o, t2), nil }, "Date": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } y, m, d := o.Value.Date() return Dict{"year": Int(y), "month": Int(m), "day": Int(d)}, nil }, "Clock": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } h, m, s := o.Value.Clock() return Dict{"hour": Int(h), "minute": Int(m), "second": Int(s)}, nil }, "UTC": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return &Time{Value: o.Value.UTC()}, nil }, "Unix": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Unix()), nil }, "UnixNano": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.UnixNano()), nil }, "Year": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Year()), nil }, "Month": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Month()), nil }, "Day": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Day()), nil }, "Hour": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Hour()), nil }, "Minute": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Minute()), nil }, "Second": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Second()), nil }, "Nanosecond": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Nanosecond()), nil }, "ns": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Nanosecond()), nil }, "IsZero": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Bool(o.Value.IsZero()), nil }, "Local": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return &Time{Value: o.Value.Local()}, nil }, "Location": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return &Location{Value: o.Value.Location()}, nil }, "YearDay": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.YearDay()), nil }, "Weekday": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } return Int(o.Value.Weekday()), nil }, "ISOWeek": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } y, w := o.Value.ISOWeek() return Dict{"year": Int(y), "week": Int(w)}, nil }, "Zone": func(o *Time, c *Call) (Object, error) { if err := c.Args.CheckLen(0); err != nil { return Nil, err } name, offset := o.Value.Zone() return Dict{"name": Str(name), "offset": Int(offset)}, nil }, }
var NaN = Float(math.NaN())
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", OpIsMain: "ISMAIN", OpNotIsMain: "NOTISMAIN", OpModule: "MODULE", OpGlobals: "GLOBALS", OpPop: "POP", OpGetFree: "GETFREE", OpSetFree: "SETFREE", OpGetLocalPtr: "GETLOCALPTR", OpGetFreePtr: "GETFREEPTR", OpClosure: "CLOSURE", OpIterInit: "ITERINIT", OpIterNext: "ITERNEXT", OpIterNextElse: "ITERNEXTELSE", OpIterKey: "ITERKEY", OpIterValue: "ITERVALUE", OpLoadModule: "LOADMODULE", OpInitModule: "INITMODULE", OpReturn: "RETURN", OpSetReturn: "SETRETURN", OpSetReturnModule: "SETRETURNMODULE", 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", OpNamedParamsVar: "NAMEDPARAMSVAR", OpNamedParamValue: "NPARAMVALUE", OpComputedValue: "COMPUTEDVALUE", OpAddMethod: "ADDMETHOD", OpExtendModule: "EXTENDMODULE", OpToRawStr: "TORAWSTR", OpAddMethodOverride: "ADDMETHODOVERRIDE", OpAssign: "ASSIGN", }
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: {}, OpIsMain: {}, OpNotIsMain: {}, OpModule: {}, OpGlobals: {}, OpPop: {}, OpGetFree: {1}, OpSetFree: {1}, OpGetLocalPtr: {1}, OpGetFreePtr: {1}, OpClosure: {2, 1}, OpIterInit: {}, OpIterNext: {}, OpIterNextElse: {2, 2}, OpIterKey: {}, OpIterValue: {}, OpLoadModule: {2}, OpInitModule: {1, 1}, OpSetReturn: {1}, OpSetReturnModule: {}, 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}, OpNamedParamsVar: {}, OpNamedParamValue: {}, OpComputedValue: {}, OpAddMethod: {1, 1}, OpExtendModule: {}, OpToRawStr: {}, OpAddMethodOverride: {1, 1}, OpAssign: {}, }
OpcodeOperands is the number of operands.
var RangeType = RegisterBuiltinType(BuiltinRange, "Range", (*Range)(nil), NewRangeFunc)
RangeType is the builtin `Range` object type. The `Range(from, to; step)` constructor and the `..` operator both produce *Range values.
var TFunctionHeader = RegisterBuiltinType(BuiltinFunctionHeader, "FunctionHeader", FuncHeaderObject{}, NewFunctionHeaderFunc)
TFunctionHeader is the builtin `FuncHeaderObject` object type.
var TInterface = RegisterBuiltinType(BuiltinInterface, "Interface", Interface{}, nil)
TInterface is the builtin `Interface` object type. It has no constructor.
var TMethodInterface = RegisterBuiltinType(BuiltinMethodInterface, "MethodInterface", MethodInterface{}, NewMethodInterfaceFunc)
TMethodInterface is the builtin `MethodInterface` object type.
var (
TOperator = NewType("Operator", TBase)
)
var TProp = RegisterBuiltinType(BuiltinProp, "Prop", Prop{}, NewPropFunc)
TProp is the builtin `Prop` object type.
var TimeLocationType = NewBuiltinObjType("Location").WithNew(NewLocationFunc)
var TimeModuleSpec = NewModuleSpecFromName("time")
TimeModuleSpec is the module spec shared by the builtin `time` namespace members and the importable time module.
var TimeType = NewBuiltinObjType("time").WithNew(NewTimeFunc)
var Types = map[reflect.Type]ObjectType{}
Functions ¶
func AddMethodT ¶ added in v0.0.2
func AddMethodT[T Object](target T, method ...TypedCallerObjectWithParamTypes) T
func ArrayToStringBraces ¶ added in v0.0.2
func CloserFrom ¶
func Filterable ¶
func FormatInstructions ¶
FormatInstructions returns string representation of bytecode instructions.
func FormatReturnVars ¶ added in v0.0.2
func FormatReturnVars(vars ReturnVars) string
func IsAssignableTo ¶ added in v0.0.2
func IsAssignableTo(typ, refType ObjectType) (ok bool)
func IsFunction ¶ added in v0.0.2
func IsIndexDeleter ¶
func IsIndexGetter ¶
func IsIndexSetter ¶
func IsIterator ¶
func IsObjector ¶
func IsPrimitive ¶
func IsTypeAssignableTo ¶
func IsTypeAssignableTo(a ObjectType, b TypeAssigner) 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 MethodInterfaceImplements ¶ added in v0.0.2
func MethodInterfaceImplements(vm *VM, value Object, ifaces ...*MethodInterface) (bool, error)
MethodInterfaceImplements reports whether value (a callable) structurally satisfies every header of the given method interface(s) — the same match used by the `implements` builtin. A non-callable value never implements.
func NamedParamTypeCheck ¶
func NamedParamTypeCheckAssertion ¶
func NamedParamTypeCheckAssertion(name string, assertion *TypeAssertion, value Object) (err error)
func NewArgCaller ¶
func ObjectsStrW ¶
func Print ¶
func Print(state *PrinterState, o ...Object) (err error)
func ReadOperands ¶
ReadOperands reads operands from the bytecode. Given operands slice is used to fill operands and is returned to allocate less.
func ReprTypeName ¶ added in v0.0.2
func SplitCaller ¶ added in v0.0.2
func SplitCaller(vm *VM, caller Object, cb func(co CallerObject, types ParamsTypes) error, fallback ...func(co CallerObject) error) (err error)
func TestBytecodesEqual ¶
func TestBytecodesEqual(t *testing.T, expected, got *Bytecode, checkSourceMap bool, opt ...*TestBytecodesEqualOptions)
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 ToWritable ¶
func TranspileOptions ¶
func TranspileOptions() *node.TranspileOptions
func TypeAssignerFullName ¶ added in v0.0.2
func TypeAssignerFullName(t TypeAssigner) string
TypeAssignerFullName returns a fully-qualified display name for a type assigner, falling back to TypeAssignerName.
func TypeAssignerName ¶ added in v0.0.2
func TypeAssignerName(t TypeAssigner) string
TypeAssignerName returns a display name for a type assigner (an ObjectType's Name, a meti/interface's Name, else its ToString).
func TypeAssigners ¶ added in v0.0.2
func TypeAssigners(t ObjectType, cb func(t ObjectType) any) (ret any)
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) BinOpGreater ¶ added in v0.0.2
func (Args) BinOpGreaterEq ¶ added in v0.0.2
func (Args) BinOpLess ¶ added in v0.0.2
Args compares by length against another Args, and orders after nil; these implement the comparison ObjectWith{Op}BinOperator interfaces.
func (Args) BinOpLessEq ¶ added in v0.0.2
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) DestructureRangeVar ¶ added in v0.0.2
DestructureRangeVar 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) 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) DestructureVarMinCb ¶ added in v0.0.2
func (o Args) DestructureVarMinCb(min int, otherCb func(i int, arg Object) error, dst ...*Arg) (err error)
DestructureVarMinCb shifts argument and set value to dst, and returns left arguments. If the number of arguments is less then to called args length + min, it returns an error. If type check of arg is fails, returns ArgumentTypeError. If has more args, call otherCb.
func (Args) DestructureVarRangeCb ¶ added in v0.0.2
func (o Args) DestructureVarRangeCb(min, max int, otherCb func(i int, arg Object) error, dst ...*Arg) (err error)
DestructureVarRangeCb shifts argument and set value to dst, and returns left arguments. If the number of arguments is less then to called args length + min, it returns an error. If type check of arg is fails, returns ArgumentTypeError. If has more args, call otherCb.
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 ObjectTypeArray)
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) BinOpAdd ¶ added in v0.0.2
BinOpAdd appends right to the array (ObjectWithAddBinOperator): an iterable extends it, any other value (including strings) is appended as one element.
func (Array) BinOpGreater ¶ added in v0.0.2
func (Array) BinOpGreaterEq ¶ added in v0.0.2
func (Array) BinOpIn ¶ added in v0.0.2
Contains reports whether v equals an element of the array (`v in array`). BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v is an element of o.
func (Array) BinOpLessEq ¶ added in v0.0.2
func (Array) Print ¶
func (o Array) Print(state *PrinterState) (err error)
func (Array) PrintObject ¶ added in v0.0.2
func (o Array) PrintObject(state *PrinterState, obj Object) (err error)
func (Array) SelfAssignOpAdd ¶ added in v0.0.2
SelfAssignOpAdd handles `arr += v`: append the single value v.
func (Array) SelfAssignOpInc ¶ added in v0.0.2
SelfAssignOpInc handles `arr ++= v`: append the elements of v (spread).
func (Array) ToAnyArray ¶
func (Array) ToInterface ¶
func (Array) Type ¶
func (o Array) Type() ObjectType
type BinaryOperatorType ¶
func (BinaryOperatorType) AssignTo ¶ added in v0.0.2
func (b BinaryOperatorType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
func (BinaryOperatorType) CanAssign ¶ added in v0.0.2
func (b BinaryOperatorType) CanAssign(obj Object) (bool, error)
func (BinaryOperatorType) Equal ¶
func (b BinaryOperatorType) Equal(right Object) bool
func (BinaryOperatorType) Fields ¶
func (BinaryOperatorType) Fields() Dict
func (BinaryOperatorType) FullName ¶ added in v0.0.2
func (b BinaryOperatorType) FullName() string
func (BinaryOperatorType) GadObjectType ¶ added in v0.0.2
func (BinaryOperatorType) GadObjectType()
func (BinaryOperatorType) Getters ¶
func (BinaryOperatorType) Getters() Dict
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) BinOpAdd ¶ added in v0.0.2
A Bool behaves as 0/1 in arithmetic, with the result type following the numeric right operand (Int or Uint). These implement the per-operator ObjectWith{Op}BinOperator interfaces.
func (Bool) BinOpAndNot ¶ added in v0.0.2
func (Bool) BinOpGreater ¶ added in v0.0.2
func (Bool) BinOpGreaterEq ¶ added in v0.0.2
func (Bool) BinOpLessEq ¶ added in v0.0.2
func (Bool) Type ¶
func (o Bool) Type() ObjectType
type Buffer ¶
func (*Buffer) Print ¶ added in v0.0.2
func (o *Buffer) Print(state *PrinterState) error
func (*Buffer) Type ¶
func (o *Buffer) Type() ObjectType
type BuiltinCompilableModule ¶ added in v0.0.2
type BuiltinCompilableModule struct {
Compile BuiltinCompileModuleFunc
}
BuiltinCompilableModule is an importable module that's written in ToInterface.
func (*BuiltinCompilableModule) Import ¶ added in v0.0.2
func (m *BuiltinCompilableModule) Import(_ context.Context, module *ModuleSpec) (any, string, error)
Import returns an immutable map for the module.
type BuiltinCompileModuleContext ¶ added in v0.0.2
type BuiltinCompileModuleContext struct {
Node ast.Node
Compiler *Compiler
FileSet *source.FileSet
Spec *ModuleSpec
}
func (*BuiltinCompileModuleContext) Compile ¶ added in v0.0.2
func (c *BuiltinCompileModuleContext) Compile(smts node.Stmts) error
func (*BuiltinCompileModuleContext) SetFileData ¶ added in v0.0.2
func (c *BuiltinCompileModuleContext) SetFileData(data []byte) *source.File
type BuiltinCompileModuleFunc ¶ added in v0.0.2
type BuiltinCompileModuleFunc func(ctx *BuiltinCompileModuleContext) (*Bytecode, error)
type BuiltinFunction ¶
type BuiltinFunction struct {
ObjectImpl
// Module qualifies the function's name (e.g. gad.binOpAdd) and scopes it to
// a builtin namespace; set with WithModule.
Module *ModuleSpec
// FuncName is the function's (unqualified) name, used in repr and errors.
FuncName string
// Value is the Go handler invoked on each call.
Value func(Call) (Object, error)
// Header declares the parameter signature (names/types); it drives argument
// dispatch and appears in repr. Set it via WithParams/WithParamsPairs.
Header *FunctionHeader
// AcceptMethodsDisabled prevents the function from being promoted to a
// method-bearing builtin (no `met`/AddMethod overloads allowed).
AcceptMethodsDisabled bool
// Usage is optional Markdown documentation shown by Doc().
Usage string
}
BuiltinFunction is a runtime-provided callable registered in the builtins table (see BuiltinObjects / BuiltinsMap). It behaves like Function but is part of the interpreter's standard environment rather than user code. Build one with NewBuiltinFunction and the fluent With* options:
fn := NewBuiltinFunction("binOpAdd", func(c Call) (Object, error) { … }).
WithModule(gadModuleSpec).WithParamsPairs("left", TAny, "right", TAny)
A BuiltinFunction holds a single handler; to accept typed method overloads (via `met`/AddMethod) it is promoted to a BuiltinFunctionWithMethods.
func NewBuiltinFunction ¶
func NewBuiltinFunction(name string, value func(Call) (Object, error), opt ...BuiltinFunctionOption) *BuiltinFunction
func (*BuiltinFunction) Copy ¶
func (f *BuiltinFunction) Copy() Object
Copy implements Copier interface.
func (*BuiltinFunction) Doc ¶ added in v0.0.2
func (f *BuiltinFunction) Doc() string
func (*BuiltinFunction) Equal ¶
func (f *BuiltinFunction) Equal(right Object) bool
Equal implements Object interface.
func (*BuiltinFunction) IsFalsy ¶
func (*BuiltinFunction) IsFalsy() bool
IsFalsy implements Object interface.
func (*BuiltinFunction) MethodsDisabled ¶
func (f *BuiltinFunction) MethodsDisabled() bool
func (*BuiltinFunction) Name ¶
func (f *BuiltinFunction) Name() string
func (*BuiltinFunction) ParamTypes ¶
func (f *BuiltinFunction) ParamTypes() ParamsTypes
func (*BuiltinFunction) ReturnVars ¶ added in v0.0.2
func (f *BuiltinFunction) ReturnVars() ReturnVars
func (*BuiltinFunction) String ¶ added in v0.0.2
func (f *BuiltinFunction) String() string
func (*BuiltinFunction) ToString ¶
func (f *BuiltinFunction) ToString() string
func (*BuiltinFunction) Type ¶
func (*BuiltinFunction) Type() ObjectType
func (*BuiltinFunction) WithHeader ¶ added in v0.0.2
func (f *BuiltinFunction) WithHeader(do func(h *FunctionHeader)) *BuiltinFunction
func (*BuiltinFunction) WithModule ¶ added in v0.0.2
func (f *BuiltinFunction) WithModule(module *ModuleSpec) *BuiltinFunction
func (*BuiltinFunction) WithParams ¶ added in v0.0.2
func (f *BuiltinFunction) WithParams(builder func(newParam func(name string) *ParamBuilder)) *BuiltinFunction
func (*BuiltinFunction) WithParamsPairs ¶ added in v0.0.2
func (f *BuiltinFunction) WithParamsPairs(nameAndType ...any) *BuiltinFunction
type BuiltinFunctionOption ¶ added in v0.0.2
type BuiltinFunctionOption func(f *BuiltinFunction)
func BuiltinFunctionWithHeader ¶ added in v0.0.2
func BuiltinFunctionWithHeader(do func(h *FunctionHeader)) BuiltinFunctionOption
func BuiltinFunctionWithModule ¶ added in v0.0.2
func BuiltinFunctionWithModule(module *ModuleSpec) BuiltinFunctionOption
type BuiltinFunctionWithMethods ¶ added in v0.0.2
type BuiltinFunctionWithMethods struct {
*FuncSpec
Module *ModuleSpec
// contains filtered or unexported fields
}
func NewBuiltinFunctionWithMethods ¶ added in v0.0.2
func NewBuiltinFunctionWithMethods(name string, module *ModuleSpec) *BuiltinFunctionWithMethods
func (BuiltinFunctionWithMethods) Copy ¶ added in v0.0.2
func (f BuiltinFunctionWithMethods) Copy() Object
func (*BuiltinFunctionWithMethods) Equal ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) Equal(right Object) bool
func (*BuiltinFunctionWithMethods) FullName ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) FullName() string
func (*BuiltinFunctionWithMethods) FuncSpecName ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) FuncSpecName() string
func (*BuiltinFunctionWithMethods) GetModule ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) GetModule() *ModuleSpec
func (*BuiltinFunctionWithMethods) Name ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) Name() string
func (*BuiltinFunctionWithMethods) Print ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) Print(state *PrinterState) (err error)
func (*BuiltinFunctionWithMethods) String ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) String() string
func (*BuiltinFunctionWithMethods) ToString ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) ToString() string
func (*BuiltinFunctionWithMethods) Type ¶ added in v0.0.2
func (f *BuiltinFunctionWithMethods) Type() ObjectType
type BuiltinInitModule ¶ added in v0.0.2
type BuiltinInitModule struct {
Init ModuleInitFunc
}
BuiltinInitModule is an importable module that's written in ToInterface.
func (*BuiltinInitModule) Import ¶ added in v0.0.2
func (m *BuiltinInitModule) Import(_ context.Context, module *ModuleSpec) (any, string, error)
Import returns an immutable map for the module.
type BuiltinModule ¶
type BuiltinModule struct {
Attrs Dict
// contains filtered or unexported fields
}
BuiltinModule is an importable module that's written in ToInterface.
func (*BuiltinModule) Import ¶
func (m *BuiltinModule) Import(_ context.Context, module *ModuleSpec) (any, string, error)
Import returns an immutable map for the module.
func (*BuiltinModule) InitFunc ¶ added in v0.0.2
func (m *BuiltinModule) InitFunc() ModuleInitFunc
type BuiltinObjType ¶
type BuiltinObjType struct {
Module *ModuleSpec
*FuncSpec
// contains filtered or unexported fields
}
func NewBuiltinObjType ¶
func NewBuiltinObjType(name string) *BuiltinObjType
func RegisterBuiltinType ¶
func RegisterBuiltinType(typ BuiltinType, name string, val any, init CallableFunc) *BuiltinObjType
func (*BuiltinObjType) AssignTo ¶ added in v0.0.2
func (t *BuiltinObjType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
func (*BuiltinObjType) BuiltinType ¶ added in v0.0.2
func (t *BuiltinObjType) BuiltinType() BuiltinType
func (*BuiltinObjType) CanAssign ¶ added in v0.0.2
func (t *BuiltinObjType) CanAssign(obj Object) (bool, error)
func (BuiltinObjType) Copy ¶ added in v0.0.2
func (t BuiltinObjType) Copy() Object
func (*BuiltinObjType) Equal ¶
func (t *BuiltinObjType) Equal(right Object) bool
func (*BuiltinObjType) Fields ¶
func (t *BuiltinObjType) Fields() Dict
func (*BuiltinObjType) FullName ¶ added in v0.0.2
func (t *BuiltinObjType) FullName() string
FullName returns the type's display name, qualified with its module when it belongs to one (e.g. `time.Time`, `time.Location`). Standalone types (int, str, …) render by their bare name.
func (*BuiltinObjType) FuncSpecName ¶ added in v0.0.2
func (t *BuiltinObjType) FuncSpecName() string
func (*BuiltinObjType) GadObjectType ¶ added in v0.0.2
func (t *BuiltinObjType) GadObjectType()
func (*BuiltinObjType) GetModule ¶ added in v0.0.2
func (t *BuiltinObjType) GetModule() *ModuleSpec
func (*BuiltinObjType) Getters ¶
func (t *BuiltinObjType) Getters() Dict
func (*BuiltinObjType) IsFalsy ¶
func (t *BuiltinObjType) IsFalsy() bool
func (*BuiltinObjType) Methods ¶
func (t *BuiltinObjType) Methods() Dict
func (*BuiltinObjType) Name ¶
func (t *BuiltinObjType) Name() string
func (*BuiltinObjType) Print ¶ added in v0.0.2
func (t *BuiltinObjType) Print(state *PrinterState) (err error)
func (*BuiltinObjType) ReprTypeName ¶ added in v0.0.2
func (t *BuiltinObjType) ReprTypeName() string
func (*BuiltinObjType) SetModule ¶ added in v0.0.2
func (t *BuiltinObjType) SetModule(m *ModuleSpec)
func (*BuiltinObjType) Setters ¶
func (t *BuiltinObjType) Setters() Dict
func (*BuiltinObjType) String ¶
func (t *BuiltinObjType) String() string
func (*BuiltinObjType) ToString ¶
func (t *BuiltinObjType) ToString() string
func (*BuiltinObjType) Type ¶
func (t *BuiltinObjType) Type() ObjectType
func (*BuiltinObjType) TypeKey ¶ added in v0.0.2
func (t *BuiltinObjType) TypeKey() BuiltinObjTypeKey
func (*BuiltinObjType) WithNew ¶ added in v0.0.2
func (t *BuiltinObjType) WithNew(f CallableFunc) *BuiltinObjType
type BuiltinObjTypeKey ¶ added in v0.0.2
type BuiltinObjTypeKey BuiltinType
var ( TNil, TFlag, TBool, TInt, TUint, TFloat, TDecimal, TChar, TRawStr, TStr, TTypedIdent, TBytes, TBuffer, TArray, TDict, TSyncDict, TKeyValue, TKeyValueArray, TRegexp, TRegexpStrsResult, TRegexpStrsSliceResult, TRegexpBytesResult, TRegexpBytesSliceResult, TMixedParams, TError, TPrinterState, TFunc, TComputedValue, TBuiltinFunction, TCallWrapper, TCompiledFunction, TFunction, TKeyValueArrays, TArgs, TNamedArgs, TObjectPtr, TReader, TWriter, TDiscardWriter, TObjectTypeArray, TReflectMethod, TIndexGetProxy BuiltinObjTypeKey )
func (BuiltinObjTypeKey) AssignTo ¶ added in v0.0.2
func (b BuiltinObjTypeKey) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
func (BuiltinObjTypeKey) BType ¶ added in v0.0.2
func (b BuiltinObjTypeKey) BType() BuiltinType
func (BuiltinObjTypeKey) Call ¶ added in v0.0.2
func (b BuiltinObjTypeKey) Call(c Call) (Object, error)
func (BuiltinObjTypeKey) CanAssign ¶ added in v0.0.2
func (b BuiltinObjTypeKey) CanAssign(obj Object) (bool, error)
func (BuiltinObjTypeKey) Equal ¶ added in v0.0.2
func (b BuiltinObjTypeKey) Equal(right Object) bool
func (BuiltinObjTypeKey) FullName ¶ added in v0.0.2
func (b BuiltinObjTypeKey) FullName() string
func (BuiltinObjTypeKey) GadObjectType ¶ added in v0.0.2
func (BuiltinObjTypeKey) GadObjectType()
func (BuiltinObjTypeKey) IsFalsy ¶ added in v0.0.2
func (b BuiltinObjTypeKey) IsFalsy() bool
func (BuiltinObjTypeKey) Name ¶ added in v0.0.2
func (b BuiltinObjTypeKey) Name() string
func (BuiltinObjTypeKey) Print ¶ added in v0.0.2
func (b BuiltinObjTypeKey) Print(state *PrinterState) error
func (BuiltinObjTypeKey) String ¶ added in v0.0.2
func (b BuiltinObjTypeKey) String() string
func (BuiltinObjTypeKey) ToString ¶ added in v0.0.2
func (b BuiltinObjTypeKey) ToString() string
func (BuiltinObjTypeKey) Type ¶ added in v0.0.2
func (b BuiltinObjTypeKey) Type() ObjectType
type BuiltinObjectsMap ¶
type BuiltinObjectsMap map[BuiltinType]Object
func (BuiltinObjectsMap) AddMethod ¶ added in v0.0.2
func (m BuiltinObjectsMap) AddMethod(typ BuiltinType, method ...TypedCallerObjectWithParamTypes)
func (BuiltinObjectsMap) Append ¶
func (m BuiltinObjectsMap) Append(obj ...Object) BuiltinObjectsMap
type BuiltinType ¶
type BuiltinType uint16
BuiltinType represents a builtin type
const ( BuiltinTypesBegin_ BuiltinType = iota // types BuiltinNil BuiltinAny 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 BuiltinTypedIdent BuiltinFunc BuiltinComputedValue // BuiltinProp is the builtin object type for getter/setter properties. BuiltinProp // BuiltinFunctionHeader is the builtin object type for func-header values. BuiltinFunctionHeader // BuiltinMethodInterface is the builtin object type for method interfaces. BuiltinMethodInterface // BuiltinInterface is the builtin object type for `interface { … }` values. BuiltinInterface BuiltinTypesEnd_ BuiltinStaticTypesStart_ BuiltinStaticTypeBuiltinFunction BuiltinStaticTypeCallWrapper BuiltinStaticTypeCompiledFunction BuiltinStaticTypeFunction BuiltinStaticTypeKeyValueArrays BuiltinStaticTypeArgs BuiltinStaticTypeNamedArgs BuiltinStaticTypeObjectPtr BuiltinStaticTypeReader BuiltinStaticTypeWriter BuiltinStaticTypeDiscardWriter BuiltinStaticTypeObjectTypeArray BuiltinStaticTypeReflectMethod BuiltinStaticTypeIndexGetProxy BuiltinRange BuiltinStaticTypesEnd_ BuiltinFunctionsBegin_ BuiltinBinaryOperator BuiltinSelfAssignOperator BuiltinUnaryOperator BuiltinEnter BuiltinExit BuiltinRepr BuiltinCast BuiltinAppend BuiltinDelete BuiltinCopy BuiltinDeepCopy BuiltinRepeat BuiltinContains BuiltinLen BuiltinSort BuiltinSortReverse BuiltinFilter BuiltinMap BuiltinEach BuiltinReduce BuiltinTypeName BuiltinChars BuiltinClose BuiltinRead BuiltinWrite BuiltinPrint BuiltinPrintf BuiltinPrintln BuiltinSprintf BuiltinStdIO BuiltinWrap BuiltinNewClass BuiltinTypeOf BuiltinAddMethod BuiltinRawCaller BuiltinMakeArray BuiltinMakeArrayRest 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 BuiltinImplements BuiltinMethodFromArgs BuiltinFunctionsEnd_ BuiltinErrorsBegin_ // errors BuiltinWrongNumArgumentsError BuiltinInvalidOperatorError BuiltinIndexOutOfBoundsError BuiltinNotIterableError BuiltinNotIndexableError BuiltinNotIndexAssignableError BuiltinNotCallableError BuiltinNotImplementedError BuiltinZeroDivisionError BuiltinTypeError BuiltinErrorsEnd_ BuiltinConstantsBegin_ BuiltinDiscardWriter BuiltinConstantsEnd_ // Builtin module namespaces (stdlib modules exposed without `import`). GroupBuiltinModulesBegin BuiltinModuleBase64 BuiltinModuleStrings BuiltinModuleTime BuiltinModuleFmt BuiltinModuleGad GroupBuiltinModulesEnd GroupBuiltinBinaryOperatorsBegin BuiltinBinaryOperatorAdd BuiltinBinaryOperatorSub BuiltinBinaryOperatorMul BuiltinBinaryOperatorPow BuiltinBinaryOperatorQuo BuiltinBinaryOperatorRem BuiltinBinaryOperatorAnd BuiltinBinaryOperatorOr BuiltinBinaryOperatorXor BuiltinBinaryOperatorShl BuiltinBinaryOperatorShr BuiltinBinaryOperatorAndNot BuiltinBinaryOperatorLAnd BuiltinBinaryOperatorEqual BuiltinBinaryOperatorNotEqual BuiltinBinaryOperatorLess BuiltinBinaryOperatorGreater BuiltinBinaryOperatorLessEq BuiltinBinaryOperatorGreaterEq BuiltinBinaryOperatorTilde BuiltinBinaryOperatorDoubleTilde BuiltinBinaryOperatorTripleTilde BuiltinBinaryOperatorDotDot BuiltinBinaryOperatorTripleLess BuiltinBinaryOperatorTripleGreater BuiltinBinaryOperatorDoubleMod BuiltinBinaryOperatorLambda BuiltinBinaryOperatorSame BuiltinBinaryOperatorNotSame BuiltinBinaryOperatorInc BuiltinBinaryOperatorDec BuiltinBinaryOperatorIn BuiltinBinaryOperatorAin GroupBuiltinBinaryOperatorsEnd GroupBuiltinSelfAssignOperatorsBegin BuiltinSelfAssignOperatorAdd BuiltinSelfAssignOperatorInc BuiltinSelfAssignOperatorSub BuiltinSelfAssignOperatorDec BuiltinSelfAssignOperatorMul BuiltinSelfAssignOperatorPow BuiltinSelfAssignOperatorQuo BuiltinSelfAssignOperatorRem BuiltinSelfAssignOperatorAnd BuiltinSelfAssignOperatorOr BuiltinSelfAssignOperatorXor BuiltinSelfAssignOperatorShl BuiltinSelfAssignOperatorShr BuiltinSelfAssignOperatorTripleLess BuiltinSelfAssignOperatorTripleGreater BuiltinSelfAssignOperatorDoubleMod BuiltinSelfAssignOperatorAndNot BuiltinSelfAssignOperatorLOr GroupBuiltinSelfAssignOperatorsEnd GroupBuiltinUnaryOperatorsBegin BuiltinUnaryOperatorNot BuiltinUnaryOperatorSub BuiltinUnaryOperatorAdd BuiltinUnaryOperatorXor BuiltinUnaryOperatorInc BuiltinUnaryOperatorDec GroupBuiltinUnaryOperatorsEnd BuiltinEnd_ )
Builtins
func NewBuiltinType ¶
func NewBuiltinType() (t BuiltinType)
func (BuiltinType) String ¶
func (t BuiltinType) String() string
type Builtins ¶
type Builtins struct {
Objects BuiltinObjectsMap
NameSet BuiltinsNameSet
// contains filtered or unexported fields
}
func NewBuiltins ¶
func NewBuiltins() *Builtins
func (*Builtins) ArgsInvoker ¶
func (*Builtins) Build ¶ added in v0.0.2
func (b *Builtins) Build() (s *StaticBuiltins)
func (*Builtins) Caller ¶
func (b *Builtins) Caller(t BuiltinType) CallerObject
func (*Builtins) Get ¶
func (b *Builtins) Get(t BuiltinType) Object
func (*Builtins) SetType ¶
func (b *Builtins) SetType(typ ObjectType) *Builtins
type BuiltinsNameSet ¶ added in v0.0.2
type BuiltinsNameSet map[string]BuiltinType
type Bytecode ¶
type Bytecode struct {
FileSet *source.FileSet
Main *CompiledFunction
Constants Array
Modules []*ModuleSpec
NumModules int
}
Bytecode holds the compiled functions and constants.
func Compile ¶
func Compile(st *SymbolTable, script []byte, opts CompileOptions) (pf *parser.File, bc *Bytecode, err error)
Compile compiles given script to Bytecode.
func CompileFile ¶ added in v0.0.2
func CompileFile(st *SymbolTable, module *ModuleSpec, pf *parser.File, opts CompileOptions) (bc *Bytecode, err error)
CompileFile compiles given module file to Bytecode.
func CompileModule ¶ added in v0.0.2
func CompileModule(st *SymbolTable, module *ModuleSpec, script []byte, opts CompileOptions) (pf *parser.File, bc *Bytecode, err error)
CompileModule compiles given module script to Bytecode.
type Bytes ¶
type Bytes []byte
Bytes represents byte slice and implements Object interface.
func (Bytes) BinOpAdd ¶ added in v0.0.2
BinOpAdd appends Bytes or a Str to the bytes (ObjectWithAddBinOperator).
func (Bytes) BinOpGreater ¶ added in v0.0.2
func (Bytes) BinOpGreaterEq ¶ added in v0.0.2
func (Bytes) BinOpIn ¶ added in v0.0.2
Contains reports whether v (a byte-valued number/char in 0..255) is present in the bytes (`v in bytes`). BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether the byte value v is present in o.
func (Bytes) BinOpLessEq ¶ added in v0.0.2
func (Bytes) Print ¶ added in v0.0.2
func (o Bytes) Print(state *PrinterState) (err error)
func (Bytes) Type ¶
func (o Bytes) Type() ObjectType
type BytesConverter ¶
BytesConverter is to bytes converter
type CalendarDate ¶ added in v0.0.2
type CalendarDate uint
CalendarDate is a calendar date encoded as the unsigned integer YYYYMMDD (e.g. 20260131 for 2026-01-31); it mirrors a Go uint and is one of the time module's value types.
func CalendarDateFromTime ¶ added in v0.0.2
func CalendarDateFromTime(t time.Time) CalendarDate
CalendarDateFromTime returns the CalendarDate (YYYYMMDD) part of t.
func NewCalendarDate ¶ added in v0.0.2
func NewCalendarDate(year, month, day int) CalendarDate
NewCalendarDate builds a CalendarDate from its year, month and day components.
func (CalendarDate) BinOpAdd ¶ added in v0.0.2
func (o CalendarDate) BinOpAdd(_ *VM, right Object) (Object, error)
BinaryOp supports duration arithmetic, date difference and ordered comparisons:
- `calendarDate ± duration` -> calendarDate when the result lands on midnight (a whole number of days), otherwise calendarTime
- `calendarDate - calendarDate` -> duration
- ordered comparisons -> bool (the YYYYMMDD encoding is monotonic)
func (CalendarDate) BinOpGreater ¶ added in v0.0.2
func (o CalendarDate) BinOpGreater(_ *VM, right Object) (Object, error)
func (CalendarDate) BinOpGreaterEq ¶ added in v0.0.2
func (o CalendarDate) BinOpGreaterEq(_ *VM, right Object) (Object, error)
func (CalendarDate) BinOpLess ¶ added in v0.0.2
func (o CalendarDate) BinOpLess(_ *VM, right Object) (Object, error)
func (CalendarDate) BinOpLessEq ¶ added in v0.0.2
func (o CalendarDate) BinOpLessEq(_ *VM, right Object) (Object, error)
func (CalendarDate) BinOpSub ¶ added in v0.0.2
func (o CalendarDate) BinOpSub(_ *VM, right Object) (Object, error)
func (CalendarDate) CallName ¶ added in v0.0.2
func (o CalendarDate) CallName(name string, c Call) (Object, error)
CallName dispatches the date accessor methods.
func (CalendarDate) Day ¶ added in v0.0.2
func (o CalendarDate) Day() int
func (CalendarDate) Equal ¶ added in v0.0.2
func (o CalendarDate) Equal(right Object) bool
Equal implements Object. A CalendarDate equals another CalendarDate or a uint/int with the same YYYYMMDD value.
func (CalendarDate) IsFalsy ¶ added in v0.0.2
func (o CalendarDate) IsFalsy() bool
IsFalsy reports whether the date is the zero value.
func (CalendarDate) MarshalJSON ¶ added in v0.0.2
func (o CalendarDate) MarshalJSON() ([]byte, error)
MarshalJSON encodes the date as the JSON string "YYYY-MM-DD".
func (CalendarDate) Month ¶ added in v0.0.2
func (o CalendarDate) Month() int
func (CalendarDate) Print ¶ added in v0.0.2
func (o CalendarDate) Print(s *PrinterState) error
Print writes the date (Printabler); without it the printer's reflection fallback would recurse on this named-uint Object.
func (CalendarDate) Time ¶ added in v0.0.2
func (o CalendarDate) Time(loc *time.Location) time.Time
Time returns midnight of this date in the given location (UTC when nil).
func (CalendarDate) ToString ¶ added in v0.0.2
func (o CalendarDate) ToString() string
ToString renders the date as YYYY-MM-DD.
func (CalendarDate) Type ¶ added in v0.0.2
func (CalendarDate) Type() ObjectType
func (CalendarDate) Year ¶ added in v0.0.2
func (o CalendarDate) Year() int
type CalendarTime ¶ added in v0.0.2
type CalendarTime uint64
CalendarTime is a zone-less wall-clock timestamp stored as the number of nanoseconds since the Unix epoch (interpreted as UTC wall clock). Unlike *Time it carries no location; it mirrors a Go uint64 and is one of the time module's value types. Instants before 1970-01-01 are not representable.
func CalendarTimeFromTime ¶ added in v0.0.2
func CalendarTimeFromTime(t time.Time) CalendarTime
CalendarTimeFromTime returns the zone-less CalendarTime of t (its wall-clock fields are kept; the zone is dropped).
func NewCalendarTime ¶ added in v0.0.2
func NewCalendarTime(year, month, day, hour, min, sec, nsec int) CalendarTime
NewCalendarTime builds a CalendarTime from its components (UTC wall clock).
func (CalendarTime) BinOpAdd ¶ added in v0.0.2
func (o CalendarTime) BinOpAdd(_ *VM, right Object) (Object, error)
BinaryOp supports duration arithmetic and ordered comparisons:
- `calendarTime ± int|duration` -> calendarTime (the int is nanoseconds)
- `calendarTime - calendarTime` -> duration
- `calendarTime <|<=|>|>= calendarTime` -> bool
func (CalendarTime) BinOpGreater ¶ added in v0.0.2
func (o CalendarTime) BinOpGreater(_ *VM, right Object) (Object, error)
func (CalendarTime) BinOpGreaterEq ¶ added in v0.0.2
func (o CalendarTime) BinOpGreaterEq(_ *VM, right Object) (Object, error)
func (CalendarTime) BinOpLess ¶ added in v0.0.2
func (o CalendarTime) BinOpLess(_ *VM, right Object) (Object, error)
func (CalendarTime) BinOpLessEq ¶ added in v0.0.2
func (o CalendarTime) BinOpLessEq(_ *VM, right Object) (Object, error)
func (CalendarTime) BinOpSub ¶ added in v0.0.2
func (o CalendarTime) BinOpSub(_ *VM, right Object) (Object, error)
func (CalendarTime) CallName ¶ added in v0.0.2
func (o CalendarTime) CallName(name string, c Call) (Object, error)
CallName dispatches the calendar-time accessor methods.
func (CalendarTime) Date ¶ added in v0.0.2
func (o CalendarTime) Date() CalendarDate
Date returns the calendar date (YYYYMMDD) part of this timestamp.
func (CalendarTime) Day ¶ added in v0.0.2
func (o CalendarTime) Day() int
func (CalendarTime) Equal ¶ added in v0.0.2
func (o CalendarTime) Equal(right Object) bool
Equal implements Object. A CalendarTime equals another CalendarTime or a uint/int holding the same nanosecond count.
func (CalendarTime) Hour ¶ added in v0.0.2
func (o CalendarTime) Hour() int
func (CalendarTime) IsFalsy ¶ added in v0.0.2
func (o CalendarTime) IsFalsy() bool
IsFalsy reports whether the timestamp is the zero value.
func (CalendarTime) MarshalJSON ¶ added in v0.0.2
func (o CalendarTime) MarshalJSON() ([]byte, error)
MarshalJSON encodes the timestamp as a JSON string "YYYY-MM-DD HH:MM:SS".
func (CalendarTime) Minute ¶ added in v0.0.2
func (o CalendarTime) Minute() int
func (CalendarTime) Month ¶ added in v0.0.2
func (o CalendarTime) Month() int
func (CalendarTime) Nanosecond ¶ added in v0.0.2
func (o CalendarTime) Nanosecond() int
func (CalendarTime) Print ¶ added in v0.0.2
func (o CalendarTime) Print(s *PrinterState) error
Print writes the timestamp (Printabler); without it the printer's reflection fallback would recurse on this named-uint64 Object.
func (CalendarTime) Second ¶ added in v0.0.2
func (o CalendarTime) Second() int
func (CalendarTime) Time ¶ added in v0.0.2
func (o CalendarTime) Time(loc *time.Location) time.Time
Time returns this wall time in the given location (UTC when nil).
func (CalendarTime) ToString ¶ added in v0.0.2
func (o CalendarTime) ToString() string
ToString renders the timestamp as "YYYY-MM-DD HH:MM:SS[.fraction]".
func (CalendarTime) Type ¶ added in v0.0.2
func (CalendarTime) Type() ObjectType
func (CalendarTime) Year ¶ added in v0.0.2
func (o CalendarTime) Year() int
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
func (*Call) Params ¶ added in v0.0.2
func (c *Call) Params() *MixedParams
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) Name ¶ added in v0.0.2
func (i *CallWrapper) Name() string
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.
func FuncPTLRO ¶ added in v0.0.2
func FuncPTLRO(fn func(*Time, *Location) Object) CallableFunc
FuncPTLRO is a generated function to make CallableFunc. Source: FuncPTLRO(t *Time, loc *Location) (ret Object)
func FuncPTRO ¶ added in v0.0.2
func FuncPTRO(fn func(*Time) Object) CallableFunc
FuncPTRO is a generated function to make CallableFunc. Source: FuncPTRO(t *Time) (ret Object)
func FuncPTTRO ¶ added in v0.0.2
func FuncPTTRO(fn func(*Time, *Time) Object) CallableFunc
FuncPTTRO is a generated function to make CallableFunc. Source: FuncPTTRO(t1 *Time, t2 *Time) (ret Object)
func FuncPTb2sRO ¶ added in v0.0.2
func FuncPTb2sRO(fn func(*Time, []byte, string) Object) CallableFunc
FuncPTb2sRO is a generated function to make CallableFunc. Source: FuncPTb2sRO(t *Time, b []byte, s string) (ret Object)
func FuncPTi64RO ¶ added in v0.0.2
func FuncPTi64RO(fn func(*Time, int64) Object) CallableFunc
FuncPTi64RO is a generated function to make CallableFunc. Source: FuncPTi64RO(t *Time, d int64) (ret Object)
func FuncPTiiiRO ¶ added in v0.0.2
FuncPTiiiRO is a generated function to make CallableFunc. Source: FuncPTiiiRO(t *Time, i1 int, i2 int, i3 int) (ret Object)
type CallerMethod ¶
type CallerMethod struct {
CallerObject
ToStringDetailFunc func(m *CallerMethod) string
// contains filtered or unexported fields
}
func NewCallerMethod ¶ added in v0.0.2
func NewCallerMethod(target Object, callerObject CallerObject) *CallerMethod
func (*CallerMethod) Caller ¶
func (o *CallerMethod) Caller() CallerObject
func (*CallerMethod) IndexGet ¶ added in v0.0.2
func (o *CallerMethod) IndexGet(vm *VM, index Object) (value Object, err error)
func (*CallerMethod) String ¶
func (o *CallerMethod) String() string
func (*CallerMethod) StringTarget ¶ added in v0.0.2
func (o *CallerMethod) StringTarget(targets bool) string
func (*CallerMethod) Target ¶ added in v0.0.2
func (o *CallerMethod) Target() Object
type CallerMethodDefinition ¶
type CallerMethodDefinition struct {
Handler CallerObject
Types ParamsTypes
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
func YieldCallDone ¶ added in v0.0.2
func YieldCallDone(callerObject CallerObject, c *Call, done func()) CallerObject
type CallerObjectWithVMParamTypes ¶ added in v0.0.2
type CallerObjectWithVMParamTypes interface {
CallerObject
ParamTypes(vm *VM) (ParamsTypes, error)
}
CallerObjectWithVMParamTypes is an interface for objects that can be called with Call method with parameters with types.
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) BinOpAndNot ¶ added in v0.0.2
func (Char) BinOpGreater ¶ added in v0.0.2
func (Char) BinOpGreaterEq ¶ added in v0.0.2
func (Char) BinOpLessEq ¶ added in v0.0.2
func (Char) Type ¶
func (o Char) Type() ObjectType
type ClasPropertySetter ¶ added in v0.0.2
type ClasPropertySetter struct {
Handler CallerObject
ValueTypes ObjectTypes
// contains filtered or unexported fields
}
func (*ClasPropertySetter) ToParamTypes ¶ added in v0.0.2
func (s *ClasPropertySetter) ToParamTypes() (t ParamsTypes)
type Class ¶ added in v0.0.2
type Class struct {
// contains filtered or unexported fields
}
Class is a user-defined type created with the `Class(name; …)` builtin. It is an ObjectType (so values can be type-checked against it) and is itself callable: calling a Class constructs a ClassInstance via its constructor.
A class owns its fields (with defaults), methods, getter/setter properties and new-handlers, plus a list of parent classes for inheritance. It is assembled by NewClass followed by Define (which reads the `fields`/`methods`/ `properties`/`new`/`extends` named args); members can also be added incrementally via AddField/AddMethod/AddProperty and the `met`/`prop` syntax.
func NewClass ¶ added in v0.0.2
func NewClass(name string, module *ModuleSpec) (t *Class)
NewClass returns an empty Class with the given name and defining module, its constructor wired to Construct. Members are added afterwards via Define or the AddField/AddMethod/AddProperty helpers.
func (*Class) AddCallerMethod ¶ added in v0.0.2
func (t *Class) AddCallerMethod(_ *VM, types ParamsTypes, handler CallerObject, override bool, onAdd func(tcm *TypedCallerMethod) error) (err error)
func (*Class) AddField ¶ added in v0.0.2
func (t *Class) AddField(field ...*ClassField) error
func (*Class) AddMethod ¶ added in v0.0.2
func (t *Class) AddMethod(name string) (_ *ClassMethod, err error)
func (*Class) AddMethodByTypes ¶ added in v0.0.2
func (t *Class) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(method *TypedCallerMethod) error) error
func (*Class) AddMethodIndex ¶ added in v0.0.2
func (*Class) AddProperty ¶ added in v0.0.2
func (*Class) BinOpGreater ¶ added in v0.0.2
func (*Class) BinOpGreaterEq ¶ added in v0.0.2
func (*Class) BinOpLess ¶ added in v0.0.2
A class compares as greater than nil and is otherwise not comparable, so `class < nil` / `class <= nil` are false and `class > nil` / `class >= nil` are true; any other operand is unsupported.
func (*Class) BinOpLessEq ¶ added in v0.0.2
func (*Class) Call ¶ added in v0.0.2
Call constructs a new instance. Calling a Class value (`MyClass(…)`, in the VM or from Go via Class.Call(Call{VM: vm, …})) allocates an uninitialised instance, wraps it in a ClassInitiator and dispatches to the matching constructor, which receives the initiator as its `new` first parameter. The constructor body builds the instance with a `new(; fields)` super-call (see ClassInitiator.Call).
func (*Class) CallAddFields ¶ added in v0.0.2
func (*Class) CallAddMethods ¶ added in v0.0.2
func (*Class) CallAddNewHandlers ¶ added in v0.0.2
func (*Class) CallAddProperties ¶ added in v0.0.2
func (*Class) CallAddProperty ¶ added in v0.0.2
func (*Class) CallExtends ¶ added in v0.0.2
func (*Class) CallFieldsOf ¶ added in v0.0.2
func (*Class) CallGetProperty ¶ added in v0.0.2
func (*Class) CallerMethodDefault ¶ added in v0.0.2
func (t *Class) CallerMethodDefault() CallerObject
CallerMethodDefault returns the constructor's default caller, if any.
func (*Class) CallerMethodOfArgsTypes ¶ added in v0.0.2
func (t *Class) CallerMethodOfArgsTypes(types ObjectTypeArray) CallerObject
CallerMethodOfArgsTypes resolves a constructor method from argument types.
func (*Class) CallerMethodWithValidationCheckOfArgs ¶ added in v0.0.2
func (t *Class) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
CallerMethodWithValidationCheckOfArgs resolves a constructor method from args.
func (*Class) CallerMethodWithValidationCheckOfArgsTypes ¶ added in v0.0.2
func (t *Class) CallerMethodWithValidationCheckOfArgsTypes(types ObjectTypeArray) (CallerObject, bool)
CallerMethodWithValidationCheckOfArgsTypes resolves a constructor method from argument types.
func (*Class) CallerMethods ¶ added in v0.0.2
func (t *Class) CallerMethods() *MethodArgType
CallerMethods returns the constructor's method tree.
func (*Class) Construct ¶ added in v0.0.2
Construct re-initialises an already-allocated `this` instance (passed as the first argument) from the call's named args. It backs `instance.@new` and `MyClass.new(this; …)`.
func (*Class) Constructor ¶ added in v0.0.2
func (t *Class) Constructor() *ClassConstructor
func (*Class) DeclaresField ¶ added in v0.0.2
DeclaresField reports whether the class or one of its (transitive) parents declares a field named name.
func (*Class) Define ¶ added in v0.0.2
Define populates the class from the call's named args: `new` (constructor handler(s)), `fields` (a KeyValueArray of field specs), `methods`, `properties` and `extends` (parent classes). Each recognised arg runs its corresponding CallAdd* helper. Unrecognised named args are rejected (ErrUnexpectedNamedArg), so callers that handle some args themselves must consume those first (see NewClassFunc / NamedArgs.GetDoCheck).
func (Class) GadObjectType ¶ added in v0.0.2
func (Class) GadObjectType()
func (*Class) GetFuncSpec ¶ added in v0.0.2
GetFuncSpec exposes the constructor's dispatcher.
func (*Class) GetIndexMethod ¶ added in v0.0.2
func (*Class) GetProperty ¶ added in v0.0.2
func (t *Class) GetProperty(name string) *ClassProperty
func (*Class) HasCallerMethods ¶ added in v0.0.2
HasCallerMethods reports whether the constructor has registered methods.
func (*Class) IsChildOf ¶ added in v0.0.2
func (t *Class) IsChildOf(p ObjectType) bool
func (*Class) Module ¶ added in v0.0.2
func (t *Class) Module() *ModuleSpec
func (*Class) New ¶ added in v0.0.2
func (t *Class) New(c Call) (*ClassInstance, error)
New constructs an instance of t, initialising its fields from the given dict (defaults fill the rest). It is the Go-side entry point for creating an instance; from Gad, calling the class invokes Call/Construct. New constructs an instance of t, running any matching custom constructor. It is a typed wrapper over Call usable from Go (inside or outside the VM loop):
inst, err := cls.New(Call{VM: vm, Args: Args{Array{a, b}}})
func (*Class) NewInstance ¶ added in v0.0.2
func (t *Class) NewInstance() (o *ClassInstance)
NewInstance allocates an uninitialised instance of t (its fields are not yet populated; call Init or use NewInstanceWithFields).
func (*Class) NewInstanceWithFields ¶ added in v0.0.2
func (t *Class) NewInstanceWithFields(vm *VM, fields Dict) (*ClassInstance, error)
NewInstanceWithFields allocates an instance of t and runs Init with the given field values (applying defaults and inherited fields).
func (*Class) Print ¶ added in v0.0.2
func (t *Class) Print(state *PrinterState) error
func (*Class) Properties ¶ added in v0.0.2
func (*Class) RawFields ¶ added in v0.0.2
func (t *Class) RawFields() (r []*ClassField)
func (*Class) RawParents ¶ added in v0.0.2
func (t *Class) RawParents() []*ClassParent
func (*Class) Type ¶ added in v0.0.2
func (t *Class) Type() ObjectType
type ClassConstructor ¶ added in v0.0.2
type ClassConstructor struct {
// contains filtered or unexported fields
}
ClassConstructor is a Class's constructor: a callable FuncSpec holding the user `new` handler overloads plus the default handler (Class.Construct). It is invoked when a Class is called to build an instance.
func (*ClassConstructor) AddMethodByTypes ¶ added in v0.0.2
func (c *ClassConstructor) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(method *TypedCallerMethod) error) error
func (*ClassConstructor) Call ¶ added in v0.0.2
func (c *ClassConstructor) Call(c2 Call) (Object, error)
func (*ClassConstructor) Equal ¶ added in v0.0.2
func (c *ClassConstructor) Equal(right Object) bool
func (*ClassConstructor) FullName ¶ added in v0.0.2
func (c *ClassConstructor) FullName() string
func (*ClassConstructor) FuncSpecName ¶ added in v0.0.2
func (c *ClassConstructor) FuncSpecName() string
func (*ClassConstructor) GetFuncSpec ¶ added in v0.0.2
func (c *ClassConstructor) GetFuncSpec() *FuncSpec
GetFuncSpec exposes the constructor's dispatcher so helpers such as gad.methodFromArgs can resolve a registered constructor by argument types.
func (*ClassConstructor) GetModule ¶ added in v0.0.2
func (c *ClassConstructor) GetModule() *ModuleSpec
func (*ClassConstructor) IsFalsy ¶ added in v0.0.2
func (c *ClassConstructor) IsFalsy() bool
func (*ClassConstructor) Name ¶ added in v0.0.2
func (c *ClassConstructor) Name() string
func (*ClassConstructor) Print ¶ added in v0.0.2
func (c *ClassConstructor) Print(state *PrinterState) (err error)
func (*ClassConstructor) String ¶ added in v0.0.2
func (c *ClassConstructor) String() string
func (*ClassConstructor) ToString ¶ added in v0.0.2
func (c *ClassConstructor) ToString() string
func (*ClassConstructor) Type ¶ added in v0.0.2
func (c *ClassConstructor) Type() ObjectType
type ClassField ¶ added in v0.0.2
type ClassField struct {
Name string
Types ObjectTypes
Value Object
// contains filtered or unexported fields
}
ClassField is a declared field of a Class: its Name, optional accepted Types, positional index within the instance, and default Value (an initialiser or nil when the field has no default).
func (*ClassField) Equal ¶ added in v0.0.2
func (f *ClassField) Equal(right Object) bool
func (*ClassField) IsFalsy ¶ added in v0.0.2
func (f *ClassField) IsFalsy() bool
func (*ClassField) Print ¶ added in v0.0.2
func (f *ClassField) Print(state *PrinterState) (err error)
func (*ClassField) ReprTypeName ¶ added in v0.0.2
func (f *ClassField) ReprTypeName() string
func (*ClassField) String ¶ added in v0.0.2
func (f *ClassField) String() string
func (*ClassField) ToString ¶ added in v0.0.2
func (f *ClassField) ToString() string
func (*ClassField) Type ¶ added in v0.0.2
func (f *ClassField) Type() ObjectType
type ClassGoMethod ¶ added in v0.0.2
type ClassGoMethod struct {
Name string
Handlers []*ClassGoMethodHandler
}
type ClassGoMethodHandler ¶ added in v0.0.2
type ClassGoMethodHandler struct {
Handler CallerObject
ParamTypes ParamsTypes
}
type ClassInitiator ¶ added in v0.0.2
type ClassInitiator struct {
// contains filtered or unexported fields
}
ClassInitiator wraps the in-progress ClassInstance during construction. It is passed to every constructor as the `new` first parameter and is itself callable: a `new(; fields)` super-call dispatches to the matching constructor (or, when it re-enters the running one, to the default) to build the instance. newCallStack tracks the active constructor chain so that super-call recursion terminates at the default constructor.
func (*ClassInitiator) Call ¶ added in v0.0.2
func (in *ClassInitiator) Call(c Call) (_ Object, err error)
Call dispatches to the matching constructor, passing the initiator as the `new` first argument. A super-call back into the running constructor falls to the default constructor (which initialises the instance), so construction terminates. It returns the constructed instance.
func (*ClassInitiator) Equal ¶ added in v0.0.2
func (in *ClassInitiator) Equal(right Object) bool
func (*ClassInitiator) IsFalsy ¶ added in v0.0.2
func (in *ClassInitiator) IsFalsy() bool
func (*ClassInitiator) Name ¶ added in v0.0.2
func (in *ClassInitiator) Name() string
func (*ClassInitiator) ToString ¶ added in v0.0.2
func (in *ClassInitiator) ToString() string
func (*ClassInitiator) Type ¶ added in v0.0.2
func (in *ClassInitiator) Type() ObjectType
type ClassInstance ¶ added in v0.0.2
type ClassInstance struct {
// contains filtered or unexported fields
}
ClassInstance is a live object of a Class. It holds the instance's field values (fields), one ClassInstance per parent class (parents, keyed by the parent alias) and a back-reference to its class. It implements the Object interface and dispatches method, property and field access through its class.
func (*ClassInstance) AssignTo ¶ added in v0.0.2
func (o *ClassInstance) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
AssignTo makes *ClassInstance a TypeAssigner: obj is assignable to `to` when the instance's class (or one of its parents) is the target type. Returns obj unchanged (unlike CastTo, which returns the up-cast instance).
func (*ClassInstance) BinOpIn ¶ added in v0.0.2
func (o *ClassInstance) BinOpIn(_ *VM, v Object) (Object, error)
BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v names a property or a field of the instance, including fields inherited from parent instances. Membership is checked structurally, without invoking any property getter.
func (*ClassInstance) Call ¶ added in v0.0.2
func (o *ClassInstance) Call(Call) (Object, error)
Call on an instance is not a constructor entry point: instances are built via Class.Call / ClassInitiator. Calling a live instance is therefore an error.
func (*ClassInstance) CallName ¶ added in v0.0.2
func (o *ClassInstance) CallName(name string, c Call) (_ Object, err error)
func (*ClassInstance) CallPrint ¶ added in v0.0.2
func (o *ClassInstance) CallPrint(c Call) (err error)
func (*ClassInstance) Cast ¶ added in v0.0.2
func (o *ClassInstance) Cast(t ObjectType) *ClassInstance
func (*ClassInstance) CastTo ¶ added in v0.0.2
func (o *ClassInstance) CastTo(_ *VM, t ObjectType) (Object, error)
func (*ClassInstance) Copy ¶ added in v0.0.2
func (o *ClassInstance) Copy() Object
Copy implements Copier interface.
func (ClassInstance) CopyInstance ¶ added in v0.0.2
func (o ClassInstance) CopyInstance() *ClassInstance
CopyInstance copy this instance.
func (*ClassInstance) DeepCopy ¶ added in v0.0.2
func (o *ClassInstance) DeepCopy(vm *VM) (r Object, err error)
DeepCopy implements DeepCopier interface.
func (ClassInstance) DeepCopyInstance ¶ added in v0.0.2
func (o ClassInstance) DeepCopyInstance(vm *VM) (_ *ClassInstance, err error)
DeepCopyInstance deep copy this instance.
func (*ClassInstance) Equal ¶ added in v0.0.2
func (o *ClassInstance) Equal(right Object) bool
Equal implements Object interface.
func (*ClassInstance) Fields ¶ added in v0.0.2
func (o *ClassInstance) Fields() Dict
func (*ClassInstance) GetFieldValue ¶ added in v0.0.2
func (o *ClassInstance) GetFieldValue(vm *VM, name string) (Object, error)
func (*ClassInstance) GetMethod ¶ added in v0.0.2
func (o *ClassInstance) GetMethod(name string) CallerObject
func (*ClassInstance) GetPropertyGetter ¶ added in v0.0.2
func (o *ClassInstance) GetPropertyGetter(name string) (handler CallerObject, valid bool)
func (*ClassInstance) GetPropertySetter ¶ added in v0.0.2
func (o *ClassInstance) GetPropertySetter(name string, typ ObjectType) (handler CallerObject, valid bool)
func (*ClassInstance) IndexGet ¶ added in v0.0.2
func (o *ClassInstance) IndexGet(vm *VM, index Object) (Object, error)
IndexGet implements Object interface.
func (*ClassInstance) IndexSet ¶ added in v0.0.2
func (o *ClassInstance) IndexSet(vm *VM, index, value Object) (err error)
IndexSet implements Object interface.
func (*ClassInstance) Init ¶ added in v0.0.2
func (o *ClassInstance) Init(vm *VM, fields Dict) (err error)
func (*ClassInstance) Instances ¶ added in v0.0.2
func (o *ClassInstance) Instances() func(yield func(instance *ClassInstance) bool)
func (*ClassInstance) IsFalsy ¶ added in v0.0.2
func (o *ClassInstance) IsFalsy() bool
IsFalsy implements Object interface.
func (*ClassInstance) Items ¶ added in v0.0.2
func (o *ClassInstance) Items(vm *VM, cb ItemsGetterCallback) (err error)
func (*ClassInstance) Keys ¶ added in v0.0.2
func (o *ClassInstance) Keys() Array
func (*ClassInstance) Methods ¶ added in v0.0.2
func (o *ClassInstance) Methods() *IndexGetProxy
func (*ClassInstance) Name ¶ added in v0.0.2
func (o *ClassInstance) Name() string
func (*ClassInstance) Parent ¶ added in v0.0.2
func (o *ClassInstance) Parent(name string) *ClassInstance
func (*ClassInstance) Parents ¶ added in v0.0.2
func (o *ClassInstance) Parents() (d Dict)
func (*ClassInstance) Print ¶ added in v0.0.2
func (o *ClassInstance) Print(state *PrinterState) error
func (*ClassInstance) ReprTypeName ¶ added in v0.0.2
func (o *ClassInstance) ReprTypeName() string
func (*ClassInstance) ResolveField ¶ added in v0.0.2
func (o *ClassInstance) ResolveField(name string) (inst *ClassInstance)
func (*ClassInstance) ResolveMethod ¶ added in v0.0.2
func (o *ClassInstance) ResolveMethod(name string) (inst *ClassInstance, m *ClassMethod)
func (*ClassInstance) ResolveProperty ¶ added in v0.0.2
func (o *ClassInstance) ResolveProperty(name string) (inst *ClassInstance, p *ClassProperty)
func (*ClassInstance) SetFieldValue ¶ added in v0.0.2
func (o *ClassInstance) SetFieldValue(vm *VM, name string, value Object) error
func (*ClassInstance) ToDict ¶ added in v0.0.2
func (o *ClassInstance) ToDict() (d Dict)
func (*ClassInstance) ToString ¶ added in v0.0.2
func (o *ClassInstance) ToString() string
func (*ClassInstance) Type ¶ added in v0.0.2
func (o *ClassInstance) Type() ObjectType
func (*ClassInstance) Values ¶ added in v0.0.2
func (o *ClassInstance) Values() Array
func (*ClassInstance) WalkInstances ¶ added in v0.0.2
func (o *ClassInstance) WalkInstances(cb func(path []*ClassInstance, instance *ClassInstance) (mode utils.WalkMode))
func (*ClassInstance) WalkProperty ¶ added in v0.0.2
func (o *ClassInstance) WalkProperty(name string, f func(inst *ClassInstance, p *ClassProperty) (next bool))
type ClassInstanceMethod ¶ added in v0.0.2
type ClassInstanceMethod struct {
// contains filtered or unexported fields
}
ClassInstanceMethod is a ClassMethod bound to a receiver instance. Calling it prepends `this` to the arguments and dispatches to the method's typed overloads.
func (*ClassInstanceMethod) Call ¶ added in v0.0.2
func (m *ClassInstanceMethod) Call(c Call) (Object, error)
func (*ClassInstanceMethod) Equal ¶ added in v0.0.2
func (m *ClassInstanceMethod) Equal(right Object) bool
func (*ClassInstanceMethod) FullName ¶ added in v0.0.2
func (m *ClassInstanceMethod) FullName() string
func (*ClassInstanceMethod) FuncSpecName ¶ added in v0.0.2
func (m *ClassInstanceMethod) FuncSpecName() string
func (*ClassInstanceMethod) IsFalsy ¶ added in v0.0.2
func (m *ClassInstanceMethod) IsFalsy() bool
func (*ClassInstanceMethod) Name ¶ added in v0.0.2
func (m *ClassInstanceMethod) Name() string
func (*ClassInstanceMethod) Print ¶ added in v0.0.2
func (m *ClassInstanceMethod) Print(state *PrinterState) (err error)
func (*ClassInstanceMethod) String ¶ added in v0.0.2
func (m *ClassInstanceMethod) String() string
func (*ClassInstanceMethod) ToString ¶ added in v0.0.2
func (m *ClassInstanceMethod) ToString() string
func (*ClassInstanceMethod) Type ¶ added in v0.0.2
func (m *ClassInstanceMethod) Type() ObjectType
type ClassInstancePropertyGetter ¶ added in v0.0.2
type ClassInstancePropertyGetter struct {
// contains filtered or unexported fields
}
ClassInstancePropertyGetter is a ClassProperty's getter bound to a receiver instance. h is the resolved zero-arg `(this)` getter overload; calling the getter (or indexing into it) invokes h with `this`.
func (*ClassInstancePropertyGetter) Call ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) Call(c Call) (Object, error)
func (*ClassInstancePropertyGetter) Equal ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) Equal(right Object) bool
func (*ClassInstancePropertyGetter) IndexGet ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) IndexGet(vm *VM, index Object) (value Object, err error)
func (*ClassInstancePropertyGetter) IsFalsy ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) IsFalsy() bool
func (*ClassInstancePropertyGetter) Name ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) Name() string
func (*ClassInstancePropertyGetter) Print ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) Print(state *PrinterState) (err error)
func (*ClassInstancePropertyGetter) String ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) String() string
func (*ClassInstancePropertyGetter) ToString ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) ToString() string
func (*ClassInstancePropertyGetter) Type ¶ added in v0.0.2
func (m *ClassInstancePropertyGetter) Type() ObjectType
type ClassInstancePropertySetter ¶ added in v0.0.2
type ClassInstancePropertySetter struct {
// contains filtered or unexported fields
}
ClassInstancePropertySetter is a ClassProperty's setter bound to a receiver instance. Its Set method dispatches to the matching `(this, value)` setter overload, using vm for the call.
func (*ClassInstancePropertySetter) Equal ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) Equal(right Object) bool
func (*ClassInstancePropertySetter) IndexGet ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) IndexGet(vm *VM, index Object) (value Object, err error)
func (*ClassInstancePropertySetter) IsFalsy ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) IsFalsy() bool
func (*ClassInstancePropertySetter) Name ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) Name() string
func (*ClassInstancePropertySetter) Print ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) Print(state *PrinterState) (err error)
func (*ClassInstancePropertySetter) Set ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) Set(v Object) (err error)
func (*ClassInstancePropertySetter) String ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) String() string
func (*ClassInstancePropertySetter) ToString ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) ToString() string
func (*ClassInstancePropertySetter) Type ¶ added in v0.0.2
func (m *ClassInstancePropertySetter) Type() ObjectType
type ClassMethod ¶ added in v0.0.2
type ClassMethod struct {
// contains filtered or unexported fields
}
ClassMethod is a named method of a Class: a callable FuncSpec that may carry several typed overloads. On an instance it is bound as a ClassInstanceMethod (with `this` prepended).
func NewClassMethod ¶ added in v0.0.2
func NewClassMethod(name string, class *Class) *ClassMethod
func (*ClassMethod) AddMethodByTypes ¶ added in v0.0.2
func (m *ClassMethod) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(method *TypedCallerMethod) error) error
func (*ClassMethod) Equal ¶ added in v0.0.2
func (m *ClassMethod) Equal(right Object) bool
func (*ClassMethod) FullName ¶ added in v0.0.2
func (m *ClassMethod) FullName() string
func (*ClassMethod) FuncSpecName ¶ added in v0.0.2
func (m *ClassMethod) FuncSpecName() string
func (*ClassMethod) GetFuncSpec ¶ added in v0.0.2
func (m *ClassMethod) GetFuncSpec() *FuncSpec
GetFuncSpec exposes the method's dispatcher so helpers such as gad.methodFromArgs can resolve a registered method by argument types.
func (*ClassMethod) IsFalsy ¶ added in v0.0.2
func (m *ClassMethod) IsFalsy() bool
func (*ClassMethod) Name ¶ added in v0.0.2
func (m *ClassMethod) Name() string
func (*ClassMethod) NewInstance ¶ added in v0.0.2
func (m *ClassMethod) NewInstance(this *ClassInstance) *ClassInstanceMethod
func (*ClassMethod) Print ¶ added in v0.0.2
func (m *ClassMethod) Print(state *PrinterState) (err error)
func (*ClassMethod) ReprTypeName ¶ added in v0.0.2
func (m *ClassMethod) ReprTypeName() string
func (*ClassMethod) String ¶ added in v0.0.2
func (m *ClassMethod) String() string
func (*ClassMethod) ToString ¶ added in v0.0.2
func (m *ClassMethod) ToString() string
func (*ClassMethod) Type ¶ added in v0.0.2
func (m *ClassMethod) Type() ObjectType
type ClassParent ¶ added in v0.0.2
ClassParent is one entry in a class's inheritance list: a parent Class and the Alias under which its members are reachable (defaults to the parent's name).
type ClassProperty ¶ added in v0.0.2
type ClassProperty struct {
// contains filtered or unexported fields
}
ClassProperty is a computed property of a Class (declared with `prop`): a named getter/setter backed by a FuncSpec, whose overloads distinguish the zero-arg getter `(this)` from the typed setters `(this, value)`.
func NewClassProperty ¶ added in v0.0.2
func NewClassProperty(class *Class, name string) *ClassProperty
NewClassProperty returns an empty property named name on class, ready for getter/setter overloads to be added to its FuncSpec.
func (*ClassProperty) Add ¶ added in v0.0.2
func (p *ClassProperty) Add(handler CallerObject, argTypes ParamsTypes) (err error)
func (*ClassProperty) AddGetter ¶ added in v0.0.2
func (p *ClassProperty) AddGetter(v Object, thisType ParamTypes, override bool, onAdd func(method *TypedCallerMethod) error) (err error)
func (*ClassProperty) AddMethodByTypes ¶ added in v0.0.2
func (p *ClassProperty) AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(method *TypedCallerMethod) error) error
func (*ClassProperty) AddSetter ¶ added in v0.0.2
func (p *ClassProperty) AddSetter(v Object, thisType, valueType ParamTypes, override bool, onAdd func(method *TypedCallerMethod) error) (err error)
func (*ClassProperty) Call ¶ added in v0.0.2
func (p *ClassProperty) Call(c Call) (Object, error)
Call dispatches to the matching getter or setter.
func (*ClassProperty) CallerMethodDefault ¶ added in v0.0.2
func (p *ClassProperty) CallerMethodDefault() CallerObject
CallerMethodDefault returns the accessor default caller, if any.
func (*ClassProperty) CallerMethodOfArgsTypes ¶ added in v0.0.2
func (p *ClassProperty) CallerMethodOfArgsTypes(types ObjectTypeArray) CallerObject
CallerMethodOfArgsTypes resolves an accessor from argument types.
func (*ClassProperty) CallerMethodWithValidationCheckOfArgs ¶ added in v0.0.2
func (p *ClassProperty) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
CallerMethodWithValidationCheckOfArgs resolves an accessor from args.
func (*ClassProperty) CallerMethodWithValidationCheckOfArgsTypes ¶ added in v0.0.2
func (p *ClassProperty) CallerMethodWithValidationCheckOfArgsTypes(types ObjectTypeArray) (CallerObject, bool)
CallerMethodWithValidationCheckOfArgsTypes resolves an accessor from argument types.
func (*ClassProperty) CallerMethods ¶ added in v0.0.2
func (p *ClassProperty) CallerMethods() *MethodArgType
CallerMethods returns the getter/setter method tree.
func (ClassProperty) Clone ¶ added in v0.0.2
func (p ClassProperty) Clone() *ClassProperty
func (*ClassProperty) Equal ¶ added in v0.0.2
func (p *ClassProperty) Equal(right Object) bool
func (*ClassProperty) FullName ¶ added in v0.0.2
func (p *ClassProperty) FullName() string
func (*ClassProperty) FuncSpecName ¶ added in v0.0.2
func (p *ClassProperty) FuncSpecName() string
func (*ClassProperty) GetFuncSpec ¶ added in v0.0.2
func (p *ClassProperty) GetFuncSpec() *FuncSpec
GetFuncSpec exposes the property's getter/setter dispatcher so helpers such as gad.methodFromArgs can resolve a registered accessor by argument types.
func (*ClassProperty) GetModule ¶ added in v0.0.2
func (p *ClassProperty) GetModule() *ModuleSpec
func (*ClassProperty) HasCallerMethods ¶ added in v0.0.2
func (p *ClassProperty) HasCallerMethods() bool
HasCallerMethods reports whether any getter/setter is registered.
func (*ClassProperty) IsFalsy ¶ added in v0.0.2
func (p *ClassProperty) IsFalsy() bool
func (*ClassProperty) Name ¶ added in v0.0.2
func (p *ClassProperty) Name() string
func (*ClassProperty) NewGetter ¶ added in v0.0.2
func (p *ClassProperty) NewGetter(this *ClassInstance) *ClassInstancePropertyGetter
func (*ClassProperty) NewSetter ¶ added in v0.0.2
func (p *ClassProperty) NewSetter(vm *VM, this *ClassInstance) *ClassInstancePropertySetter
func (*ClassProperty) Print ¶ added in v0.0.2
func (p *ClassProperty) Print(state *PrinterState) (err error)
func (*ClassProperty) ReprTypeName ¶ added in v0.0.2
func (p *ClassProperty) ReprTypeName() string
func (*ClassProperty) String ¶ added in v0.0.2
func (p *ClassProperty) String() string
func (*ClassProperty) ToString ¶ added in v0.0.2
func (p *ClassProperty) ToString() string
func (*ClassProperty) Type ¶ added in v0.0.2
func (p *ClassProperty) Type() ObjectType
type CollectableIterator ¶
type CompilableImporter ¶
type CompilableImporter interface {
Importable
CompileModule(compiler *Compiler, nd ast.Node, module *ModuleSpec, 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 {
FuncName string
AllowMethods bool
// number of local variabls including parameters NumLocals>=NumParams
NumLocals int
Instructions []byte
Free []*ObjectPtr
Return *ObjectPtr
// SourceMap holds the index of instruction and token's position.
SourceMap map[int]int
Params Params
NamedParams NamedParams
ReturnVars ReturnVars
// NamedParamsMap is a map of NamedParams with index
// this value allow to perform named args validation.
NamedParamsMap map[string]int
// LocalNames holds debug names for local slots (slot index -> name), used by
// the debugger to label locals. It is populated by the compiler and may be
// nil (e.g. for hand-built functions); it round-trips through the encoder.
LocalNames []string
// contains filtered or unexported fields
}
CompiledFunction holds the constants and instructions to pass VM.
func (*CompiledFunction) CanValidateParamTypes ¶
func (o *CompiledFunction) CanValidateParamTypes() bool
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(builtins *Builtins, w io.Writer, bc *Bytecode)
Fprint writes constants and instructions to given Writer in a human readable form.
func (*CompiledFunction) FprintLP ¶
func (o *CompiledFunction) FprintLP(builtins *Builtins, constants Array, linePrefix string, w io.Writer)
FprintLP writes constants and instructions to given Writer in a human readable form with line prefix.
func (*CompiledFunction) FullName ¶ added in v0.0.2
func (o *CompiledFunction) FullName() string
func (*CompiledFunction) GetModule ¶ added in v0.0.2
func (o *CompiledFunction) GetModule() *ModuleSpec
func (*CompiledFunction) GetReturnVars ¶ added in v0.0.2
func (o *CompiledFunction) GetReturnVars() ReturnVars
func (*CompiledFunction) HasStructuralParamTypes ¶ added in v0.0.2
func (o *CompiledFunction) HasStructuralParamTypes() bool
HasStructuralParamTypes reports whether any parameter is typed by a structural type literal (meti/interface), i.e. a type symbol resolved from a bytecode constant (ScopeConstant). Such params cannot be matched by identity in the dispatch tree, so a match against them must always be validated by value.
func (*CompiledFunction) HeaderString ¶ added in v0.0.2
func (o *CompiledFunction) HeaderString() string
func (*CompiledFunction) IsFalsy ¶
func (*CompiledFunction) IsFalsy() bool
IsFalsy implements Object interface.
func (*CompiledFunction) Name ¶
func (o *CompiledFunction) Name() string
func (*CompiledFunction) ParamTypes ¶
func (o *CompiledFunction) ParamTypes(vm *VM) (types ParamsTypes, err error)
func (*CompiledFunction) Print ¶ added in v0.0.2
func (o *CompiledFunction) Print(state *PrinterState) error
func (*CompiledFunction) SetModule ¶ added in v0.0.2
func (o *CompiledFunction) SetModule(m *ModuleSpec)
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) WithNamedParams ¶ added in v0.0.2
func (o *CompiledFunction) WithNamedParams(names ...string) *CompiledFunction
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(st *SymbolTable, module *ModuleSpec, file *source.File, opts CompileOptions) *Compiler
NewCompiler creates a new Compiler object.
func (*Compiler) BaseEmbedMap ¶
func (c *Compiler) BaseEmbedMap() *EmbeddedMap
func (*Compiler) BaseModuleMap ¶
func (*Compiler) CompileModule ¶
func (c *Compiler) CompileModule(nd *ModuleStmt) (err error)
func (*Compiler) Options ¶ added in v0.0.2
func (c *Compiler) Options() *CompileOptions
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
EmbededdMap *EmbeddedMap
ModuleMap *ModuleMap
ModuleFile string
Constants []Object
Trace io.Writer
TraceParser bool
TraceCompiler bool
TraceOptimizer bool
OptimizerMaxCycle int
OptimizeConst bool
OptimizeExpr bool
MixedWriteFunction node.Expr
MixedExprToTextFunc node.Expr
FallbackFunc func(c *Compiler, nd ast.Node) error
// contains filtered or unexported fields
}
CompilerOptions represents customizable options for Compile().
type ComputedValue ¶ added in v0.0.2
type ComputedValue struct {
CallerObject CallerObject
}
func (*ComputedValue) Equal ¶ added in v0.0.2
func (v *ComputedValue) Equal(right Object) bool
func (*ComputedValue) IsFalsy ¶ added in v0.0.2
func (v *ComputedValue) IsFalsy() bool
func (*ComputedValue) Name ¶ added in v0.0.2
func (v *ComputedValue) Name() string
func (*ComputedValue) Print ¶ added in v0.0.2
func (v *ComputedValue) Print(state *PrinterState) error
func (*ComputedValue) ReprTypeName ¶ added in v0.0.2
func (v *ComputedValue) ReprTypeName() string
func (*ComputedValue) String ¶ added in v0.0.2
func (v *ComputedValue) String() string
func (*ComputedValue) ToString ¶ added in v0.0.2
func (v *ComputedValue) ToString() string
func (ComputedValue) Type ¶ added in v0.0.2
func (ComputedValue) Type() ObjectType
type DebugFrame ¶ added in v0.0.2
DebugFrame describes one active call frame for the debugger's stack view, including that frame's local values and their debug names.
type DebugStepper ¶ added in v0.0.2
type DebugStepper interface {
// Step is called with the VM positioned at the instruction about to run.
Step(vm *VM)
}
DebugStepper is invoked before each instruction executes when the VM runs in debug mode (see VM.SetDebugger). Implementations typically block inside Step to pause execution (breakpoints, single-stepping) and inspect state through the VM's Debug* accessors.
The debug execution loop (loopDebug) is generated from the production loop by cmd/update-delve, so the two never drift; the production loop has no per-instruction hook and is unaffected.
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) BinOpGreater ¶ added in v0.0.2
func (Decimal) BinOpGreaterEq ¶ added in v0.0.2
func (Decimal) BinOpLessEq ¶ added in v0.0.2
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 Base64Module ¶ added in v0.0.2
func Base64Module() Dict
Base64Module returns the `base64` builtin namespace. It is shared (not copied) and is also used by the stdlib `encoding/base64` importable module.
func ConvertToDict ¶
ConvertToDict convert objects to Dict. If success return then, otherwise return error.
func FmtModule ¶ added in v0.0.2
func FmtModule() Dict
FmtModule returns the `fmt` builtin namespace (Print/Printf/Sprint/Scan…). It is also used by the stdlib `fmt` importable module.
func GadModule ¶ added in v0.0.2
func GadModule() Dict
GadModule returns the `gad` builtin namespace (the operator functions).
func MustConvertToDict ¶
MustConvertToDict convert objects to Dict and return then if success, otherwise panics.
func StringsModule ¶ added in v0.0.2
func StringsModule() Dict
StringsModule returns the `strings` builtin namespace. It is also used by the stdlib `strings` importable module.
func TimeModule ¶ added in v0.0.2
func TimeModule() Dict
TimeModule returns the `time` builtin namespace. It is also used by the stdlib `time` importable module.
func (Dict) BinOpAdd ¶ added in v0.0.2
BinOpAdd merges right's entries into the dict (ObjectWithAddBinOperator).
func (Dict) BinOpGreater ¶ added in v0.0.2
func (Dict) BinOpGreaterEq ¶ added in v0.0.2
func (Dict) BinOpIn ¶ added in v0.0.2
Contains reports whether v is a key of the dict (`v in dict`). BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v is a key of o.
func (Dict) BinOpLessEq ¶ added in v0.0.2
func (Dict) BinOpSub ¶ added in v0.0.2
BinOpSub removes the keys in right from the dict (ObjectWithSubBinOperator).
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) PrintObject ¶ added in v0.0.2
func (o Dict) PrintObject(state *PrinterState, dot Object) (err error)
func (Dict) SortedKeys ¶
func (Dict) ToInterface ¶
func (Dict) ToKeyValueArray ¶ added in v0.0.2
func (o Dict) ToKeyValueArray() (arr KeyValueArray)
func (Dict) ToNamedArgs ¶
func (Dict) Type ¶
func (o Dict) Type() ObjectType
func (Dict) UpdateIndexSetter ¶ added in v0.0.2
func (o Dict) UpdateIndexSetter(out StringIndexSetter)
type Duration ¶ added in v0.0.2
Duration is a span of time with nanosecond precision; it mirrors Go's time.Duration and is one of the time module's value types.
func (Duration) BinOpAdd ¶ added in v0.0.2
BinaryOp supports duration arithmetic and comparison:
- `duration ± duration` -> duration
- `duration * int` -> duration (scale)
- `duration / int` -> duration (scale)
- `duration / duration` -> float (ratio)
- `duration % int|duration` -> duration (remainder)
- ordered comparisons -> bool
The operators accept a Duration or an Int (taken as a nanosecond count).
func (Duration) BinOpGreater ¶ added in v0.0.2
func (Duration) BinOpGreaterEq ¶ added in v0.0.2
func (Duration) BinOpLessEq ¶ added in v0.0.2
func (Duration) CallName ¶ added in v0.0.2
CallName dispatches the duration methods (Go time.Duration accessors).
func (Duration) Equal ¶ added in v0.0.2
Equal implements Object. A Duration equals another Duration or an int with the same nanosecond count.
func (Duration) MarshalJSON ¶ added in v0.0.2
MarshalJSON encodes the duration as a JSON string, e.g. "1h30m0s".
func (Duration) Print ¶ added in v0.0.2
func (o Duration) Print(s *PrinterState) error
Print writes the duration (Printabler); without it the printer's reflection fallback would recurse on this named-int Object.
func (Duration) ToString ¶ added in v0.0.2
ToString renders the duration like Go does, e.g. "1h30m0s".
func (Duration) Type ¶ added in v0.0.2
func (Duration) Type() ObjectType
type Embedded ¶ added in v0.0.2
type Embedded struct {
ReaderFactory EmbeddedReaderFactory
Name string
Entries map[string]*Embedded
Parent *Embedded
ModTime time.Time
Mode os.FileMode
AbsPath string
}
func (*Embedded) FS ¶ added in v0.0.2
func (n *Embedded) FS() (*EmbeddedNodeFS, error)
func (*Embedded) JoinToArray ¶ added in v0.0.2
func (*Embedded) Print ¶ added in v0.0.2
func (n *Embedded) Print(state *PrinterState) (err error)
func (*Embedded) SortedNames ¶ added in v0.0.2
func (*Embedded) Type ¶ added in v0.0.2
func (n *Embedded) Type() ObjectType
type EmbeddedBytesReaderFactory ¶ added in v0.0.2
type EmbeddedBytesReaderFactory []byte
func (EmbeddedBytesReaderFactory) Reader ¶ added in v0.0.2
func (b EmbeddedBytesReaderFactory) Reader(*Embedded) (io.ReadSeeker, error)
type EmbeddedExtImporter ¶ added in v0.0.2
type EmbeddedExtImporter interface {
EmbeddedImporter
// Get returns EmbeddedExtImporter instance which will import an embedded file.
Get(name string) EmbeddedExtImporter
// Paths returns the unique relative and absolute paths of embedded.
Paths() (relPath, absPath string, err error)
}
EmbeddedExtImporter wraps methods for a embedded which will be imported dynamically like a file.
type EmbeddedFile ¶ added in v0.0.2
type EmbeddedFile Embedded
EmbeddedFile is an importable embed that's written in Gad.
func (EmbeddedFile) Import ¶ added in v0.0.2
func (m EmbeddedFile) Import(_ context.Context, _, _ string, _ *EmbeddedImportOptions) (*Embedded, error)
type EmbeddedFileData ¶ added in v0.0.2
type EmbeddedFileData []byte
EmbeddedFileData is an importable embed for data that's written in Gad.
func (EmbeddedFileData) Import ¶ added in v0.0.2
func (m EmbeddedFileData) Import(_ context.Context, name, _ string, _ *EmbeddedImportOptions) (*Embedded, error)
type EmbeddedFileImporter ¶ added in v0.0.2
type EmbeddedFileImporter struct {
NameResolver func(cwd, name string) (string, error)
WorkDir string
FileReader func(string) (data []byte, uri string, err error)
}
EmbeddedFileImporter is an implemention of gad.ExtImporter to import files from file system. It uses absolute paths of module as import names.
type EmbeddedImportOptions ¶ added in v0.0.2
type EmbeddedImporter ¶ added in v0.0.2
type EmbeddedImporter interface {
// Import should return either an Object or module source code ([]byte).
Import(ctx context.Context, relPath string, absPath string, opts *EmbeddedImportOptions) (data *Embedded, err error)
}
EmbeddedImporter interface represents importable embedded instance.
type EmbeddedLimittedReaderFactory ¶ added in v0.0.2
func (*EmbeddedLimittedReaderFactory) Reader ¶ added in v0.0.2
func (b *EmbeddedLimittedReaderFactory) Reader(*Embedded) (io.ReadSeeker, error)
type EmbeddedMap ¶ added in v0.0.2
type EmbeddedMap struct {
// contains filtered or unexported fields
}
EmbeddedMap represents a set of named modules. Use NewEmbedMap to create a new module map.
func (*EmbeddedMap) Add ¶ added in v0.0.2
func (m *EmbeddedMap) Add(name string, module EmbeddedImporter) *EmbeddedMap
Add adds an importable module.
func (*EmbeddedMap) AddFile ¶ added in v0.0.2
func (m *EmbeddedMap) AddFile(path string, data []byte) *EmbeddedMap
AddFile adds a source file data.
func (*EmbeddedMap) Copy ¶ added in v0.0.2
func (m *EmbeddedMap) Copy() *EmbeddedMap
Copy creates a copy of the module map.
func (*EmbeddedMap) Get ¶ added in v0.0.2
func (m *EmbeddedMap) Get(name string) EmbeddedImporter
Get returns an import module identified by name. It returns nil if the name is not found.
func (*EmbeddedMap) Remove ¶ added in v0.0.2
func (m *EmbeddedMap) Remove(name string)
Remove removes a named module.
func (*EmbeddedMap) SetExtImporter ¶ added in v0.0.2
func (m *EmbeddedMap) SetExtImporter(im EmbeddedExtImporter) *EmbeddedMap
SetExtImporter sets an ExtImporter to EmbeddedMap, which will be used to embed path dynamically.
type EmbeddedNodeFS ¶ added in v0.0.2
type EmbeddedNodeFS struct {
// contains filtered or unexported fields
}
func (*EmbeddedNodeFS) Equal ¶ added in v0.0.2
func (e *EmbeddedNodeFS) Equal(right Object) bool
func (*EmbeddedNodeFS) IndexGet ¶ added in v0.0.2
func (e *EmbeddedNodeFS) IndexGet(_ *VM, index Object) (value Object, err error)
func (*EmbeddedNodeFS) IsFalsy ¶ added in v0.0.2
func (e *EmbeddedNodeFS) IsFalsy() bool
func (*EmbeddedNodeFS) Iterate ¶ added in v0.0.2
func (e *EmbeddedNodeFS) Iterate(_ *VM, na *NamedArgs) Iterator
func (*EmbeddedNodeFS) Print ¶ added in v0.0.2
func (e *EmbeddedNodeFS) Print(state *PrinterState) error
func (*EmbeddedNodeFS) ToDict ¶ added in v0.0.2
func (e *EmbeddedNodeFS) ToDict() (d Dict)
func (*EmbeddedNodeFS) ToString ¶ added in v0.0.2
func (e *EmbeddedNodeFS) ToString() string
func (*EmbeddedNodeFS) Type ¶ added in v0.0.2
func (e *EmbeddedNodeFS) Type() ObjectType
type EmbeddedOsFileReaderFactory ¶ added in v0.0.2
type EmbeddedOsFileReaderFactory struct{}
func (*EmbeddedOsFileReaderFactory) Reader ¶ added in v0.0.2
func (s *EmbeddedOsFileReaderFactory) Reader(e *Embedded) (io.ReadSeeker, error)
type EmbeddedReaderFactory ¶ added in v0.0.2
type EmbeddedReaderFactory interface {
Reader(e *Embedded) (io.ReadSeeker, error)
}
type Enum ¶ added in v0.0.2
type Enum struct {
EnumName string
Values map[string]*EnumValue
Module *ModuleSpec
}
Enum is an ordered, named set of integer constants produced by the `enum` syntax. It is also an ObjectType: each member is an EnumValue whose Type() is the owning Enum. An Enum is immutable after construction, indexable by member name and iterable in declaration order.
func NewEnum ¶ added in v0.0.2
func NewEnum(enumName string, module *ModuleSpec) *Enum
NewEnum returns an empty Enum; members are added in order with AddValue.
func (*Enum) AddValue ¶ added in v0.0.2
AddValue appends a member with the given name and underlying int/uint value. Its Index is the current member count, so members added in source order keep that order.
func (*Enum) GadObjectType ¶ added in v0.0.2
func (e *Enum) GadObjectType()
func (*Enum) GetModule ¶ added in v0.0.2
func (e *Enum) GetModule() *ModuleSpec
func (*Enum) Print ¶ added in v0.0.2
func (e *Enum) Print(state *PrinterState) error
func (*Enum) ReprTypeName ¶ added in v0.0.2
func (*Enum) SetModule ¶ added in v0.0.2
func (e *Enum) SetModule(m *ModuleSpec)
func (*Enum) Type ¶ added in v0.0.2
func (e *Enum) Type() ObjectType
type EnumValue ¶ added in v0.0.2
EnumValue is a single member of an Enum: its declaration Index, owning Enum, Name and the underlying Int/Uint Value. Its members are reachable from Gad as `.name`, `.value`, `.index` and `.enum`.
func (*EnumValue) IndexGet ¶ added in v0.0.2
IndexGet exposes the value's members: `name` (the field name), `value` (the underlying int/uint), `index` (declaration order) and `enum` (the owning Enum).
func (*EnumValue) Type ¶ added in v0.0.2
func (e *EnumValue) Type() ObjectType
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 NewEmbeddedPathIsDir ¶ added in v0.0.2
NewEmbeddedPathIsDir creates a new ErrEmbedded when path is directory
func NewEmbeddedPathIsNtDir ¶ added in v0.0.2
NewEmbeddedPathIsNtDir creates a new ErrEmbedded when path isn't a directory
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 NewStructPropertyInstanceError ¶ added in v0.0.2
NewStructPropertyInstanceError creates a new Error from ErrClassInstanceProperty.
func (*Error) NewError ¶
NewError creates a new Error and sets original Error as its cause which can be unwrapped.
func (*Error) NewErrorf ¶ added in v0.0.2
NewErrorf creates a new Error and sets original Error as its cause which can be unwrapped, using formatable message.
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 []*Module
// contains filtered or unexported fields
}
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(builtins *StaticBuiltins, st *SymbolTable, opts CompileOptions, runOpts ...*RunOpts) *Eval
NewEval returns new Eval object.
func (*Eval) RunScript ¶ added in v0.0.2
func (r *Eval) RunScript(ctx context.Context, script []byte) (ret Object, bytecode *Bytecode, err error)
RunScript compiles, runs given script and returns last value on stack.
func (*Eval) SymbolTable ¶ added in v0.0.2
func (r *Eval) SymbolTable() *SymbolTable
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) BinOpAndNot ¶ added in v0.0.2
func (Flag) BinOpGreater ¶ added in v0.0.2
func (Flag) BinOpGreaterEq ¶ added in v0.0.2
func (Flag) BinOpLessEq ¶ added in v0.0.2
func (Flag) Type ¶
func (o Flag) Type() ObjectType
type Float ¶
type Float float64
Float represents float values and implements Object interface.
func (Float) BinOpGreater ¶ added in v0.0.2
func (Float) BinOpGreaterEq ¶ added in v0.0.2
func (Float) BinOpLessEq ¶ added in v0.0.2
func (Float) Type ¶
func (o Float) Type() ObjectType
type FmtScanArg ¶ added in v0.0.2
type FmtScanArg interface {
// Set sets status of scanning. It is set false before scanning and true
// after scanning if argument is scanned.
Set(bool)
// Arg must return either a pointer to a basic ToInterface type or implementations of
// fmt.Scanner interface.
Arg() any
// Value must return scanned, non-nil Gad Object.
Value() Object
}
FmtScanArg is an interface that wraps methods required to scan argument with scan functions.
type Func ¶ added in v0.0.2
type Func struct {
*FuncSpec
// contains filtered or unexported fields
}
func NewFunc ¶ added in v0.0.2
func NewFunc(name string, module *ModuleSpec) *Func
func (*Func) FuncSpecName ¶ added in v0.0.2
func (*Func) GetModule ¶ added in v0.0.2
func (f *Func) GetModule() *ModuleSpec
func (*Func) Print ¶ added in v0.0.2
func (f *Func) Print(state *PrinterState) (err error)
func (*Func) Type ¶ added in v0.0.2
func (f *Func) Type() ObjectType
type FuncHeaderObject ¶ added in v0.0.2
type FuncHeaderObject struct {
FuncName string
Params Array // of *TypedIdent
NamedParams Array // of *TypedIdent
Return Array // of *TypedIdent
// Module is the module the header was compiled in, used to render a
// module-qualified FullName. Set from *Compiler.module when a func-header
// value is compiled to a constant; nil for values built at run time.
Module *ModuleSpec
}
FuncHeaderObject is a function signature value (see TFunctionHeader).
func (*FuncHeaderObject) Equal ¶ added in v0.0.2
func (h *FuncHeaderObject) Equal(right Object) bool
func (*FuncHeaderObject) FullName ¶ added in v0.0.2
func (h *FuncHeaderObject) FullName() string
FullName is the header name qualified by its module, e.g. `mod.f`, or just the name when there is no (or an unnamed) module. An anonymous header (no name) has no FullName.
func (*FuncHeaderObject) IndexGet ¶ added in v0.0.2
func (h *FuncHeaderObject) IndexGet(_ *VM, index Object) (Object, error)
IndexGet exposes name, params, namedParams and return.
func (*FuncHeaderObject) IsFalsy ¶ added in v0.0.2
func (h *FuncHeaderObject) IsFalsy() bool
func (*FuncHeaderObject) Name ¶ added in v0.0.2
func (h *FuncHeaderObject) Name() string
func (*FuncHeaderObject) String ¶ added in v0.0.2
func (h *FuncHeaderObject) String() string
func (*FuncHeaderObject) ToString ¶ added in v0.0.2
func (h *FuncHeaderObject) ToString() string
func (*FuncHeaderObject) Type ¶ added in v0.0.2
func (h *FuncHeaderObject) Type() ObjectType
type FuncSpec ¶ added in v0.0.2
type FuncSpec struct {
Methods MethodArgType
// contains filtered or unexported fields
}
func NewFuncSpec ¶ added in v0.0.2
func NewFuncSpec(this FuncWrapper, opt ...FuncSpecOption) *FuncSpec
func (*FuncSpec) AddMethod ¶ added in v0.0.2
func (s *FuncSpec) AddMethod(vm *VM, handler CallerObject, override bool, onAdd func(tcm *TypedCallerMethod) error) error
AddMethod Add caller method.
func (*FuncSpec) AddMethodByTypes ¶ added in v0.0.2
func (s *FuncSpec) AddMethodByTypes(_ *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(tcm *TypedCallerMethod) error) error
func (*FuncSpec) CallerMethodDefault ¶ added in v0.0.2
func (s *FuncSpec) CallerMethodDefault() CallerObject
func (*FuncSpec) CallerMethodOfArgsTypes ¶ added in v0.0.2
func (s *FuncSpec) CallerMethodOfArgsTypes(types ObjectTypeArray) (co CallerObject)
func (*FuncSpec) CallerMethodWithValidationCheckOfArgs ¶ added in v0.0.2
func (s *FuncSpec) CallerMethodWithValidationCheckOfArgs(args Args) (CallerObject, bool)
func (*FuncSpec) CallerMethodWithValidationCheckOfArgsTypes ¶ added in v0.0.2
func (s *FuncSpec) CallerMethodWithValidationCheckOfArgsTypes(types ObjectTypeArray) (co CallerObject, validate bool)
func (*FuncSpec) CallerMethods ¶ added in v0.0.2
func (s *FuncSpec) CallerMethods() *MethodArgType
func (FuncSpec) CopyWithTarget ¶ added in v0.0.2
func (s FuncSpec) CopyWithTarget(target FuncWrapper) *FuncSpec
func (*FuncSpec) GetFuncSpec ¶ added in v0.0.2
func (*FuncSpec) HasCallerMethods ¶ added in v0.0.2
func (*FuncSpec) MethodOrDefault ¶ added in v0.0.2
func (s *FuncSpec) MethodOrDefault(types ObjectTypeArray) (method *TypedCallerMethod, defaul CallerObject)
func (*FuncSpec) PrintFuncWrapper ¶ added in v0.0.2
func (s *FuncSpec) PrintFuncWrapper(state *PrinterState, fo FuncWrapper) (err error)
type FuncSpecOption ¶ added in v0.0.2
type FuncSpecOption func(spec *FuncSpec)
func FuncSpectWithDefault ¶ added in v0.0.2
func FuncSpectWithDefault(co CallerObject) FuncSpecOption
type FuncWrapper ¶ added in v0.0.2
type Function ¶
type Function struct {
ObjectImpl
// FuncName is the function's (unqualified) name, used in repr and errors.
FuncName string
// Usage is optional Markdown documentation shown by Doc().
Usage string
// Value is the Go handler invoked on each call.
Value func(Call) (Object, error)
// ToStringFunc, when set, overrides the default ToString rendering.
ToStringFunc func() string
// Header declares the parameter signature (names/types); it drives argument
// dispatch and appears in repr. Set it via WithParams/WithParamsPairs.
Header *FunctionHeader
// Module qualifies the function's name (e.g. mod.greet) and scopes it to a
// builtin namespace; set with WithModule.
Module *ModuleSpec
// contains filtered or unexported fields
}
Function is a Go-implemented callable value: it wraps a Value handler behind the Object/CallerObject interfaces so native Go code can be exposed to Gad scripts. Build one with NewFunction and the fluent With* options rather than populating the fields directly:
fn := NewFunction("greet", func(c Call) (Object, error) { … }).
WithModule(mod).WithParamsPairs("name", TStr)
func NewFunction ¶ added in v0.0.2
func (*Function) GetModule ¶ added in v0.0.2
func (f *Function) GetModule() *ModuleSpec
func (*Function) ParamTypes ¶ added in v0.0.2
func (f *Function) ParamTypes() (types ParamsTypes)
func (*Function) ReturnVars ¶ added in v0.0.2
func (f *Function) ReturnVars() ReturnVars
func (*Function) SetModule ¶ added in v0.0.2
func (f *Function) SetModule(m *ModuleSpec)
func (*Function) Type ¶
func (*Function) Type() ObjectType
func (*Function) WithHeader ¶ added in v0.0.2
func (f *Function) WithHeader(do func(h *FunctionHeader)) *Function
func (*Function) WithOption ¶ added in v0.0.2
func (f *Function) WithOption(opt ...FunctionOption) *Function
func (*Function) WithParams ¶ added in v0.0.2
func (f *Function) WithParams(builder func(newParam func(name string) *ParamBuilder)) *Function
func (*Function) WithParamsPairs ¶ added in v0.0.2
type FunctionHeader ¶
type FunctionHeader struct {
Params Params
NamedParams NamedParams
ReturnVars ReturnVars
// contains filtered or unexported fields
}
func NewFunctionHeader ¶ added in v0.0.2
func NewFunctionHeader() *FunctionHeader
func (*FunctionHeader) ParamTypes ¶
func (h *FunctionHeader) ParamTypes() ParamsTypes
func (*FunctionHeader) String ¶
func (h *FunctionHeader) String() string
func (*FunctionHeader) WithNamedParams ¶ added in v0.0.2
func (h *FunctionHeader) WithNamedParams(builder func(newParam func(name string) *NamedParamBuilder)) *FunctionHeader
func (*FunctionHeader) WithParams ¶ added in v0.0.2
func (h *FunctionHeader) WithParams(builder func(newParam func(name string) *ParamBuilder)) *FunctionHeader
func (*FunctionHeader) WithReturnVars ¶ added in v0.0.2
func (h *FunctionHeader) WithReturnVars(builder func(ret func(name string, typ ...ObjectType))) *FunctionHeader
type FunctionHeaderParam ¶
type FunctionHeaderParam struct {
Name string
Types []ObjectType
Value string
}
func (*FunctionHeaderParam) String ¶
func (p *FunctionHeaderParam) String() string
type FunctionOption ¶ added in v0.0.2
type FunctionOption func(f *Function)
func FunctionWithModule ¶ added in v0.0.2
func FunctionWithModule(spec *ModuleSpec) FunctionOption
func FunctionWithNamedParams ¶ added in v0.0.2
func FunctionWithNamedParams(builder func(newParam func(name string) *NamedParamBuilder)) FunctionOption
func FunctionWithParams ¶ added in v0.0.2
func FunctionWithParams(builder func(newParam func(name string) *ParamBuilder)) FunctionOption
func FunctionWithUsage ¶ added in v0.0.2
func FunctionWithUsage(usage string) FunctionOption
type Importable ¶
type Importable interface {
// Import should return either an Object or module source code ([]byte).
Import(ctx context.Context, module *ModuleSpec) (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
}
func (*IndexDeleteProxy) BinOpAdd ¶ added in v0.0.2
func (o *IndexDeleteProxy) BinOpAdd(vm *VM, right Object) (Object, error)
BinaryOp implements Object interface. BinOpAdd merges an iterable via the proxied index setter.
func (*IndexDeleteProxy) BinOpGreater ¶ added in v0.0.2
func (o *IndexDeleteProxy) BinOpGreater(_ *VM, right Object) (Object, error)
func (*IndexDeleteProxy) BinOpGreaterEq ¶ added in v0.0.2
func (o *IndexDeleteProxy) BinOpGreaterEq(_ *VM, right Object) (Object, error)
func (*IndexDeleteProxy) BinOpLess ¶ added in v0.0.2
func (o *IndexDeleteProxy) BinOpLess(_ *VM, right Object) (Object, error)
func (*IndexDeleteProxy) BinOpLessEq ¶ added in v0.0.2
func (o *IndexDeleteProxy) BinOpLessEq(_ *VM, right Object) (Object, error)
type IndexDeleter ¶
IndexDeleter wraps the IndexDelete method to delete an index of an object.
type IndexGetProxy ¶
type IndexGetProxy struct {
GetIndexFunc func(vm *VM, index Object) (value Object, err error)
ToStrFunc func() string
PrintFunc func(s *PrinterState) error
IterateFunc func(vm *VM, na *NamedArgs) Iterator
InterfaceValue any
CallNameFunc 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) Print ¶ added in v0.0.2
func (i *IndexGetProxy) Print(state *PrinterState) error
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 IndexMethodAdder ¶ added in v0.0.2
type IndexMethodGetter ¶ added in v0.0.2
type IndexProxy ¶
type IndexProxy struct {
IndexGetProxy
IndexSetProxy
}
func (*IndexProxy) BinOpAdd ¶ added in v0.0.2
func (o *IndexProxy) BinOpAdd(vm *VM, right Object) (Object, error)
BinOpAdd merges an iterable's entries via the proxied index setter; the comparison operators order the proxy after nil.
func (*IndexProxy) BinOpGreater ¶ added in v0.0.2
func (o *IndexProxy) BinOpGreater(_ *VM, right Object) (Object, error)
func (*IndexProxy) BinOpGreaterEq ¶ added in v0.0.2
func (o *IndexProxy) BinOpGreaterEq(_ *VM, right Object) (Object, error)
func (*IndexProxy) BinOpLess ¶ added in v0.0.2
func (o *IndexProxy) BinOpLess(_ *VM, right Object) (Object, error)
func (*IndexProxy) BinOpLessEq ¶ added in v0.0.2
func (o *IndexProxy) BinOpLessEq(_ *VM, right Object) (Object, error)
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 IndexSetterUpdater ¶ added in v0.0.2
type IndexSetterUpdater interface {
UpdateIndexSetter(out StringIndexSetter)
}
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) BinOpAndNot ¶ added in v0.0.2
func (Int) BinOpGreater ¶ added in v0.0.2
func (Int) BinOpGreaterEq ¶ added in v0.0.2
func (Int) BinOpLessEq ¶ added in v0.0.2
func (Int) Type ¶
func (o Int) Type() ObjectType
type Interface ¶ added in v0.0.2
type Interface struct {
IName string
Module *ModuleSpec // module the interface was compiled in (for FullName)
Extends ParamType // parent interface symbol refs (from `extends { … }`)
Fields []*InterfaceField // typed fields
Props []*InterfaceProp // getter/setter properties
Methods []*InterfaceMethod
}
Interface is the value of an `interface { … }` (see TInterface).
func (*Interface) AssignTo ¶ added in v0.0.2
AssignTo makes *Interface a TypeAssigner: obj is assignable to the interface `to` when it structurally satisfies it (see CanAssignVM).
func (*Interface) CanAssign ¶ added in v0.0.2
CanAssign reports whether obj structurally satisfies the interface. It has no VM, so field-type symbols and parent interfaces that need one are skipped; prefer CanAssignVM (used by parameter checking and the `::` operator).
func (*Interface) CanAssignVM ¶ added in v0.0.2
CanAssignVM reports whether obj structurally satisfies the interface: it has every required field (with an assignable type), property and method (whose signatures satisfy the required headers), and satisfies every extended interface. vm resolves field-type symbols, property/method calls and the parent-interface symbols; when nil those VM-dependent checks are relaxed.
func (*Interface) FullName ¶ added in v0.0.2
FullName is the interface name qualified by its module, or just the name when there is no (or an unnamed) module or the interface is anonymous. FullName returns the module-qualified name `MODULE_NAME.NAME` when the module name is set; otherwise the bare name (or an empty string when unnamed).
func (*Interface) Type ¶ added in v0.0.2
func (i *Interface) Type() ObjectType
func (*Interface) WithField ¶ added in v0.0.2
func (i *Interface) WithField(name string, types ...ObjectType) *Interface
WithField appends a typed field.
func (*Interface) WithGetter ¶ added in v0.0.2
func (i *Interface) WithGetter(name string, getter *FuncHeaderObject) *Interface
WithGetter appends a getter property (an InterfaceProp with a Getter).
func (*Interface) WithMethod ¶ added in v0.0.2
func (i *Interface) WithMethod(name string, headers ...*FuncHeaderObject) *Interface
WithMethod appends a required method with its overload signatures.
func (*Interface) WithSetter ¶ added in v0.0.2
func (i *Interface) WithSetter(name string, setters ...*FuncHeaderObject) *Interface
WithSetter appends a setter property (an InterfaceProp with Setters).
type InterfaceField ¶ added in v0.0.2
type InterfaceField struct {
Iface *Interface
Name string
TypesSymbols ParamType // compile-time type symbols
Types ObjectTypes // resolved types (when built at run time)
}
InterfaceField is a typed field of an interface (see gad.Param for the type symbol/ObjectType split).
func (*InterfaceField) Equal ¶ added in v0.0.2
func (f *InterfaceField) Equal(right Object) bool
func (*InterfaceField) IndexGet ¶ added in v0.0.2
func (f *InterfaceField) IndexGet(vm *VM, index Object) (Object, error)
func (*InterfaceField) IsFalsy ¶ added in v0.0.2
func (f *InterfaceField) IsFalsy() bool
func (*InterfaceField) ToString ¶ added in v0.0.2
func (f *InterfaceField) ToString() string
func (*InterfaceField) Type ¶ added in v0.0.2
func (f *InterfaceField) Type() ObjectType
type InterfaceMethod ¶ added in v0.0.2
type InterfaceMethod struct {
Iface *Interface
Name string
Headers []*FuncHeaderObject
}
InterfaceMethod is a required method of an interface: a name and its overload signatures (like a MethodInterface).
func (*InterfaceMethod) Equal ¶ added in v0.0.2
func (m *InterfaceMethod) Equal(right Object) bool
func (*InterfaceMethod) IndexGet ¶ added in v0.0.2
func (m *InterfaceMethod) IndexGet(_ *VM, index Object) (Object, error)
func (*InterfaceMethod) IsFalsy ¶ added in v0.0.2
func (m *InterfaceMethod) IsFalsy() bool
func (*InterfaceMethod) ToString ¶ added in v0.0.2
func (m *InterfaceMethod) ToString() string
func (*InterfaceMethod) Type ¶ added in v0.0.2
func (m *InterfaceMethod) Type() ObjectType
type InterfaceProp ¶ added in v0.0.2
type InterfaceProp struct {
Iface *Interface
Name string
Getter *FuncHeaderObject // the getter signature, or nil
Setters []*FuncHeaderObject // the setter signatures
}
InterfaceProp is a getter and/or setter property of an interface.
func (*InterfaceProp) Equal ¶ added in v0.0.2
func (p *InterfaceProp) Equal(right Object) bool
func (*InterfaceProp) IndexGet ¶ added in v0.0.2
func (p *InterfaceProp) IndexGet(_ *VM, index Object) (Object, error)
func (*InterfaceProp) IsFalsy ¶ added in v0.0.2
func (p *InterfaceProp) IsFalsy() bool
func (*InterfaceProp) ToString ¶ added in v0.0.2
func (p *InterfaceProp) ToString() string
func (*InterfaceProp) Type ¶ added in v0.0.2
func (p *InterfaceProp) 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 ¶
func (*Invoker) Release ¶
func (inv *Invoker) Release()
Release releases the VM back to the pool if it was acquired from the pool.
func (*Invoker) WithContext ¶ added in v0.0.2
WithContext binds a context to the Invoker. When the context is cancelled (for example a deadline from context.WithTimeout, or a context.WithCancel cancel) before the invoked function returns, the whole VM tree is aborted from the root, so the invoked CompiledFunction and every VM it spawned through nested invokers — which all fork into the same root pool — stop, and Invoke returns the context's error (context.DeadlineExceeded / context.Canceled). This is the intended guard against infinite loops and long-running invoked code.
A nil or non-cancellable context (the default, or context.Background) adds no goroutine and no overhead: the callee runs inline as before.
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) Print ¶ added in v0.0.2
func (it *Iteration) Print(state *PrinterState) error
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 {
Printabler
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 Iterators ¶ added in v0.0.2
type Iterators []Iterator
func (Iterators) Print ¶ added in v0.0.2
func (its Iterators) Print(s *PrinterState) (err error)
type KeyValue ¶
type KeyValue struct {
K, V Object
}
func (*KeyValue) BinOpGreater ¶ added in v0.0.2
Greater and GreaterEq both report !IsLess (matching the original behavior).
func (*KeyValue) BinOpGreaterEq ¶ added in v0.0.2
func (*KeyValue) BinOpLess ¶ added in v0.0.2
A *KeyValue orders after nil and against another *KeyValue by IsLess; these implement the comparison ObjectWith{Op}BinOperator interfaces.
func (*KeyValue) BinOpLessEq ¶ added in v0.0.2
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) AppendArrayOfPairs ¶ added in v0.0.2
func (o *KeyValueArray) AppendArrayOfPairs(arr Array) 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) BinOpAdd ¶ added in v0.0.2
func (o KeyValueArray) BinOpAdd(vm *VM, right Object) (Object, error)
BinOpAdd appends right's entries (ObjectWithAddBinOperator); the comparison operators order the array after nil and are otherwise unsupported.
func (KeyValueArray) BinOpGreater ¶ added in v0.0.2
func (o KeyValueArray) BinOpGreater(_ *VM, right Object) (Object, error)
func (KeyValueArray) BinOpGreaterEq ¶ added in v0.0.2
func (o KeyValueArray) BinOpGreaterEq(_ *VM, right Object) (Object, error)
func (KeyValueArray) BinOpIn ¶ added in v0.0.2
func (o KeyValueArray) BinOpIn(_ *VM, v Object) (Object, error)
BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v is a key of the key-value array (`v in kva`).
func (KeyValueArray) BinOpLess ¶ added in v0.0.2
func (o KeyValueArray) BinOpLess(_ *VM, right Object) (Object, error)
func (KeyValueArray) BinOpLessEq ¶ added in v0.0.2
func (o KeyValueArray) BinOpLessEq(_ *VM, right Object) (Object, 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) ToArray ¶ added in v0.0.2
func (o KeyValueArray) ToArray() (arr Array)
func (KeyValueArray) ToString ¶
func (o KeyValueArray) ToString() string
func (KeyValueArray) Type ¶
func (o KeyValueArray) Type() ObjectType
func (KeyValueArray) UpdateIndexSetter ¶ added in v0.0.2
func (o KeyValueArray) UpdateIndexSetter(out StringIndexSetter)
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) BinOpGreater ¶ added in v0.0.2
func (o KeyValueArrays) BinOpGreater(_ *VM, right Object) (Object, error)
func (KeyValueArrays) BinOpGreaterEq ¶ added in v0.0.2
func (o KeyValueArrays) BinOpGreaterEq(_ *VM, right Object) (Object, error)
func (KeyValueArrays) BinOpLess ¶ added in v0.0.2
func (o KeyValueArrays) BinOpLess(_ *VM, right Object) (Object, error)
KeyValueArrays orders after nil and is otherwise not comparable.
func (KeyValueArrays) BinOpLessEq ¶ added in v0.0.2
func (o KeyValueArrays) BinOpLessEq(_ *VM, right Object) (Object, error)
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 Location ¶ added in v0.0.2
type Location struct {
ObjectImpl
Value *time.Location
}
Location represents location values and implements Object interface.
func ToLocation ¶ added in v0.0.2
ToLocation will try to convert given Object to *Location value.
func (*Location) Type ¶ added in v0.0.2
func (*Location) Type() ObjectType
type MethodAdder ¶ added in v0.0.2
type MethodAdder interface {
// AddCallerMethod add caller method from argument types.
// the argTypes param is a list of supported types for arguments.
//
// Examples:
// - fn(str, decimal) => ParamsTypes{{TStr},{TDecimal}}
// - fn(str|int, decimal) => ParamsTypes{{TStr,Int},{TDecimal}}
AddMethodByTypes(vm *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(method *TypedCallerMethod) error) error
}
type MethodArgType ¶
type MethodArgType struct {
Type TypeAssigner
Method *TypedCallerMethod
Var bool
Next Methods
NextVar Methods
// contains filtered or unexported fields
}
func (*MethodArgType) Add ¶
func (at *MethodArgType) Add(types ParamsTypes, m *CallerMethod, override bool, onAdd func(tcm *TypedCallerMethod) error) (err error)
func (*MethodArgType) ArgWalk ¶ added in v0.0.2
func (at *MethodArgType) ArgWalk(f func(m *MethodArgType) any) (r any)
func (MethodArgType) Copy ¶ added in v0.0.2
func (at MethodArgType) Copy() *MethodArgType
func (*MethodArgType) EachMethods ¶ added in v0.0.2
func (at *MethodArgType) EachMethods() func(func(i int, m *MethodArgType) bool)
func (*MethodArgType) GetMethod ¶
func (at *MethodArgType) GetMethod(types ObjectTypeArray) *TypedCallerMethod
func (*MethodArgType) IsZero ¶
func (at *MethodArgType) IsZero() (ok bool)
func (*MethodArgType) MethodsWalk ¶ added in v0.0.2
func (at *MethodArgType) MethodsWalk(f func(m *MethodArgType) any) (r any)
func (*MethodArgType) NumMethods ¶ added in v0.0.2
func (at *MethodArgType) NumMethods() (i int)
func (*MethodArgType) Parents ¶ added in v0.0.2
func (at *MethodArgType) Parents() (parents []*MethodArgType)
func (*MethodArgType) Path ¶ added in v0.0.2
func (at *MethodArgType) Path() (path []*MethodArgType)
func (*MethodArgType) ToString ¶ added in v0.0.2
func (at *MethodArgType) ToString() string
func (*MethodArgType) Walk ¶
func (at *MethodArgType) Walk(cb func(m *TypedCallerMethod) any) (v any)
func (*MethodArgType) WalkSorted ¶
func (at *MethodArgType) WalkSorted(cb func(m *TypedCallerMethod) any) (v any)
type MethodCaller ¶
type MethodCaller interface {
CallerObject
MethodAdder
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 ObjectTypeArray) (method CallerObject, validationCheck bool)
// CallerMethodOfArgsTypes return a method from arguments types whitout validation check flag.
CallerMethodOfArgsTypes(types ObjectTypeArray) (method CallerObject)
HasCallerMethods() bool
// CallerMethodDefault returns default caller Object if exists or nil
CallerMethodDefault() CallerObject
Name() string
}
type MethodDefinition ¶
type MethodDefinition struct {
Args []ObjectType
Handler CallerObject
}
type MethodInterface ¶ added in v0.0.2
type MethodInterface struct {
MIName string
Headers []*FuncHeaderObject
}
MethodInterface is the value of a method interface (see TMethodInterface): a name and the required function headers.
func (*MethodInterface) AssignTo ¶ added in v0.0.2
func (m *MethodInterface) AssignTo(vm *VM, obj Object, to TypeAssigner) (Object, error)
AssignTo makes *MethodInterface a TypeAssigner. As a target it accepts a value that structurally implements it; as a source it matches only an equal interface.
func (*MethodInterface) BinOpAdd ¶ added in v0.0.2
func (m *MethodInterface) BinOpAdd(_ *VM, right Object) (Object, error)
BinOpAdd implements `mi + mi2` (ObjectWithAddBinOperator), merging two interfaces.
func (*MethodInterface) BinOpIn ¶ added in v0.0.2
func (m *MethodInterface) BinOpIn(_ *VM, v Object) (Object, error)
BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v is one of the interface's function headers (`header in meti`).
func (*MethodInterface) CanAssign ¶ added in v0.0.2
func (m *MethodInterface) CanAssign(obj Object) (bool, error)
func (*MethodInterface) CanAssignVM ¶ added in v0.0.2
func (m *MethodInterface) CanAssignVM(vm *VM, obj Object) (bool, error)
CanAssignVM reports whether obj (a callable) structurally implements the interface, using vm to resolve the callable's signatures.
func (*MethodInterface) Equal ¶ added in v0.0.2
func (m *MethodInterface) Equal(right Object) bool
func (*MethodInterface) HeadersArray ¶ added in v0.0.2
func (m *MethodInterface) HeadersArray() Array
HeadersArray returns the headers as an Array of FunctionHeader values.
func (*MethodInterface) IndexGet ¶ added in v0.0.2
func (m *MethodInterface) IndexGet(_ *VM, index Object) (Object, error)
IndexGet exposes name and headers.
func (*MethodInterface) IsFalsy ¶ added in v0.0.2
func (m *MethodInterface) IsFalsy() bool
func (*MethodInterface) Name ¶ added in v0.0.2
func (m *MethodInterface) Name() string
func (*MethodInterface) String ¶ added in v0.0.2
func (m *MethodInterface) String() string
func (*MethodInterface) ToString ¶ added in v0.0.2
func (m *MethodInterface) ToString() string
func (*MethodInterface) Type ¶ added in v0.0.2
func (m *MethodInterface) Type() ObjectType
type Methods ¶
type Methods map[TypeAssigner]*MethodArgType
func (Methods) Sorted ¶ added in v0.0.2
func (m Methods) Sorted(cb func(m *MethodArgType) any) (err any)
func (Methods) WalkSorted ¶
func (m Methods) WalkSorted(cb func(m *TypedCallerMethod) any) (v any)
type MixedParams ¶
type MixedParams struct {
Positional Array
Named KeyValueArray
}
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) Print ¶ added in v0.0.2
func (m *MixedParams) Print(state *PrinterState) error
func (*MixedParams) ToDict ¶
func (m *MixedParams) ToDict() (d Dict)
func (*MixedParams) ToString ¶
func (m *MixedParams) ToString() string
func (*MixedParams) Type ¶
func (m *MixedParams) Type() ObjectType
func (*MixedParams) UpdateIndexSetter ¶ added in v0.0.2
func (m *MixedParams) UpdateIndexSetter(out StringIndexSetter)
type Module ¶ added in v0.0.2
type Module struct {
Spec *ModuleSpec
Data ModuleData
Params MixedParams
}
Module represent the module
func NewModule ¶ added in v0.0.2
func NewModule(static *ModuleSpec, f ...func(m *Module)) *Module
func (*Module) CanIterate ¶ added in v0.0.2
func (*Module) Items ¶ added in v0.0.2
func (m *Module) Items(vm *VM, cb ItemsGetterCallback) (err error)
func (*Module) Print ¶ added in v0.0.2
func (m *Module) Print(state *PrinterState) (err error)
func (*Module) Type ¶ added in v0.0.2
func (m *Module) Type() ObjectType
func (*Module) UpdateIndexSetter ¶ added in v0.0.2
func (m *Module) UpdateIndexSetter(out StringIndexSetter)
type ModuleData ¶ added in v0.0.2
type ModuleData interface {
Object
IndexGetSetter
ToDictConverter
LengthGetter
KeysGetter
ValuesGetter
ItemsGetter
Iterabler
StringIndexSetter
}
type ModuleGetter ¶ added in v0.0.2
type ModuleGetter interface {
GetModule() *ModuleSpec
}
type ModuleInfo ¶
type ModuleInitFunc ¶ added in v0.0.2
func ModuleInitWithDataDict ¶ added in v0.0.2
func ModuleInitWithDataDict(d Dict) ModuleInitFunc
func (ModuleInitFunc) Caller ¶ added in v0.0.2
func (f ModuleInitFunc) Caller(spec *ModuleSpec) func(module *Module) CallerObject
func (ModuleInitFunc) MustGetData ¶ added in v0.0.2
func (f ModuleInitFunc) MustGetData(module *Module) (data ModuleData)
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) AddBuiltinCompilableModule ¶ added in v0.0.2
func (m *ModuleMap) AddBuiltinCompilableModule( name string, compile BuiltinCompileModuleFunc, ) *ModuleMap
AddBuiltinCompilableModule adds a builtin compilable module.
func (*ModuleMap) AddBuiltinModule ¶
AddBuiltinModule adds a builtin module.
func (*ModuleMap) AddBuiltinModuleInit ¶ added in v0.0.2
func (m *ModuleMap) AddBuiltinModuleInit( name string, init ModuleInitFunc, ) *ModuleMap
AddBuiltinModuleInit 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) Importers ¶ added in v0.0.2
func (m *ModuleMap) Importers() map[string]Importable
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 ModuleSetter ¶ added in v0.0.2
type ModuleSetter interface {
SetModule(m *ModuleSpec)
}
type ModuleSpec ¶ added in v0.0.2
type ModuleSpec struct {
ModuleInfo
Index int
Path []int
Main bool
InitCompiledFunc *CompiledFunction
InitGoFunc func(module *Module) CallerObject
}
func NewModuleSpecFromName ¶ added in v0.0.2
func NewModuleSpecFromName(name string, opt ...func(s *ModuleSpec)) *ModuleSpec
func (*ModuleSpec) InitFunc ¶ added in v0.0.2
func (i *ModuleSpec) InitFunc(module *Module) CallerObject
func (*ModuleSpec) String ¶ added in v0.0.2
func (i *ModuleSpec) String() string
type ModuleStmt ¶ added in v0.0.2
type ModuleStmt struct {
Module *ModuleSpec
*parser.File
}
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
Do func(value Object) error
*TypeAssertion
}
NamedArgVar is a struct to destructure named arguments from Call object.
func (*NamedArgVar) IsFalsy ¶ added in v0.0.2
func (v *NamedArgVar) IsFalsy() bool
type NamedArgs ¶
type NamedArgs struct {
// contains filtered or unexported fields
}
NamedArgs holds the keyword (name=value) arguments of a call.
Values are lazily materialised from sources into the m map on first access (see check). By default reading a value with GetValue/GetValueOrNil *consumes* it — the key is removed from m and recorded in ready — so a function only sees each named argument once and leftover names can be detected. When the NamedArgs is read-only (see WithReadOnly), reads do not consume, so the same NamedArgs can be reused across several calls; this is useful when reusing one instance in a loop and mutating a backing Dict between calls (Dict.ToNamedArgs keeps a live reference to that Dict in m).
func NewNamedArgs ¶
func NewNamedArgs(pairs ...KeyValueArray) *NamedArgs
NewNamedArgs returns a NamedArgs from the given name=value pair lists. Later pairs take precedence over earlier ones for duplicate keys.
func (*NamedArgs) BinOpAdd ¶ added in v0.0.2
BinOpAdd merges a nil right operand (a no-op add); NamedArgs otherwise orders after nil and is not comparable to other operands.
func (*NamedArgs) BinOpGreater ¶ added in v0.0.2
func (*NamedArgs) BinOpGreaterEq ¶ added in v0.0.2
func (*NamedArgs) BinOpLessEq ¶ added in v0.0.2
func (*NamedArgs) CheckNames ¶
func (*NamedArgs) CheckNamesFromSet ¶
func (*NamedArgs) Get ¶
func (o *NamedArgs) Get(dst ...*NamedArgVar) (err error)
Get reads each named arg in dst (by Name, type-checked via TypeAssertion) and is strict: it returns ErrUnexpectedNamedArg if any passed named arg is not covered by dst. Use it when dst is the complete set of accepted named args.
Errors:
- ArgumentTypeError if a value fails its TypeAssertion.
- ErrUnexpectedNamedArg if an unrecognised named arg was passed.
It does not run the Do handlers; see GetDo.
func (*NamedArgs) GetDo ¶ added in v0.0.2
func (o *NamedArgs) GetDo(dst ...*NamedArgVar) (err error)
GetDo is the strict form of GetDoCheck (check=true): it reads each named arg in dst, rejects any unrecognised named arg with ErrUnexpectedNamedArg, then runs each dst.Do handler (in dst order) for the args that were present.
Errors:
- ArgumentTypeError if a value fails its TypeAssertion.
- ErrUnexpectedNamedArg if an unrecognised named arg was passed.
- any error returned by a dst.Do handler.
func (*NamedArgs) GetDoCheck ¶ added in v0.0.2
func (o *NamedArgs) GetDoCheck(check bool, dst ...*NamedArgVar) (err error)
GetDoCheck reads each named arg in dst (by Name, type-checked) and runs its Do handler when the arg was present. When check is true it additionally rejects any passed named arg not covered by dst with ErrUnexpectedNamedArg.
Pass check=false when dst is only a partial view of the accepted named args — i.e. the remaining ones are consumed by a later call on the same NamedArgs. This is the two-phase pattern used by the Class constructor, where the outer builtin handles `define` and Class.Define handles `fields`/`methods`/`new`/…; the outer call must not reject those it leaves for the inner call.
Errors:
- ArgumentTypeError if a value fails its TypeAssertion.
- ErrUnexpectedNamedArg only when check is true and an unrecognised named arg was passed.
- any error returned by a dst.Do handler.
func (*NamedArgs) GetOne ¶
func (o *NamedArgs) GetOne(dst ...*NamedArgVar) (err error)
GetOne reads each named arg in dst by Name (type-checked). Unlike Get it is lenient: it ignores any other passed named args, so it never returns ErrUnexpectedNamedArg. Use it when other args are consumed elsewhere.
Errors:
- ArgumentTypeError if a value fails its TypeAssertion.
It does not run the Do handlers; see GetOneDo.
func (*NamedArgs) GetOneDo ¶ added in v0.0.2
func (o *NamedArgs) GetOneDo(dst ...*NamedArgVar) (err error)
GetOneDo is the Do-running form of GetOne: it reads each named arg in dst and runs its Do handler when present, without rejecting unrecognised named args. It is equivalent to GetDoCheck(false, dst...).
Errors:
- ArgumentTypeError if a value fails its TypeAssertion.
- any error returned by a dst.Do handler.
func (*NamedArgs) GetPassedValue ¶
GetPassedValue Get passed value
func (*NamedArgs) GetValueOrNil ¶
GetValueOrNil returns the value for key, or nil if absent. Unless the NamedArgs is read-only, the key is consumed (removed from m and recorded in ready) so it is reported only once.
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) IsReadOnly ¶ added in v0.0.2
IsReadOnly reports whether reads consume values.
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) Print ¶ added in v0.0.2
func (o *NamedArgs) Print(state *PrinterState) (err error)
func (*NamedArgs) Ready ¶
func (o *NamedArgs) Ready() (arr KeyValueArray)
func (*NamedArgs) SetReadOnly ¶ added in v0.0.2
SetReadOnly sets the read-only flag (see WithReadOnly).
func (*NamedArgs) Type ¶
func (o *NamedArgs) Type() ObjectType
func (*NamedArgs) UnreadPairs ¶
func (o *NamedArgs) UnreadPairs() (ret KeyValueArray)
func (*NamedArgs) Walk ¶
Walk pass over all pairs and call `cb` function. if `cb` function returns any error, stop iterator and return then.
func (*NamedArgs) WithReadOnly ¶ added in v0.0.2
WithReadOnly sets the read-only flag and returns o. While read-only, reads do not consume values and Add returns ErrNotWriteable.
type NamedParam ¶
type NamedParam struct {
Name string
// Value is a script of default value
Value string
Usage string
Index int
TypesSymbols ParamType
Types ObjectTypes
Symbol *SymbolInfo
Var bool
}
func NewNamedParam ¶
func NewNamedParam(name, value string) *NamedParam
func NewVarNamedParam ¶ added in v0.0.2
func NewVarNamedParam(name string) *NamedParam
func (*NamedParam) String ¶
func (p *NamedParam) String() string
type NamedParamBuilder ¶ added in v0.0.2
type NamedParamBuilder struct {
// contains filtered or unexported fields
}
func (*NamedParamBuilder) Type ¶ added in v0.0.2
func (b *NamedParamBuilder) Type(typ ...ObjectType) *NamedParamBuilder
func (*NamedParamBuilder) Usage ¶ added in v0.0.2
func (b *NamedParamBuilder) Usage(v string) *NamedParamBuilder
func (*NamedParamBuilder) Var ¶ added in v0.0.2
func (b *NamedParamBuilder) Var() *NamedParamBuilder
type NamedParams ¶
type NamedParams struct {
Items []*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) EachNonVar ¶ added in v0.0.2
func (n *NamedParams) EachNonVar(cb func(i int, p *NamedParam))
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 NamedParamsVar ¶ added in v0.0.2
type NamedParamsVar struct {
Object
}
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) BinOpGreater ¶ added in v0.0.2
func (*NilType) BinOpGreaterEq ¶ added in v0.0.2
func (*NilType) BinOpLess ¶ added in v0.0.2
nil orders before every non-nil value and equals itself, so `nil < x` and `nil <= x` are true (false only against nil for `<`), while `nil > x` is false and `nil >= x` is true only against nil. These implement the comparison ObjectWith{Op}BinOperator interfaces.
func (*NilType) BinOpLessEq ¶ added in v0.0.2
func (*NilType) Print ¶ added in v0.0.2
func (o *NilType) Print(state *PrinterState) error
func (*NilType) Type ¶
func (o *NilType) Type() ObjectType
type Object ¶
type Object interface {
Falser
// Type should return the type object.
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 AddMethod ¶ added in v0.0.2
func AddMethod(target Object, method ...TypedCallerObjectWithParamTypes) Object
func AddMethodOverride ¶ added in v0.0.2
func AddMethodOverride(override bool, target Object, method ...TypedCallerObjectWithParamTypes) Object
func AssignToType ¶ added in v0.0.2
AssignToType implements the `obj :: to` assign-to-type operator: it returns obj when obj is assignable to the type value `to`, otherwise a type error. The target may be an ObjectType (plain type assignability) or a structural TypeAssigner such as a meti/interface (checked by value, like a parameter type). It is the runtime behind OpAssign and chains left-to-right for `obj::T1::T2`.
func BinaryOp ¶ added in v0.0.2
BinaryOp runs a binary operator on two objects through the per-operator ObjectWith{Op}BinOperator dispatch (binOpObject), matching gad.binOp. Internal callers (sort, value comparisons) and embedders use it.
func BuiltinAddMethodFunc ¶ added in v0.0.2
func BuiltinAppendFunc ¶
func BuiltinCapFunc ¶
func BuiltinCastFunc ¶
func BuiltinCharsFunc ¶
func BuiltinCloseFunc ¶
func BuiltinCollectFunc ¶
func BuiltinContainsFunc ¶
func BuiltinCopyFunc ¶
func BuiltinDeepCopyFunc ¶
func BuiltinDeleteFunc ¶
func BuiltinEachFunc ¶
func BuiltinEnterFunc ¶ added in v0.0.2
BuiltinEnterFunc implements gad.enter(resource), the entry half of a `with` block: it runs the resource's Enter hook — the Go ObjectEnter interface or, for Gad objects, an `enter()` method. A resource with neither is a no-op. Returns the resource so it can be used directly.
func BuiltinEnumerateFunc ¶
func BuiltinExitFunc ¶ added in v0.0.2
BuiltinExitFunc implements gad.exit(resource, err), the exit half of a `with` block: it runs the resource's Exit hook — the Go ObjectExit interface or, for Gad objects, an `exit(err)` method — passing any error raised in the block (nil on normal exit). A resource with neither is a no-op.
func BuiltinFilterFunc ¶
func BuiltinFlushFunc ¶
func BuiltinImplementsFunc ¶ added in v0.0.2
BuiltinImplementsFunc reports whether fn provides every header of the given method interfaces: implements(fn CALLABLE, mi MethodInterface, *otherMi) <bool>. Matching is by parameter arity and assignable parameter types.
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 BuiltinMakeArrayRestFunc ¶ added in v0.0.2
BuiltinMakeArrayRestFunc backs the private :makeArrayRest builtin used by array destructuring with a trailing `*rest` target. n is the number of fixed targets before the rest. It returns an Array of n+1 elements: indices 0..n-1 are arg's elements (padded with Nil when arg is shorter) and index n is the remaining elements (arg[n:]) as a fresh Array, empty when arg has n or fewer elements.
func BuiltinMapFunc ¶
func BuiltinMethodFromArgsFunc ¶ added in v0.0.2
BuiltinMethodFromArgsFunc implements `gad.methodFromArgs(target, ...args)`: it resolves the method currently registered on target that a call with the given arguments would dispatch to, returning that caller (or nil if none matches).
Each argument after target may be a value — in which case its type is used — or an ObjectType, used directly; so a signature can be described by example values (`methodFromArgs(f, 1, "x")`) or by type names (`methodFromArgs(f, int, str)`). It underpins the `$old` override parameter, which captures the method being overridden before the override replaces it.
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 BuiltinToArrayFunc ¶
func BuiltinTypeNameFunc ¶
func BuiltinTypeOfFunc ¶
func BuiltinUnaryOperatorFunc ¶ added in v0.0.2
BuiltinUnaryOperatorFunc is the default handler of gad.unOp: it dispatches to the operand's per-operator ObjectWith{Op}UnaryOperator implementation (unOpObject). The logical NOT operator (`!`) is universal — any value that does not implement UnOpNot falls back to its truthiness.
func BuiltinUserDataFunc ¶
func BuiltinValuesFunc ¶
func BuiltinWrapFunc ¶
func BuiltinWriteFunc ¶
func IteratorObject ¶
func MustCallVargs ¶
func MustToObject ¶
func NewArrayFunc ¶
func NewBufferFunc ¶
func NewBytesFunc ¶
func NewCalendarDateFunc ¶ added in v0.0.2
NewCalendarDateFunc is the calendarDate(...) constructor: a calendarDate pass-through, a calendarTime/time (its date part), an int/uint (YYYYMMDD) or a string (see strToDate).
func NewCalendarTimeFunc ¶ added in v0.0.2
NewCalendarTimeFunc is the calendarTime(...) constructor: a calendarTime pass-through, a time/calendarDate (its wall-clock value), an int/uint (UnixNano) or a string (see strToCalendarTime).
func NewClassFunc ¶ added in v0.0.2
func NewComputedValue ¶ added in v0.0.2
func NewDictFunc ¶
func NewDurationFunc ¶ added in v0.0.2
NewDurationFunc is the duration(...) constructor: a duration pass-through, an int/uint (nanoseconds) or a string (see strToDuration, e.g. "1h30m").
func NewErrorFunc ¶
func NewFuncFunc ¶ added in v0.0.2
func NewFunctionHeaderFunc ¶ added in v0.0.2
NewFunctionHeaderFunc builds a FuncHeaderObject from (name str, params array, namedParams array, return array).
func NewKeyValueArrayFunc ¶
func NewKeyValueFunc ¶
func NewLocationFunc ¶ added in v0.0.2
NewLocationFunc is the Location(...) constructor: a Location pass-through, a string (offset/name, see strToLocation) or an int offset in seconds.
func NewMethodInterfaceFunc ¶ added in v0.0.2
NewMethodInterfaceFunc builds a MethodInterface from (name str, *headers FunctionHeader).
func NewMixedParamsFunc ¶
func NewPrinterStateFunc ¶
func NewPropFunc ¶ added in v0.0.2
NewPropFunc create prop instance.
func NewRangeFunc ¶ added in v0.0.2
NewRangeFunc is the Range(from, to; step) constructor body shared by the typed methods.
func NewRawStrFunc ¶
func NewRegexpFunc ¶
func NewStrFunc ¶
func NewSyncDictFunc ¶
func NewTimeFunc ¶ added in v0.0.2
NewTimeFunc is the time(...) constructor: a time pass-through, a string (see strToTime), a Date (midnight UTC) or an int (unix seconds).
func NewTypedIdentFunc ¶ added in v0.0.2
func ObjectOrNil ¶ added in v0.0.2
func TimeAddDate ¶ added in v0.0.2
func TimeAppendFormat ¶ added in v0.0.2
func TimeBefore ¶ added in v0.0.2
func TimeDateFunc ¶ added in v0.0.2
func TimeDurationHoursFunc ¶ added in v0.0.2
func TimeDurationMicrosecondsFunc ¶ added in v0.0.2
func TimeDurationMillisecondsFunc ¶ added in v0.0.2
func TimeDurationMinutesFunc ¶ added in v0.0.2
func TimeDurationNanosecondsFunc ¶ added in v0.0.2
func TimeDurationRoundFunc ¶ added in v0.0.2
func TimeDurationSecondsFunc ¶ added in v0.0.2
func TimeDurationStringFunc ¶ added in v0.0.2
func TimeDurationTruncateFunc ¶ added in v0.0.2
func TimeFixedZoneFunc ¶ added in v0.0.2
func TimeFormat ¶ added in v0.0.2
func TimeIsLocationFunc ¶ added in v0.0.2
func TimeIsTimeFunc ¶ added in v0.0.2
func TimeLoadLocationFunc ¶ added in v0.0.2
func TimeLocalFunc ¶ added in v0.0.2
func TimeLocalFunc() Object
func TimeMonthStringFunc ¶ added in v0.0.2
func TimeNewArgTypeErr ¶ added in v0.0.2
func TimeNowFunc ¶ added in v0.0.2
func TimeNowFunc() Object
func TimeParseDurationFunc ¶ added in v0.0.2
func TimeParseFunc ¶ added in v0.0.2
func TimeSinceFunc ¶ added in v0.0.2
func TimeSleepFunc ¶ added in v0.0.2
func TimeTruncate ¶ added in v0.0.2
func TimeUnixFunc ¶ added in v0.0.2
func TimeUntilFunc ¶ added in v0.0.2
func TimeUtcFunc ¶ added in v0.0.2
func TimeUtcFunc() Object
func TimeWeekdayStringFunc ¶ added in v0.0.2
func TimeZerotimeFunc ¶ added in v0.0.2
func TimeZerotimeFunc() Object
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) RegisterToGo ¶ added in v0.0.2
func (oc *ObjectConverters) RegisterToGo(objType ObjectType, togo func(vm *VM, v Object) any) *ObjectConverters
func (*ObjectConverters) RegisterToObject ¶ added in v0.0.2
func (oc *ObjectConverters) RegisterToObject(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 ObjectEnter ¶ added in v0.0.2
ObjectEnter is implemented by values usable as a `with` resource. Enter runs when the `with` block is entered, via gad.enter(resource). The `with` statement/expression desugars to a deferb that pairs it with ObjectExit.
type ObjectExit ¶ added in v0.0.2
ObjectExit is implemented by values usable as a `with` resource. Exit runs when the `with` block is left, via gad.exit(resource, err), receiving any error raised in the block (nil on normal exit). A non-nil returned error propagates from the block.
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) BinOpAndNot ¶ added in v0.0.2
func (*ObjectPtr) BinOpGreater ¶ added in v0.0.2
func (*ObjectPtr) BinOpGreaterEq ¶ added in v0.0.2
func (*ObjectPtr) BinOpLessEq ¶ added in v0.0.2
func (*ObjectPtr) Type ¶
func (o *ObjectPtr) Type() ObjectType
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 = 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
TypeAssigner
Name() string
FullName() string
GadObjectType()
}
type ObjectTypeArray ¶
type ObjectTypeArray []ObjectType
func (ObjectTypeArray) Array ¶
func (t ObjectTypeArray) Array() Array
func (ObjectTypeArray) Assign ¶ added in v0.0.2
func (t ObjectTypeArray) Assign(ot ObjectType) (ok bool)
func (ObjectTypeArray) Equal ¶
func (t ObjectTypeArray) Equal(right Object) bool
func (ObjectTypeArray) Get ¶ added in v0.0.2
func (t ObjectTypeArray) Get(i int) ObjectType
func (ObjectTypeArray) HasVar ¶ added in v0.0.2
func (t ObjectTypeArray) HasVar() (ok bool)
func (ObjectTypeArray) IsFalsy ¶
func (t ObjectTypeArray) IsFalsy() bool
func (ObjectTypeArray) IsZero ¶ added in v0.0.2
func (t ObjectTypeArray) IsZero() bool
func (ObjectTypeArray) Items ¶ added in v0.0.2
func (t ObjectTypeArray) Items() ObjectTypeArray
func (ObjectTypeArray) Keys ¶ added in v0.0.2
func (t ObjectTypeArray) Keys() (keys ObjectTypeKeys)
func (ObjectTypeArray) Last ¶ added in v0.0.2
func (t ObjectTypeArray) Last() ObjectType
func (ObjectTypeArray) Len ¶ added in v0.0.2
func (t ObjectTypeArray) Len() int
func (ObjectTypeArray) Print ¶ added in v0.0.2
func (t ObjectTypeArray) Print(state *PrinterState) error
func (ObjectTypeArray) String ¶ added in v0.0.2
func (t ObjectTypeArray) String() string
func (ObjectTypeArray) ToString ¶
func (t ObjectTypeArray) ToString() string
func (ObjectTypeArray) Type ¶
func (t ObjectTypeArray) Type() ObjectType
func (ObjectTypeArray) Var ¶ added in v0.0.2
func (t ObjectTypeArray) Var() (_ ObjectType)
func (ObjectTypeArray) VarSplit ¶ added in v0.0.2
func (t ObjectTypeArray) VarSplit() (nonVar ObjectTypeArray, varType ObjectType)
type ObjectTypeAssignersGetter ¶ added in v0.0.2
type ObjectTypeAssignersGetter interface {
GetTypeAssigners(cb func(t ObjectType) any) any
}
type ObjectTypeKey ¶ added in v0.0.2
type ObjectTypeKey struct {
T ObjectType
// contains filtered or unexported fields
}
func KeyOfObjectType ¶ added in v0.0.2
func KeyOfObjectType(t ObjectType) *ObjectTypeKey
func (ObjectTypeKey) String ¶ added in v0.0.2
func (k ObjectTypeKey) String() string
type ObjectTypeKeys ¶ added in v0.0.2
type ObjectTypeKeys []*ObjectTypeKey
func (ObjectTypeKeys) Sort ¶ added in v0.0.2
func (o ObjectTypeKeys) Sort(reverse bool)
type ObjectTypeNode ¶
type ObjectTypeNode struct {
Var bool
Type ObjectType
VarChildren,
Children []*ObjectTypeNode
}
func (*ObjectTypeNode) Append ¶
func (n *ObjectTypeNode) Append(o ParamsTypes) (err error)
func (*ObjectTypeNode) Walk ¶
func (n *ObjectTypeNode) Walk(cb func(types ObjectTypeArray) any) any
func (*ObjectTypeNode) WalkE ¶
func (n *ObjectTypeNode) WalkE(cb func(types ObjectTypeArray) any) error
type ObjectTypes ¶
type ObjectTypes []ObjectType
func (ObjectTypes) Get ¶ added in v0.0.2
func (t ObjectTypes) Get(i int) ObjectType
func (ObjectTypes) HasVar ¶ added in v0.0.2
func (t ObjectTypes) HasVar() (ok bool)
func (ObjectTypes) IsZero ¶ added in v0.0.2
func (t ObjectTypes) IsZero() bool
func (ObjectTypes) Items ¶ added in v0.0.2
func (t ObjectTypes) Items() ObjectTypes
func (ObjectTypes) Last ¶ added in v0.0.2
func (t ObjectTypes) Last() ObjectType
func (ObjectTypes) Len ¶ added in v0.0.2
func (t ObjectTypes) Len() int
func (ObjectTypes) Multi ¶ added in v0.0.2
func (t ObjectTypes) Multi() (m ParamsTypes)
func (ObjectTypes) String ¶
func (t ObjectTypes) String() string
func (ObjectTypes) Var ¶ added in v0.0.2
func (t ObjectTypes) Var() (_ ObjectType)
func (ObjectTypes) VarSplit ¶ added in v0.0.2
func (t ObjectTypes) VarSplit() (nonVar ObjectTypes, varType ObjectType)
type ObjectWithAddBinOperator ¶ added in v0.0.2
ObjectWithAddBinOperator is implemented by an object that handles the `+` binary operator as the left operand.
type ObjectWithAddSelfAssignOperator ¶ added in v0.0.2
type ObjectWithAddSelfAssignOperator interface {
SelfAssignOpAdd(vm *VM, value Object) (Object, error)
}
ObjectWithAddSelfAssignOperator is implemented by an object that handles the `+=` self-assign operator as the left operand.
type ObjectWithAddUnaryOperator ¶ added in v0.0.2
ObjectWithAddUnaryOperator is implemented by an object that handles the `+` unary operator.
type ObjectWithAinBinOperator ¶ added in v0.0.2
ObjectWithAinBinOperator is implemented by an object that handles the `ain` binary operator as the left operand.
type ObjectWithAndBinOperator ¶ added in v0.0.2
ObjectWithAndBinOperator is implemented by an object that handles the `&` binary operator as the left operand.
type ObjectWithAndNotBinOperator ¶ added in v0.0.2
ObjectWithAndNotBinOperator is implemented by an object that handles the `&^` binary operator as the left operand.
type ObjectWithAndNotSelfAssignOperator ¶ added in v0.0.2
type ObjectWithAndNotSelfAssignOperator interface {
SelfAssignOpAndNot(vm *VM, value Object) (Object, error)
}
ObjectWithAndNotSelfAssignOperator is implemented by an object that handles the `&^=` self-assign operator as the left operand.
type ObjectWithAndSelfAssignOperator ¶ added in v0.0.2
type ObjectWithAndSelfAssignOperator interface {
SelfAssignOpAnd(vm *VM, value Object) (Object, error)
}
ObjectWithAndSelfAssignOperator is implemented by an object that handles the `&=` self-assign operator as the left operand.
type ObjectWithDecBinOperator ¶ added in v0.0.2
ObjectWithDecBinOperator is implemented by an object that handles the `--` binary operator as the left operand.
type ObjectWithDecSelfAssignOperator ¶ added in v0.0.2
type ObjectWithDecSelfAssignOperator interface {
SelfAssignOpDec(vm *VM, value Object) (Object, error)
}
ObjectWithDecSelfAssignOperator is implemented by an object that handles the `--=` self-assign operator as the left operand.
type ObjectWithDecUnaryOperator ¶ added in v0.0.2
ObjectWithDecUnaryOperator is implemented by an object that handles the `--` unary operator.
type ObjectWithDotDotBinOperator ¶ added in v0.0.2
ObjectWithDotDotBinOperator is implemented by an object that handles the `..` binary operator as the left operand.
type ObjectWithDoubleModBinOperator ¶ added in v0.0.2
type ObjectWithDoubleModBinOperator interface {
BinOpDoubleMod(vm *VM, right Object) (Object, error)
}
ObjectWithDoubleModBinOperator is implemented by an object that handles the `%%` binary operator as the left operand.
type ObjectWithDoubleModSelfAssignOperator ¶ added in v0.0.2
type ObjectWithDoubleModSelfAssignOperator interface {
SelfAssignOpDoubleMod(vm *VM, value Object) (Object, error)
}
ObjectWithDoubleModSelfAssignOperator is implemented by an object that handles the `%%=` self-assign operator as the left operand.
type ObjectWithDoubleTildeBinOperator ¶ added in v0.0.2
type ObjectWithDoubleTildeBinOperator interface {
BinOpDoubleTilde(vm *VM, right Object) (Object, error)
}
ObjectWithDoubleTildeBinOperator is implemented by an object that handles the `~~` binary operator as the left operand.
type ObjectWithEqualBinOperator ¶ added in v0.0.2
ObjectWithEqualBinOperator is implemented by an object that handles the `==` binary operator as the left operand.
type ObjectWithGreaterBinOperator ¶ added in v0.0.2
ObjectWithGreaterBinOperator is implemented by an object that handles the `>` binary operator as the left operand.
type ObjectWithGreaterEqBinOperator ¶ added in v0.0.2
type ObjectWithGreaterEqBinOperator interface {
BinOpGreaterEq(vm *VM, right Object) (Object, error)
}
ObjectWithGreaterEqBinOperator is implemented by an object that handles the `>=` binary operator as the left operand.
type ObjectWithInBinOperator ¶ added in v0.0.2
ObjectWithInBinOperator is implemented by an object that handles the `in` binary operator as the left operand.
type ObjectWithIncBinOperator ¶ added in v0.0.2
ObjectWithIncBinOperator is implemented by an object that handles the `++` binary operator as the left operand.
type ObjectWithIncSelfAssignOperator ¶ added in v0.0.2
type ObjectWithIncSelfAssignOperator interface {
SelfAssignOpInc(vm *VM, value Object) (Object, error)
}
ObjectWithIncSelfAssignOperator is implemented by an object that handles the `++=` self-assign operator as the left operand.
type ObjectWithIncUnaryOperator ¶ added in v0.0.2
ObjectWithIncUnaryOperator is implemented by an object that handles the `++` unary operator.
type ObjectWithLAndBinOperator ¶ added in v0.0.2
ObjectWithLAndBinOperator is implemented by an object that handles the `&&` binary operator as the left operand.
type ObjectWithLOrSelfAssignOperator ¶ added in v0.0.2
type ObjectWithLOrSelfAssignOperator interface {
SelfAssignOpLOr(vm *VM, value Object) (Object, error)
}
ObjectWithLOrSelfAssignOperator is implemented by an object that handles the `||=` self-assign operator as the left operand.
type ObjectWithLambdaBinOperator ¶ added in v0.0.2
ObjectWithLambdaBinOperator is implemented by an object that handles the `=>` binary operator as the left operand.
type ObjectWithLessBinOperator ¶ added in v0.0.2
ObjectWithLessBinOperator is implemented by an object that handles the `<` binary operator as the left operand.
type ObjectWithLessEqBinOperator ¶ added in v0.0.2
ObjectWithLessEqBinOperator is implemented by an object that handles the `<=` binary operator as the left operand.
type ObjectWithMulBinOperator ¶ added in v0.0.2
ObjectWithMulBinOperator is implemented by an object that handles the `*` binary operator as the left operand.
type ObjectWithMulSelfAssignOperator ¶ added in v0.0.2
type ObjectWithMulSelfAssignOperator interface {
SelfAssignOpMul(vm *VM, value Object) (Object, error)
}
ObjectWithMulSelfAssignOperator is implemented by an object that handles the `*=` self-assign operator as the left operand.
type ObjectWithNotEqualBinOperator ¶ added in v0.0.2
type ObjectWithNotEqualBinOperator interface {
BinOpNotEqual(vm *VM, right Object) (Object, error)
}
ObjectWithNotEqualBinOperator is implemented by an object that handles the `!=` binary operator as the left operand.
type ObjectWithNotSameBinOperator ¶ added in v0.0.2
ObjectWithNotSameBinOperator is implemented by an object that handles the `!==` binary operator as the left operand.
type ObjectWithNotUnaryOperator ¶ added in v0.0.2
ObjectWithNotUnaryOperator is implemented by an object that handles the `!` unary operator.
type ObjectWithOrBinOperator ¶ added in v0.0.2
ObjectWithOrBinOperator is implemented by an object that handles the `|` binary operator as the left operand.
type ObjectWithOrSelfAssignOperator ¶ added in v0.0.2
type ObjectWithOrSelfAssignOperator interface {
SelfAssignOpOr(vm *VM, value Object) (Object, error)
}
ObjectWithOrSelfAssignOperator is implemented by an object that handles the `|=` self-assign operator as the left operand.
type ObjectWithPowBinOperator ¶ added in v0.0.2
ObjectWithPowBinOperator is implemented by an object that handles the `**` binary operator as the left operand.
type ObjectWithPowSelfAssignOperator ¶ added in v0.0.2
type ObjectWithPowSelfAssignOperator interface {
SelfAssignOpPow(vm *VM, value Object) (Object, error)
}
ObjectWithPowSelfAssignOperator is implemented by an object that handles the `**=` self-assign operator as the left operand.
type ObjectWithQuoBinOperator ¶ added in v0.0.2
ObjectWithQuoBinOperator is implemented by an object that handles the `/` binary operator as the left operand.
type ObjectWithQuoSelfAssignOperator ¶ added in v0.0.2
type ObjectWithQuoSelfAssignOperator interface {
SelfAssignOpQuo(vm *VM, value Object) (Object, error)
}
ObjectWithQuoSelfAssignOperator is implemented by an object that handles the `/=` self-assign operator as the left operand.
type ObjectWithRemBinOperator ¶ added in v0.0.2
ObjectWithRemBinOperator is implemented by an object that handles the `%` binary operator as the left operand.
type ObjectWithRemSelfAssignOperator ¶ added in v0.0.2
type ObjectWithRemSelfAssignOperator interface {
SelfAssignOpRem(vm *VM, value Object) (Object, error)
}
ObjectWithRemSelfAssignOperator is implemented by an object that handles the `%=` self-assign operator as the left operand.
type ObjectWithSameBinOperator ¶ added in v0.0.2
ObjectWithSameBinOperator is implemented by an object that handles the `===` binary operator as the left operand.
type ObjectWithShlBinOperator ¶ added in v0.0.2
ObjectWithShlBinOperator is implemented by an object that handles the `<<` binary operator as the left operand.
type ObjectWithShlSelfAssignOperator ¶ added in v0.0.2
type ObjectWithShlSelfAssignOperator interface {
SelfAssignOpShl(vm *VM, value Object) (Object, error)
}
ObjectWithShlSelfAssignOperator is implemented by an object that handles the `<<=` self-assign operator as the left operand.
type ObjectWithShrBinOperator ¶ added in v0.0.2
ObjectWithShrBinOperator is implemented by an object that handles the `>>` binary operator as the left operand.
type ObjectWithShrSelfAssignOperator ¶ added in v0.0.2
type ObjectWithShrSelfAssignOperator interface {
SelfAssignOpShr(vm *VM, value Object) (Object, error)
}
ObjectWithShrSelfAssignOperator is implemented by an object that handles the `>>=` self-assign operator as the left operand.
type ObjectWithSubBinOperator ¶ added in v0.0.2
ObjectWithSubBinOperator is implemented by an object that handles the `-` binary operator as the left operand.
type ObjectWithSubSelfAssignOperator ¶ added in v0.0.2
type ObjectWithSubSelfAssignOperator interface {
SelfAssignOpSub(vm *VM, value Object) (Object, error)
}
ObjectWithSubSelfAssignOperator is implemented by an object that handles the `-=` self-assign operator as the left operand.
type ObjectWithSubUnaryOperator ¶ added in v0.0.2
ObjectWithSubUnaryOperator is implemented by an object that handles the `-` unary operator.
type ObjectWithTildeBinOperator ¶ added in v0.0.2
ObjectWithTildeBinOperator is implemented by an object that handles the `~` binary operator as the left operand.
type ObjectWithTripleGreaterBinOperator ¶ added in v0.0.2
type ObjectWithTripleGreaterBinOperator interface {
BinOpTripleGreater(vm *VM, right Object) (Object, error)
}
ObjectWithTripleGreaterBinOperator is implemented by an object that handles the `>>>` binary operator as the left operand.
type ObjectWithTripleGreaterSelfAssignOperator ¶ added in v0.0.2
type ObjectWithTripleGreaterSelfAssignOperator interface {
SelfAssignOpTripleGreater(vm *VM, value Object) (Object, error)
}
ObjectWithTripleGreaterSelfAssignOperator is implemented by an object that handles the `>>>=` self-assign operator as the left operand.
type ObjectWithTripleLessBinOperator ¶ added in v0.0.2
type ObjectWithTripleLessBinOperator interface {
BinOpTripleLess(vm *VM, right Object) (Object, error)
}
ObjectWithTripleLessBinOperator is implemented by an object that handles the `<<<` binary operator as the left operand.
type ObjectWithTripleLessSelfAssignOperator ¶ added in v0.0.2
type ObjectWithTripleLessSelfAssignOperator interface {
SelfAssignOpTripleLess(vm *VM, value Object) (Object, error)
}
ObjectWithTripleLessSelfAssignOperator is implemented by an object that handles the `<<<=` self-assign operator as the left operand.
type ObjectWithTripleTildeBinOperator ¶ added in v0.0.2
type ObjectWithTripleTildeBinOperator interface {
BinOpTripleTilde(vm *VM, right Object) (Object, error)
}
ObjectWithTripleTildeBinOperator is implemented by an object that handles the `~~~` binary operator as the left operand.
type ObjectWithXorBinOperator ¶ added in v0.0.2
ObjectWithXorBinOperator is implemented by an object that handles the `^` binary operator as the left operand.
type ObjectWithXorSelfAssignOperator ¶ added in v0.0.2
type ObjectWithXorSelfAssignOperator interface {
SelfAssignOpXor(vm *VM, value Object) (Object, error)
}
ObjectWithXorSelfAssignOperator is implemented by an object that handles the `^=` self-assign operator as the left operand.
type ObjectWithXorUnaryOperator ¶ added in v0.0.2
ObjectWithXorUnaryOperator is implemented by an object that handles the `^` unary operator.
type OpCallFlag ¶
type OpCallFlag byte
const ( OpCallFlagVarArgs OpCallFlag = 1 << iota OpCallFlagNamedArgs OpCallFlagNamedArgsVar )
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 OpIsMain OpNotIsMain OpModule OpGlobals OpPop OpGetFree OpSetFree OpGetLocalPtr OpGetFreePtr OpClosure OpIterInit OpIterNext OpIterNextElse OpIterKey OpIterValue OpLoadModule OpInitModule OpSetupTry OpSetupCatch OpSetupFinally OpThrow OpFinalizer OpReturn OpSetReturn OpSetReturnModule OpDefineLocal OpTrue OpFalse OpYes OpNo OpCallName OpJumpNil OpJumpNotNil OpKeyValueArray OpKeyValue OpCallee OpArgs OpNamedArgs OpTextWriter OpIsNil OpNotIsNil OpNamedParamsVar OpNamedParamValue OpComputedValue OpAddMethod OpExtendModule OpToRawStr OpAddMethodOverride OpAssign )
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
TypesSymbols ParamType
Types ObjectTypes
Var bool
Symbol *SymbolInfo
Usage string
Index int
}
type ParamBuilder ¶ added in v0.0.2
type ParamBuilder struct {
// contains filtered or unexported fields
}
func (*ParamBuilder) Type ¶ added in v0.0.2
func (b *ParamBuilder) Type(typ ...ObjectType) *ParamBuilder
func (*ParamBuilder) Usage ¶ added in v0.0.2
func (b *ParamBuilder) Usage(v string) *ParamBuilder
func (*ParamBuilder) Var ¶ added in v0.0.2
func (b *ParamBuilder) Var() *ParamBuilder
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
func (ParamType) Accept ¶
Accept reports whether obj satisfies the parameter type list. An ObjectType entry is matched by the (resolved) type of obj (assignability); a structural entry (a meti/interface, i.e. a TypeAssigner that is not an ObjectType) is matched by its CanAssign check. An empty list accepts anything.
type ParamTypes ¶ added in v0.0.2
type ParamTypes interface {
fmt.Stringer
zeroer.Zeroer
Items() ObjectTypes
Len() int
Get(int) ObjectType
}
type Params ¶
type Params struct {
Items []*Param
// contains filtered or unexported fields
}
func (*Params) BuildTypes ¶ added in v0.0.2
func (p *Params) BuildTypes() (t ParamsTypes)
func (Params) RequiredCount ¶
type ParamsTypes ¶ added in v0.0.2
type ParamsTypes []ParamTypes
func ParamTypesOfRawCaller ¶ added in v0.0.2
func ParamTypesOfRawCaller(vm *VM, caller Object) (types ParamsTypes, err error)
func (ParamsTypes) String ¶ added in v0.0.2
func (t ParamsTypes) String() string
func (ParamsTypes) Tree ¶ added in v0.0.2
func (t ParamsTypes) Tree() (r *ObjectTypeNode, err error)
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 (i *PipedInvokeIterator) Call(state *IteratorState) (err error)
func (*PipedInvokeIterator) Handler ¶
func (i *PipedInvokeIterator) Handler() func(state *IteratorState) error
func (*PipedInvokeIterator) Input ¶
func (i *PipedInvokeIterator) Input() Object
func (*PipedInvokeIterator) Next ¶
func (i *PipedInvokeIterator) Next(vm *VM, state *IteratorState) (err error)
func (*PipedInvokeIterator) PostCall ¶
func (i *PipedInvokeIterator) PostCall() func(state *IteratorState, ret Object) error
func (*PipedInvokeIterator) PreCall ¶
func (i *PipedInvokeIterator) PreCall() func(k, v Object) (Object, error)
func (*PipedInvokeIterator) Print ¶ added in v0.0.2
func (i *PipedInvokeIterator) Print(state *PrinterState) error
func (*PipedInvokeIterator) SetHandler ¶
func (i *PipedInvokeIterator) SetHandler(handler func(state *IteratorState) error) *PipedInvokeIterator
func (*PipedInvokeIterator) SetPostCall ¶
func (i *PipedInvokeIterator) SetPostCall(postCall func(state *IteratorState, ret Object) error) *PipedInvokeIterator
func (*PipedInvokeIterator) SetPreCall ¶
func (i *PipedInvokeIterator) SetPreCall(preCall func(k, v Object) (Object, error)) *PipedInvokeIterator
func (*PipedInvokeIterator) SetType ¶
func (i *PipedInvokeIterator) SetType(typ ObjectType) *PipedInvokeIterator
func (*PipedInvokeIterator) Start ¶
func (i *PipedInvokeIterator) Start(vm *VM) (state *IteratorState, err error)
func (*PipedInvokeIterator) Type ¶
func (i *PipedInvokeIterator) Type() ObjectType
type PrintBuilder ¶ added in v0.0.2
type PrintBuilder struct {
// contains filtered or unexported fields
}
func NewPrintBuilder ¶ added in v0.0.2
func NewPrintBuilder(vm *VM, o ...PrinterStateOption) *PrintBuilder
func (*PrintBuilder) MustString ¶ added in v0.0.2
func (b *PrintBuilder) MustString(o ...Object) string
func (*PrintBuilder) Options ¶ added in v0.0.2
func (b *PrintBuilder) Options(f func(opts PrinterStateOptions)) *PrintBuilder
func (*PrintBuilder) Print ¶ added in v0.0.2
func (b *PrintBuilder) Print(w io.Writer, o ...Object) (err error)
func (*PrintBuilder) State ¶ added in v0.0.2
func (b *PrintBuilder) State(f func(s *PrinterState)) *PrintBuilder
type PrintStateDictEntries ¶ added in v0.0.2
type PrintStateDictEntries []*PrintStateDictEntry
func (PrintStateDictEntries) Sort ¶ added in v0.0.2
func (s PrintStateDictEntries) Sort(typ PrintStateOptionSortType)
type PrintStateDictEntry ¶ added in v0.0.2
type PrintStateOptionSortType ¶
type PrintStateOptionSortType uint8
const ( PrintStateOptionSortTypeAuto PrintStateOptionSortType = iota PrintStateOptionSortTypeAscending PrintStateOptionSortTypeDescending )
type Printabler ¶ added in v0.0.2
type Printabler interface {
Print(state *PrinterState) error
}
type PrinterState ¶
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) Do ¶ added in v0.0.2
func (s *PrinterState) Do(f func(s *PrinterState)) *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) GoWriter ¶ added in v0.0.2
func (s *PrinterState) GoWriter() io.Writer
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) OnVisite ¶ added in v0.0.2
func (s *PrinterState) OnVisite(f func(old func(o Object) (done func())) func(o Object) (done func()))
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() PrinterStateOptions
func (*PrinterState) ParseOptions ¶ added in v0.0.2
func (s *PrinterState) ParseOptions(na *NamedArgs) *PrinterState
func (*PrinterState) Print ¶
func (s *PrinterState) Print(o Object) (err error)
func (*PrinterState) PrintArray ¶ added in v0.0.2
func (*PrinterState) PrintDictEntries ¶ added in v0.0.2
func (s *PrinterState) PrintDictEntries(entries PrintStateDictEntries) (err error)
func (*PrinterState) PrintFromArgs ¶
func (s *PrinterState) PrintFromArgs(sep []byte, args Args) (err error)
func (*PrinterState) PrintIndent ¶
func (s *PrinterState) PrintIndent()
func (*PrinterState) PrintKey ¶ added in v0.0.2
func (s *PrinterState) PrintKey(o Object) (err error)
func (*PrinterState) PrintKeySafe ¶ added in v0.0.2
func (s *PrinterState) PrintKeySafe(safe bool, o Object) (err error)
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) PrintPairs ¶ added in v0.0.2
func (*PrinterState) PrintValues ¶ added in v0.0.2
func (*PrinterState) QuoteNextStr ¶ added in v0.0.2
func (s *PrinterState) QuoteNextStr(level int64)
func (*PrinterState) Repr ¶ added in v0.0.2
func (s *PrinterState) Repr(o Object) error
func (*PrinterState) SkipDepth ¶
func (s *PrinterState) SkipDepth() bool
func (*PrinterState) SkipNexDepth ¶ added in v0.0.2
func (s *PrinterState) SkipNexDepth() 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) Update ¶ added in v0.0.2
func (s *PrinterState) Update() *PrinterState
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) WithRepr ¶ added in v0.0.2
func (s *PrinterState) WithRepr(cb func(s *PrinterState) error) error
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
func (*PrinterState) WithoutRepr ¶ added in v0.0.2
func (s *PrinterState) WithoutRepr(cb func(s *PrinterState) error) error
func (*PrinterState) WrapIndentedReprString ¶ added in v0.0.2
func (s *PrinterState) WrapIndentedReprString(str string) func()
func (*PrinterState) WrapRepr ¶ added in v0.0.2
func (s *PrinterState) WrapRepr(o Object) func()
func (*PrinterState) WrapReprString ¶ added in v0.0.2
func (s *PrinterState) WrapReprString(str string) func()
func (*PrinterState) Write ¶
func (s *PrinterState) Write(b []byte) (n int, err error)
Write is the function to call to emit formatted output to be printed.
func (*PrinterState) WriteByte ¶ added in v0.0.2
func (s *PrinterState) WriteByte(c byte) (err error)
func (*PrinterState) WriteString ¶ added in v0.0.2
func (s *PrinterState) WriteString(b string) (err error)
type PrinterStateOption ¶
type PrinterStateOption func(s *PrinterState)
func PrinterStateWithContext ¶
func PrinterStateWithContext(ctx context.Context) PrinterStateOption
func PrinterStateWithOptions ¶
func PrinterStateWithOptions(options PrinterStateOptions) PrinterStateOption
func PrinterStateWithOptionsFromNamedArgs ¶ added in v0.0.2
func PrinterStateWithOptionsFromNamedArgs(na *NamedArgs) PrinterStateOption
type PrinterStateOptions ¶ added in v0.0.2
func (PrinterStateOptions) Anonymous ¶ added in v0.0.2
func (o PrinterStateOptions) Anonymous() (v bool, ok bool)
func (PrinterStateOptions) Backup ¶ added in v0.0.2
func (o PrinterStateOptions) Backup(key string) (restore func())
func (PrinterStateOptions) BytesToHex ¶ added in v0.0.2
func (o PrinterStateOptions) BytesToHex() (v bool, ok bool)
func (PrinterStateOptions) DefaultIndent ¶ added in v0.0.2
func (o PrinterStateOptions) DefaultIndent()
func (PrinterStateOptions) Dict ¶ added in v0.0.2
func (o PrinterStateOptions) Dict() Dict
func (PrinterStateOptions) Indent ¶ added in v0.0.2
func (o PrinterStateOptions) Indent() (v string, ok bool)
func (PrinterStateOptions) Indexes ¶ added in v0.0.2
func (o PrinterStateOptions) Indexes() (v bool, ok bool)
func (PrinterStateOptions) IsAnonymous ¶ added in v0.0.2
func (o PrinterStateOptions) IsAnonymous() (v bool)
func (PrinterStateOptions) IsBytesToHex ¶ added in v0.0.2
func (o PrinterStateOptions) IsBytesToHex() (is bool)
func (PrinterStateOptions) IsIndexes ¶ added in v0.0.2
func (o PrinterStateOptions) IsIndexes() (v bool)
func (PrinterStateOptions) IsQuoteStr ¶ added in v0.0.2
func (o PrinterStateOptions) IsQuoteStr() (is bool)
func (PrinterStateOptions) IsSortKeys ¶ added in v0.0.2
func (o PrinterStateOptions) IsSortKeys() (v PrintStateOptionSortType)
func (PrinterStateOptions) IsTypesAsFullNames ¶ added in v0.0.2
func (o PrinterStateOptions) IsTypesAsFullNames() (v bool)
func (PrinterStateOptions) IsZeros ¶ added in v0.0.2
func (o PrinterStateOptions) IsZeros() (v bool)
func (PrinterStateOptions) MaxDepth ¶ added in v0.0.2
func (o PrinterStateOptions) MaxDepth() (v int64, ok bool)
func (PrinterStateOptions) QuoteStr ¶ added in v0.0.2
func (o PrinterStateOptions) QuoteStr() (v bool, ok bool)
func (PrinterStateOptions) Raw ¶ added in v0.0.2
func (o PrinterStateOptions) Raw() (v bool, ok bool)
func (PrinterStateOptions) Repr ¶ added in v0.0.2
func (o PrinterStateOptions) Repr() (v bool, ok bool)
func (PrinterStateOptions) SetAnonymous ¶ added in v0.0.2
func (o PrinterStateOptions) SetAnonymous(v bool)
func (PrinterStateOptions) SetBytesToHex ¶ added in v0.0.2
func (o PrinterStateOptions) SetBytesToHex(v bool)
func (PrinterStateOptions) SetIndent ¶ added in v0.0.2
func (o PrinterStateOptions) SetIndent(v Object)
func (PrinterStateOptions) SetIndexes ¶ added in v0.0.2
func (o PrinterStateOptions) SetIndexes(v bool)
func (PrinterStateOptions) SetMaxDepth ¶ added in v0.0.2
func (o PrinterStateOptions) SetMaxDepth(v int64)
func (PrinterStateOptions) SetQuoteStr ¶ added in v0.0.2
func (o PrinterStateOptions) SetQuoteStr(v bool)
func (PrinterStateOptions) SetRaw ¶ added in v0.0.2
func (o PrinterStateOptions) SetRaw(v bool)
func (PrinterStateOptions) SetRepr ¶ added in v0.0.2
func (o PrinterStateOptions) SetRepr(v bool)
func (PrinterStateOptions) SetSortKeys ¶ added in v0.0.2
func (o PrinterStateOptions) SetSortKeys(v PrintStateOptionSortType)
func (PrinterStateOptions) SetTrimEmbedPath ¶ added in v0.0.2
func (o PrinterStateOptions) SetTrimEmbedPath(v Array)
func (PrinterStateOptions) SetTypesAsFullNames ¶ added in v0.0.2
func (o PrinterStateOptions) SetTypesAsFullNames(v bool)
func (PrinterStateOptions) SetZeros ¶ added in v0.0.2
func (o PrinterStateOptions) SetZeros(v bool)
func (PrinterStateOptions) SortKeys ¶ added in v0.0.2
func (o PrinterStateOptions) SortKeys() (v PrintStateOptionSortType, ok bool)
func (PrinterStateOptions) TrimEmbedPath ¶ added in v0.0.2
func (o PrinterStateOptions) TrimEmbedPath() (v Array, ok bool)
func (PrinterStateOptions) TypesAsFullNames ¶ added in v0.0.2
func (o PrinterStateOptions) TypesAsFullNames() (v bool, ok bool)
func (PrinterStateOptions) WithAnonymous ¶ added in v0.0.2
func (o PrinterStateOptions) WithAnonymous() PrinterStateOptions
func (PrinterStateOptions) WithBackup ¶ added in v0.0.2
func (o PrinterStateOptions) WithBackup(key string, value Object) (restore func())
func (PrinterStateOptions) WithBytesToHex ¶ added in v0.0.2
func (o PrinterStateOptions) WithBytesToHex()
func (PrinterStateOptions) WithIndent ¶ added in v0.0.2
func (o PrinterStateOptions) WithIndent() PrinterStateOptions
func (PrinterStateOptions) WithIndexes ¶ added in v0.0.2
func (o PrinterStateOptions) WithIndexes() PrinterStateOptions
func (PrinterStateOptions) WithMaxDepth ¶ added in v0.0.2
func (o PrinterStateOptions) WithMaxDepth(v int64) PrinterStateOptions
func (PrinterStateOptions) WithQuoteStr ¶ added in v0.0.2
func (o PrinterStateOptions) WithQuoteStr()
func (PrinterStateOptions) WithRaw ¶ added in v0.0.2
func (o PrinterStateOptions) WithRaw()
func (PrinterStateOptions) WithRepr ¶ added in v0.0.2
func (o PrinterStateOptions) WithRepr() PrinterStateOptions
func (PrinterStateOptions) WithTrimEmbedPath ¶ added in v0.0.2
func (o PrinterStateOptions) WithTrimEmbedPath(v Array) PrinterStateOptions
func (PrinterStateOptions) WithTypesAsFullNames ¶ added in v0.0.2
func (o PrinterStateOptions) WithTypesAsFullNames() PrinterStateOptions
func (PrinterStateOptions) WithZeros ¶ added in v0.0.2
func (o PrinterStateOptions) WithZeros() PrinterStateOptions
func (PrinterStateOptions) Zeros ¶ added in v0.0.2
func (o PrinterStateOptions) Zeros() (v bool, ok bool)
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 Prop ¶ added in v0.0.2
type Prop struct {
Module *ModuleSpec
PropName string
// contains filtered or unexported fields
}
Prop is a named, callable Object whose invocations are dispatched to getter and setter methods held in its FuncSpec. Calling it with no arguments runs the getter; calling it with one argument runs the setter whose parameter type matches the argument. It implements CallerObject, so a Prop value can be called directly like a function.
func NewProp ¶ added in v0.0.2
func NewProp(module *ModuleSpec, name string) *Prop
NewProp returns a method-less Prop named name bound to module. Use AddGetter, AddSetter or AddMethodByTypes to attach behaviour.
func (*Prop) Add ¶ added in v0.0.2
func (p *Prop) Add(handler CallerObject, argTypes ParamsTypes) (err error)
func (*Prop) AddGetter ¶ added in v0.0.2
func (p *Prop) AddGetter(v Object, onAdd func(method *TypedCallerMethod) error) (err error)
func (*Prop) AddMethodByTypes ¶ added in v0.0.2
func (p *Prop) AddMethodByTypes(_ *VM, argTypes ParamsTypes, handler CallerObject, override bool, onAdd func(method *TypedCallerMethod) error) error
AddMethodByTypes register prop methods. - **getter** no have params and return value: `handler() <ret>` - **setter** have one param and not return value: `handler(v)`
func (*Prop) AddSetter ¶ added in v0.0.2
func (p *Prop) AddSetter(v Object, valueType ParamTypes, override bool, onAdd func(method *TypedCallerMethod) error) (err error)
func (*Prop) Call ¶ added in v0.0.2
Call dispatches a prop invocation through its FuncSpec methods (like *Func): no args invokes the getter, one arg the matching setter.
func (*Prop) FuncSpecName ¶ added in v0.0.2
func (*Prop) GetModule ¶ added in v0.0.2
func (p *Prop) GetModule() *ModuleSpec
func (*Prop) Print ¶ added in v0.0.2
func (p *Prop) Print(state *PrinterState) (err error)
func (*Prop) SetModule ¶ added in v0.0.2
func (p *Prop) SetModule(m *ModuleSpec)
func (*Prop) Type ¶ added in v0.0.2
func (p *Prop) Type() ObjectType
type Range ¶ added in v0.0.2
Range is an iterable produced by the `..` operator or the Range(from, to; step) constructor. It yields values from From toward To (inclusive), advancing by Step in the direction of To. From and To share an element kind; Step is a number for numeric/char ranges and a duration for temporal ranges (nil selects the default: 1 for numbers, one day for dates/times).
func (*Range) BinOpQuo ¶ added in v0.0.2
BinOpQuo handles `range / step` (ObjectWithQuoBinOperator), returning a new range with that step.
func (*Range) Equal ¶ added in v0.0.2
Equal reports whether right is a range with equal bounds and effective step.
func (*Range) IndexGet ¶ added in v0.0.2
IndexGet exposes the `from` and `to` fields and the `step` method. `r.step()` returns the current step; `r.step(n)` returns a new range with step n.
func (*Range) IsFalsy ¶ added in v0.0.2
IsFalsy always reports false: a range yields at least its From element.
func (*Range) Iterate ¶ added in v0.0.2
Iterate yields the range values; the entry key is the 0-based position and the value is the element.
func (*Range) ToString ¶ added in v0.0.2
ToString renders the range as `from .. to` (with ` / step` when a step is set).
func (*Range) Type ¶ added in v0.0.2
func (o *Range) Type() ObjectType
Type returns the Range builtin type.
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) Print ¶ added in v0.0.2
func (it *RangeIteration) Print(state *PrinterState) error
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 RawCallerWithMethods ¶ added in v0.0.2
type RawCallerWithMethods interface {
MethodCaller
// Caller return the raw caller
Caller() CallerObject
}
type RawStr ¶
type RawStr string
RawStr represents safe string values and implements Object interface.
func (RawStr) BinOpAdd ¶ added in v0.0.2
BinOpAdd concatenates; a non-string/Bytes operand is stringified (ObjectWithAddBinOperator).
func (RawStr) BinOpGreater ¶ added in v0.0.2
func (RawStr) BinOpGreaterEq ¶ added in v0.0.2
func (RawStr) BinOpIn ¶ added in v0.0.2
BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v occurs as a substring of o, like Str.BinOpIn.
func (RawStr) BinOpLessEq ¶ added in v0.0.2
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) Name ¶ added in v0.0.2
func (r *ReflectFunc) Name() string
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(state *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) Print ¶ added in v0.0.2
func (o *ReflectSlice) Print(state *PrinterState) (err error)
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) Name ¶ added in v0.0.2
func (s *ReflectStruct) Name() string
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) ReprTypeName ¶ added in v0.0.2
func (s *ReflectStruct) ReprTypeName() string
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)
InstancePrintFunc func(state *PrinterState, obj *ReflectValue) error
StaticMethods map[string]CallerObject
*FuncSpec
// contains filtered or unexported fields
}
func NewReflectType ¶
func NewReflectType(t any) (rt *ReflectType)
func ReflectTypeFor ¶ added in v0.0.2
func ReflectTypeFor[T any]() *ReflectType
func ReflectTypeOf ¶
func ReflectTypeOf(v any) (rt *ReflectType)
func (*ReflectType) AssignTo ¶ added in v0.0.2
func (t *ReflectType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
func (*ReflectType) CanAssign ¶ added in v0.0.2
func (t *ReflectType) CanAssign(obj Object) (bool, error)
func (*ReflectType) Equal ¶
func (t *ReflectType) Equal(right Object) bool
func (*ReflectType) Fields ¶
func (t *ReflectType) Fields() (fields Dict)
func (*ReflectType) Fqn ¶
func (t *ReflectType) Fqn() string
func (*ReflectType) FullName ¶ added in v0.0.2
func (t *ReflectType) FullName() string
func (*ReflectType) FuncSpecName ¶ added in v0.0.2
func (t *ReflectType) FuncSpecName() string
func (ReflectType) GadObjectType ¶ added in v0.0.2
func (ReflectType) GadObjectType()
func (*ReflectType) GetRMethods ¶
func (t *ReflectType) GetRMethods() map[string]*ReflectMethod
func (*ReflectType) Name ¶
func (t *ReflectType) Name() string
func (*ReflectType) NewDefault ¶ added in v0.0.2
func (t *ReflectType) NewDefault(c Call) (Object, error)
func (*ReflectType) Print ¶
func (t *ReflectType) Print(state *PrinterState) (err error)
func (*ReflectType) StaticMethod ¶ added in v0.0.2
func (t *ReflectType) StaticMethod(name string, co CallerObject)
func (*ReflectType) String ¶
func (t *ReflectType) String() string
func (*ReflectType) ToString ¶
func (t *ReflectType) ToString() string
func (*ReflectType) Type ¶
func (t *ReflectType) Type() ObjectType
type ReflectValue ¶
type ReflectValue struct {
RType *ReflectType
RValue reflect.Value
Options *ReflectValueOptions
*FuncSpec
// 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) 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)
Example (StructuralContract) ¶
ExampleNewReflectValue_structuralContract embeds a Go value in a script and checks it against a Gad interface built from its Go fields and methods.
// rfPerson is a Go struct with a Name/Age field and a Greet() method.
rv, _ := NewReflectValue(rfPerson{Name: "Ann", Age: 30})
builtins := NewBuiltins()
st := NewSymbolTable(builtins.NameSet)
_, _ = st.DefineGlobals([]string{"p"})
src := `
interface Greeter { Name str; Greet() <str> }
p :: Greeter // rejected unless p has the Name field and Greet()
println(p.Greet())
`
_, bc, err := Compile(st, []byte(src), CompileOptions{})
if err != nil {
panic(err)
}
vm := NewVM(builtins.Build(), bc)
if _, err = vm.RunOpts(&RunOpts{StdOut: os.Stdout, Globals: Dict{"p": rv}}); err != nil {
panic(err)
}
Output: hi Ann
type Regexp ¶
func (*Regexp) BinOpDoubleTilde ¶ added in v0.0.2
func (*Regexp) BinOpTilde ¶ added in v0.0.2
BinOpTilde (`re ~ s`) matches, BinOpDoubleTilde (`re ~~ s`) finds the first match, BinOpTripleTilde (`re ~~~ s`) finds all, and BinOpOr (`re | repl`) yields a unary replacer. These implement the per-operator interfaces.
func (*Regexp) BinOpTripleTilde ¶ added in v0.0.2
func (*Regexp) Print ¶ added in v0.0.2
func (o *Regexp) Print(state *PrinterState) error
func (*Regexp) Replace ¶ added in v0.0.2
Replace replaces all matches of o in subject with repl. repl may be a Str/RawStr/Bytes template (Go's $1 / ${name} group expansion applies) or a callable returning each replacement. The callable is invoked once per match with the matched substring as the positional argument and two named arguments: `m`, the full submatch (whole match + capture groups, so groups are `m[1]`, `m[2]`, …), and `re`, the regexp itself.
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) IndexGet ¶ added in v0.0.2
func (o RegexpBytesResult) IndexGet(_ *VM, index Object) (Object, error)
IndexGet returns submatch i as bytes (i == 0 is the full match).
func (RegexpBytesResult) IsFalsy ¶
func (o RegexpBytesResult) IsFalsy() bool
func (RegexpBytesResult) Iterate ¶ added in v0.0.2
func (o RegexpBytesResult) Iterate(_ *VM, na *NamedArgs) Iterator
func (RegexpBytesResult) Length ¶ added in v0.0.2
func (o RegexpBytesResult) Length() int
Length returns the number of submatches (the full match plus capture groups).
func (RegexpBytesResult) Print ¶ added in v0.0.2
func (o RegexpBytesResult) Print(state *PrinterState) error
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) IndexGet ¶ added in v0.0.2
func (o RegexpBytesSliceResult) IndexGet(_ *VM, index Object) (Object, error)
IndexGet returns match i, itself a submatch list (full match + groups).
func (RegexpBytesSliceResult) IsFalsy ¶
func (o RegexpBytesSliceResult) IsFalsy() bool
func (RegexpBytesSliceResult) Iterate ¶ added in v0.0.2
func (o RegexpBytesSliceResult) Iterate(_ *VM, na *NamedArgs) Iterator
func (RegexpBytesSliceResult) Length ¶ added in v0.0.2
func (o RegexpBytesSliceResult) Length() int
Length returns the number of matches.
func (RegexpBytesSliceResult) Print ¶ added in v0.0.2
func (o RegexpBytesSliceResult) Print(state *PrinterState) error
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) IndexGet ¶ added in v0.0.2
func (o RegexpStrsResult) IndexGet(_ *VM, index Object) (Object, error)
IndexGet returns submatch i (i == 0 is the full match, i >= 1 are the capture groups), so groups are accessed like an array.
func (RegexpStrsResult) IsFalsy ¶
func (o RegexpStrsResult) IsFalsy() bool
func (RegexpStrsResult) Iterate ¶ added in v0.0.2
func (o RegexpStrsResult) Iterate(_ *VM, na *NamedArgs) Iterator
func (RegexpStrsResult) Length ¶ added in v0.0.2
func (o RegexpStrsResult) Length() int
Length returns the number of submatches (the full match plus capture groups).
func (RegexpStrsResult) Print ¶ added in v0.0.2
func (o RegexpStrsResult) Print(state *PrinterState) error
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) IndexGet ¶ added in v0.0.2
func (o RegexpStrsSliceResult) IndexGet(_ *VM, index Object) (Object, error)
IndexGet returns match i, itself a submatch list (full match + groups).
func (RegexpStrsSliceResult) IsFalsy ¶
func (o RegexpStrsSliceResult) IsFalsy() bool
func (RegexpStrsSliceResult) Iterate ¶ added in v0.0.2
func (o RegexpStrsSliceResult) Iterate(_ *VM, na *NamedArgs) Iterator
func (RegexpStrsSliceResult) Length ¶ added in v0.0.2
func (o RegexpStrsSliceResult) Length() int
Length returns the number of matches.
func (RegexpStrsSliceResult) Print ¶ added in v0.0.2
func (o RegexpStrsSliceResult) Print(state *PrinterState) error
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 ReprTypeNamer ¶ added in v0.0.2
type ReprTypeNamer interface {
ReprTypeName() string
}
type ReturnVar ¶ added in v0.0.2
type ReturnVar struct {
Name string
TypesSymbols ParamType
Types ObjectTypes
}
type ReturnVars ¶ added in v0.0.2
type ReturnVars []*ReturnVar
func (ReturnVars) String ¶ added in v0.0.2
func (v ReturnVars) String() string
String renders a function return-type list as " <T1, T2, ...>". It returns an empty string when there are no return types.
func (ReturnVars) Types ¶ added in v0.0.2
func (v ReturnVars) Types() (t []ObjectTypes)
func (ReturnVars) VMTypes ¶ added in v0.0.2
func (v ReturnVars) VMTypes(vm *VM) (t []ObjectTypes, err error)
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 SelfAssignOperatorType ¶
func (SelfAssignOperatorType) AssignTo ¶ added in v0.0.2
func (b SelfAssignOperatorType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
func (SelfAssignOperatorType) CanAssign ¶ added in v0.0.2
func (b SelfAssignOperatorType) CanAssign(obj Object) (bool, error)
func (SelfAssignOperatorType) Equal ¶
func (b SelfAssignOperatorType) Equal(right Object) bool
func (SelfAssignOperatorType) Fields ¶
func (SelfAssignOperatorType) Fields() Dict
func (SelfAssignOperatorType) FullName ¶ added in v0.0.2
func (b SelfAssignOperatorType) FullName() string
func (SelfAssignOperatorType) GadObjectType ¶ added in v0.0.2
func (b SelfAssignOperatorType) GadObjectType()
func (SelfAssignOperatorType) Getters ¶
func (SelfAssignOperatorType) Getters() Dict
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, module *ModuleSpec, 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.
func (*SourceModule) Import ¶
func (m *SourceModule) Import(_ context.Context, module *ModuleSpec) (any, string, error)
Import returns a module source code.
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)
// contains filtered or unexported fields
}
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 StaticBuiltins ¶ added in v0.0.2
type StaticBuiltins struct {
// contains filtered or unexported fields
}
func (*StaticBuiltins) ArgsInvoker ¶ added in v0.0.2
func (b *StaticBuiltins) ArgsInvoker(t BuiltinType, c Call) func(arg ...Object) (Object, error)
func (*StaticBuiltins) Builtins ¶ added in v0.0.2
func (b *StaticBuiltins) Builtins() *Builtins
func (*StaticBuiltins) Call ¶ added in v0.0.2
func (b *StaticBuiltins) Call(t BuiltinType, c Call) (Object, error)
func (*StaticBuiltins) Caller ¶ added in v0.0.2
func (b *StaticBuiltins) Caller(t BuiltinType) CallerObject
func (*StaticBuiltins) Get ¶ added in v0.0.2
func (b *StaticBuiltins) Get(t BuiltinType) Object
func (*StaticBuiltins) Invoker ¶ added in v0.0.2
func (b *StaticBuiltins) Invoker(t BuiltinType, c Call) func() (Object, error)
func (*StaticBuiltins) OpMethoded ¶ added in v0.0.2
func (b *StaticBuiltins) OpMethoded(bt BuiltinType) callerMethoded
OpMethoded returns operator builtin bt as a callerMethoded (or nil) via the precomputed slice, falling back to a map lookup if the cache is absent.
func (*StaticBuiltins) Set ¶ added in v0.0.2
func (b *StaticBuiltins) Set(name string, obj Object) BuiltinType
func (*StaticBuiltins) Update ¶ added in v0.0.2
func (b *StaticBuiltins) Update(key BuiltinType, value Object)
type StaticTypeKey ¶ added in v0.0.2
type StaticTypeKey uint16
func NewStaticType ¶ added in v0.0.2
func NewStaticType(objectType ObjectType) StaticTypeKey
type StaticTypes ¶ added in v0.0.2
type StaticTypes struct {
// contains filtered or unexported fields
}
func NewStaticTypes ¶ added in v0.0.2
func NewStaticTypes() *StaticTypes
func (*StaticTypes) Add ¶ added in v0.0.2
func (st *StaticTypes) Add(objectType ObjectType) StaticTypeKey
func (StaticTypes) Clone ¶ added in v0.0.2
func (st StaticTypes) Clone() *StaticTypes
func (*StaticTypes) Get ¶ added in v0.0.2
func (st *StaticTypes) Get(key StaticTypeKey) ObjectType
type Str ¶
type Str string
Str represents string values and implements Object interface.
func (Str) BinOpAdd ¶ added in v0.0.2
BinOpAdd concatenates; a non-Str/Bytes operand is stringified (ObjectWithAddBinOperator).
func (Str) BinOpGreater ¶ added in v0.0.2
func (Str) BinOpGreaterEq ¶ added in v0.0.2
func (Str) BinOpIn ¶ added in v0.0.2
BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v occurs as a substring of o. A char needle matches its rune (so `'e' in "hello"`) and a str needle matches a substring (`"ell" in "hello"`); any other needle is compared by its string form, mirroring the `contains` builtin.
func (Str) BinOpLessEq ¶ added in v0.0.2
func (Str) Print ¶ added in v0.0.2
func (o Str) Print(state *PrinterState) error
func (Str) Type ¶
func (o Str) Type() ObjectType
type StringIndexSetter ¶ added in v0.0.2
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 ScopeModule // ScopeConstant references a bytecode constant by Index. Used for a // structural type reference (a `meti`/`interface` literal compiled to a // constant and used as a parameter/field type). ScopeConstant )
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 BuiltinsNameSet) *SymbolTable
NewSymbolTable creates new symbol table object.
func (*SymbolTable) Builtins ¶
func (st *SymbolTable) Builtins() BuiltinsNameSet
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) DefineParams ¶ added in v0.0.2
func (st *SymbolTable) DefineParams(positional *Params, named *NamedParams) (err error)
DefineParams sets parameters defined in the scope with then variables. This can be called only once.
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) LocalNames ¶ added in v0.0.2
func (st *SymbolTable) LocalNames() map[int]string
LocalNames returns the recorded slot index -> name map for this function scope (debug symbols). The returned map must not be mutated.
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) 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) BinOpAdd ¶ added in v0.0.2
The binary operators delegate to the guarded dict under a read lock, mirroring Dict's per-operator ObjectWith{Op}BinOperator implementations.
func (*SyncDict) BinOpGreater ¶ added in v0.0.2
func (*SyncDict) BinOpGreaterEq ¶ added in v0.0.2
func (*SyncDict) BinOpIn ¶ added in v0.0.2
Contains reports whether v is a key of the dict (`v in syncDict`). BinOpIn implements the `in` operator (ObjectWithInBinOperator): reports whether v is a key of the guarded dict.
func (*SyncDict) BinOpLessEq ¶ added in v0.0.2
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 TestBytecodesEqualOptions ¶ added in v0.0.2
type TestBytecodesEqualOptions struct {
NoInsertMainModule bool
}
type Time ¶ added in v0.0.2
Time represents time values and implements Object interface.
func (*Time) BinOpAdd ¶ added in v0.0.2
BinOpAdd shifts the time forward by an Int (nanoseconds) or Duration.
func (*Time) BinOpGreater ¶ added in v0.0.2
func (*Time) BinOpGreaterEq ¶ added in v0.0.2
func (*Time) BinOpLessEq ¶ added in v0.0.2
func (*Time) BinOpSub ¶ added in v0.0.2
BinOpSub shifts back by an Int/Duration, or returns the gap between two times.
func (*Time) MarshalBinary ¶ added in v0.0.2
MarshalBinary implements encoding.BinaryMarshaler interface.
func (*Time) MarshalJSON ¶ added in v0.0.2
MarshalJSON implements json.JSONMarshaler interface.
func (*Time) Print ¶ added in v0.0.2
func (o *Time) Print(s *PrinterState) error
Print writes the time as a leaf value. *Time is a primitive (see IsPrimitive), so it must print as its ToString rather than letting the generic printer recurse into the wrapped time.Time internals.
func (*Time) Type ¶ added in v0.0.2
func (*Time) Type() ObjectType
func (*Time) UnmarshalBinary ¶ added in v0.0.2
UnmarshalBinary implements encoding.BinaryUnmarshaler interface.
func (*Time) UnmarshalJSON ¶ added in v0.0.2
UnmarshalJSON implements json.JSONUnmarshaler interface.
type ToArrayAppenderObject ¶
type ToArrayConveter ¶
type ToArrayConveter interface {
ToArray() Array
}
type ToDictConverter ¶ added in v0.0.2
type ToDictConverter interface {
ToDict() Dict
}
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 {
Parent ObjectType
Static Dict
Module *ModuleSpec
*FuncSpec
// contains filtered or unexported fields
}
func NewType ¶ added in v0.0.2
func NewType(typeName string, parent ...ObjectType) (t *Type)
func (*Type) Caller ¶
func (t *Type) Caller() CallerObject
func (*Type) Constructor ¶
func (t *Type) Constructor() CallerObject
func (*Type) FuncSpecName ¶ added in v0.0.2
func (Type) GadObjectType ¶ added in v0.0.2
func (Type) GadObjectType()
func (*Type) GetModule ¶ added in v0.0.2
func (t *Type) GetModule() *ModuleSpec
func (*Type) Print ¶ added in v0.0.2
func (t *Type) Print(state *PrinterState) (err error)
func (*Type) Type ¶
func (t *Type) Type() ObjectType
func (*Type) WithConstructor ¶
func (t *Type) WithConstructor(handler CallerObject) *Type
func (*Type) WithStatic ¶ added in v0.0.2
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)
func (*TypeAssertion) Options ¶ added in v0.0.2
func (a *TypeAssertion) Options(opt ...TypeAsssertionOption) *TypeAssertion
type TypeAssertionHandler ¶
type TypeAssertionHandlers ¶
type TypeAssertionHandlers map[string]TypeAssertionHandler
func TypeAssertions ¶ added in v0.0.2
func TypeAssertions(opt ...TypeAsssertionOption) TypeAssertionHandlers
type TypeAssigner ¶ added in v0.0.2
type TypeAssigner interface {
Object
// AssignTo returns obj when obj (of the receiver's kind) is assignable to
// `to`, otherwise an error (ErrIncompatibleCast). It returns obj unchanged on
// success (the value already satisfies the target).
AssignTo(vm *VM, obj Object, to TypeAssigner) (Object, error)
// CanAssign returns if obj can assign to this
CanAssign(obj Object) (bool, error)
}
TypeAssigner is a value that can decide whether another value is assignable to it — the abstraction behind parameter/field type checking. An ObjectType assigns by type (assignability), a *MethodInterface by a structural `implements` check, and a *Interface by structural satisfaction.
type TypeAssignerArray ¶ added in v0.0.2
type TypeAssignerArray []TypeAssigner
TypeAssignerArray is a list of type assigners (e.g. the allowed types of a parameter): ObjectTypes and/or structural types (meti/interface). Named to avoid a clash with the existing TypeAssigners walker function.
type TypeAsssertionOption ¶ added in v0.0.2
type TypeAsssertionOption func(a TypeAssertionHandlers)
func WithArray ¶ added in v0.0.2
func WithArray() TypeAsssertionOption
func WithCallable ¶ added in v0.0.2
func WithCallable() TypeAsssertionOption
func WithFlag ¶ added in v0.0.2
func WithFlag() TypeAsssertionOption
func WithIsAssignable ¶ added in v0.0.2
func WithIsAssignable(types ...ObjectType) TypeAsssertionOption
func WithMethodAdder ¶ added in v0.0.2
func WithMethodAdder() TypeAsssertionOption
func WithMethodCaller ¶ added in v0.0.2
func WithMethodCaller() TypeAsssertionOption
func WithRawCallable ¶ added in v0.0.2
func WithRawCallable() TypeAsssertionOption
type TypedCallerMethod ¶ added in v0.0.2
type TypedCallerMethod struct {
*CallerMethod
// contains filtered or unexported fields
}
func (*TypedCallerMethod) IndexGet ¶ added in v0.0.2
func (o *TypedCallerMethod) IndexGet(vm *VM, index Object) (value Object, err error)
func (*TypedCallerMethod) IsVar ¶ added in v0.0.2
func (o *TypedCallerMethod) IsVar() bool
func (*TypedCallerMethod) Print ¶ added in v0.0.2
func (o *TypedCallerMethod) Print(state *PrinterState) error
func (*TypedCallerMethod) String ¶ added in v0.0.2
func (o *TypedCallerMethod) String() string
func (*TypedCallerMethod) StringTarget ¶ added in v0.0.2
func (o *TypedCallerMethod) StringTarget(target bool) string
func (*TypedCallerMethod) ToString ¶ added in v0.0.2
func (o *TypedCallerMethod) ToString() string
func (*TypedCallerMethod) Types ¶ added in v0.0.2
func (o *TypedCallerMethod) Types() ObjectTypeArray
type TypedCallerMethods ¶ added in v0.0.2
type TypedCallerMethods []*TypedCallerMethod
type TypedCallerObjectWithParamTypes ¶ added in v0.0.2
type TypedCallerObjectWithParamTypes interface {
CallerObject
ParamTypes() ParamsTypes
ReturnVars() ReturnVars
}
TypedCallerObjectWithParamTypes is an interface for objects that can be called with Call method with parameters with types and typed return vars.
type TypedIdent ¶ added in v0.0.2
type TypedIdent struct {
Name string
Types Array
// TypesSymbols holds the parameter's type references as compile-time symbols
// when a func-header value is compiled to a constant (see
// compileFuncHeaderExpr). When set, the resolved Types are produced per-VM on
// demand (resolveTypes) so the shared constant stays immutable and
// thread-safe. Empty for TypedIdent values built at run time (the
// `typedIdent`/`FunctionHeader` builtins), which carry resolved Types.
TypesSymbols ParamType
}
func (*TypedIdent) Equal ¶ added in v0.0.2
func (t *TypedIdent) Equal(right Object) bool
func (*TypedIdent) IndexGet ¶ added in v0.0.2
func (t *TypedIdent) IndexGet(vm *VM, index Object) (value Object, err error)
func (*TypedIdent) IndexSet ¶ added in v0.0.2
func (t *TypedIdent) IndexSet(_ *VM, index, value Object) (err error)
func (*TypedIdent) IsFalsy ¶ added in v0.0.2
func (t *TypedIdent) IsFalsy() bool
func (*TypedIdent) Print ¶ added in v0.0.2
func (t *TypedIdent) Print(state *PrinterState) error
func (*TypedIdent) ToString ¶ added in v0.0.2
func (t *TypedIdent) ToString() string
func (*TypedIdent) Type ¶ added in v0.0.2
func (t *TypedIdent) Type() ObjectType
type Uint ¶
type Uint uint64
Uint represents unsigned integer values and implements Object interface.
func (Uint) BinOpAndNot ¶ added in v0.0.2
func (Uint) BinOpGreater ¶ added in v0.0.2
func (Uint) BinOpGreaterEq ¶ added in v0.0.2
func (Uint) BinOpLessEq ¶ added in v0.0.2
func (Uint) BinOpPow ¶ added in v0.0.2
Uint has no native power; `uint ** float|decimal` promotes to that type.
func (Uint) Type ¶
func (o Uint) Type() ObjectType
type UnaryOperatorType ¶ added in v0.0.2
func (UnaryOperatorType) AssignTo ¶ added in v0.0.2
func (b UnaryOperatorType) AssignTo(_ *VM, obj Object, to TypeAssigner) (Object, error)
func (UnaryOperatorType) CanAssign ¶ added in v0.0.2
func (b UnaryOperatorType) CanAssign(obj Object) (bool, error)
func (UnaryOperatorType) Equal ¶ added in v0.0.2
func (b UnaryOperatorType) Equal(right Object) bool
func (UnaryOperatorType) Fields ¶ added in v0.0.2
func (UnaryOperatorType) Fields() Dict
func (UnaryOperatorType) FullName ¶ added in v0.0.2
func (b UnaryOperatorType) FullName() string
func (UnaryOperatorType) GadObjectType ¶ added in v0.0.2
func (b UnaryOperatorType) GadObjectType()
func (UnaryOperatorType) Getters ¶ added in v0.0.2
func (UnaryOperatorType) Getters() Dict
func (UnaryOperatorType) IsFalsy ¶ added in v0.0.2
func (b UnaryOperatorType) IsFalsy() bool
func (UnaryOperatorType) Methods ¶ added in v0.0.2
func (UnaryOperatorType) Methods() Dict
func (UnaryOperatorType) MethodsDisabled ¶ added in v0.0.2
func (UnaryOperatorType) MethodsDisabled() bool
func (UnaryOperatorType) Name ¶ added in v0.0.2
func (b UnaryOperatorType) Name() string
func (UnaryOperatorType) Setters ¶ added in v0.0.2
func (UnaryOperatorType) Setters() Dict
func (UnaryOperatorType) String ¶ added in v0.0.2
func (b UnaryOperatorType) String() string
func (UnaryOperatorType) ToString ¶ added in v0.0.2
func (b UnaryOperatorType) ToString() string
func (UnaryOperatorType) Token ¶ added in v0.0.2
func (b UnaryOperatorType) Token() token.Token
func (UnaryOperatorType) Type ¶ added in v0.0.2
func (b UnaryOperatorType) Type() ObjectType
type UpDownLines ¶
type UpDownLines struct {
Up, Down int
}
type UserDataStorage ¶
type VM ¶
type VM struct {
StdOut, StdErr *StackWriter
StdIn *StackReader
ObjectToWriter ObjectToWriter
Builtins *StaticBuiltins
*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 ParamsTypes, caller CallerObject, onAdd func(method *TypedCallerMethod) error) (err error)
func (*VM) AddCallerMethodOverride ¶
func (vm *VM) AddCallerMethodOverride(co CallerObject, types ParamsTypes, override bool, caller CallerObject, onAdd func(method *TypedCallerMethod) error) (err error)
func (*VM) CallBuiltin ¶
func (*VM) CurrentModule ¶ added in v0.0.2
func (*VM) CurrentModuleSpec ¶ added in v0.0.2
func (vm *VM) CurrentModuleSpec() *ModuleSpec
func (*VM) DebugAbort ¶ added in v0.0.2
func (vm *VM) DebugAbort()
DebugAbort requests the running VM to stop (equivalent to Abort).
func (*VM) DebugFrames ¶ added in v0.0.2
func (vm *VM) DebugFrames() []DebugFrame
DebugFrames returns the active call frames from outermost to innermost (the current frame is last).
func (*VM) DebugLocalNames ¶ added in v0.0.2
DebugLocalNames returns the debug names of the current frame's local slots (index -> name); entries may be empty when a name is unavailable.
func (*VM) DebugLocals ¶ added in v0.0.2
DebugLocals returns the local variable values of the current frame (dereferencing captured pointers).
func (*VM) DebugOpcode ¶ added in v0.0.2
DebugOpcode returns the opcode about to execute.
func (*VM) DebugSourcePos ¶ added in v0.0.2
DebugSourcePos returns the source position (file/line/column) of the instruction about to execute, or a zero FilePos when unavailable.
func (*VM) Debugger ¶ added in v0.0.2
func (vm *VM) Debugger() DebugStepper
Debugger returns the attached DebugStepper, or nil.
func (*VM) Fork ¶ added in v0.0.2
func (vm *VM) Fork(cf *CompiledFunction, usePool bool) (child *VM)
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) ModuleByIndex ¶ added in v0.0.2
func (*VM) ModuleFromIndex ¶ added in v0.0.2
func (*VM) ResolveType ¶ added in v0.0.2
func (vm *VM) ResolveType(ot ObjectType) ObjectType
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) SetDebugger ¶ added in v0.0.2
func (vm *VM) SetDebugger(d DebugStepper)
SetDebugger attaches d, switching the VM to its debug execution loop on the next run. Pass nil to detach. Must be set before Run/RunOpts.
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 VarObjectType ¶ added in v0.0.2
type VarObjectType struct {
ObjectType
}
func (*VarObjectType) FullName ¶ added in v0.0.2
func (v *VarObjectType) FullName() string
func (*VarObjectType) Name ¶ added in v0.0.2
func (v *VarObjectType) Name() string
func (*VarObjectType) String ¶ added in v0.0.2
func (v *VarObjectType) String() string
type VarParamTypes ¶ added in v0.0.2
type VarParamTypes []ObjectType
func (VarParamTypes) Get ¶ added in v0.0.2
func (t VarParamTypes) Get(i int) ObjectType
func (VarParamTypes) IsZero ¶ added in v0.0.2
func (t VarParamTypes) IsZero() bool
func (VarParamTypes) Items ¶ added in v0.0.2
func (t VarParamTypes) Items() ObjectTypes
func (VarParamTypes) Len ¶ added in v0.0.2
func (t VarParamTypes) Len() int
func (VarParamTypes) String ¶ added in v0.0.2
func (t VarParamTypes) String() string
Source Files
¶
- builtin_operator.go
- builtin_types.go
- builtins.go
- builtins_funcs.go
- builtins_operator_builtins.go
- builtins_operator_methods.go
- builtins_types.go
- builtins_types_constructors.go
- builtins_types_ctor_methods.go
- builtins_zfuncs.go
- bytecode.go
- call.go
- compiler.go
- compiler_class.go
- compiler_defer.go
- compiler_enum.go
- compiler_helper.go
- compiler_module.go
- compiler_node.go
- compiler_nodes.go
- compiler_test_stmt.go
- compiler_with.go
- converter.go
- embedded.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
- methods_default.go
- module_base64.go
- module_callable.go
- module_fmt.go
- module_fmt_scan.go
- module_strings.go
- module_time.go
- module_time_calendar_time.go
- module_time_ctors.go
- module_time_date.go
- module_time_duration.go
- module_time_funcs.go
- module_time_location.go
- module_time_parse.go
- module_time_time.go
- module_time_trunc.go
- module_time_zfuncs.go
- modules.go
- objects.go
- objects_api.go
- objects_api_common.go
- objects_api_converters.go
- objects_api_funcs.go
- objects_class.go
- objects_class_instance.go
- objects_enum.go
- objects_error.go
- objects_func.go
- objects_func_header.go
- objects_interface.go
- objects_io.go
- objects_method_interface.go
- objects_module.go
- objects_namedargs.go
- objects_numeric.go
- objects_print.go
- objects_print_helper.go
- objects_print_options.go
- objects_prop.go
- objects_range.go
- objects_reflect.go
- objects_reflect_iterator.go
- objects_reflect_type.go
- objects_regexp.go
- objects_type_assigner.go
- objectwriter.go
- op_api.go
- op_same.go
- op_unary.go
- op_unary_time.go
- opcodes.go
- optimizer.go
- static_types.go
- symbol_table.go
- transpile.go
- vm.go
- vm_caller.go
- vm_debug.go
- vm_helper.go
- vm_helper_iterator.go
- vm_invoker.go
- vm_io.go
- vm_loop.go
- vm_loop_debug.go
- vm_run.go
- zero.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
build-website
command
Command build-website renders the Gad documentation (./doc) into a static, GitHub-Pages-ready website with client-side search, a light/dark theme and a WebAssembly playground.
|
Command build-website renders the Gad documentation (./doc) into a static, GitHub-Pages-ready website with client-side search, a light/dark theme and a WebAssembly playground. |
|
gad
command
|
|
|
gaddoc
command
|
|
|
internal/pluginsync
Package pluginsync extracts the authoritative Gad language vocabulary (keywords, atoms, constants, builtin functions) from the gad/token packages and keeps the editor plugins (codemirror-gad, prism-gad) in sync with it.
|
Package pluginsync extracts the authoritative Gad language vocabulary (keywords, atoms, constants, builtin functions) from the gad/token packages and keeps the editor plugins (codemirror-gad, prism-gad) in sync with it. |
|
mkcallable
command
|
|
|
mkoptypes
command
|
|
|
update-codemirror-plugin
command
Command update-codemirror-plugin keeps web/codemirror-gad in sync with the Gad language: it adds any keywords/atoms/constants/builtins the plugin is missing and reports the language commits since the plugin was last updated.
|
Command update-codemirror-plugin keeps web/codemirror-gad in sync with the Gad language: it adds any keywords/atoms/constants/builtins the plugin is missing and reports the language commits since the plugin was last updated. |
|
update-delve
command
Command update-delve keeps the VM's debug execution loop (vm_loop_debug.go) in sync with the production loop (vm_loop.go).
|
Command update-delve keeps the VM's debug execution loop (vm_loop_debug.go) in sync with the production loop (vm_loop.go). |
|
update-prism-plugin
command
Command update-prism-plugin keeps web/prism-gad in sync with the Gad language: it adds any keywords/atoms/builtins the grammar is missing and reports the language commits since the plugin was last updated.
|
Command update-prism-plugin keeps web/prism-gad in sync with the Gad language: it adds any keywords/atoms/builtins the grammar is missing and reports the language commits since the plugin was last updated. |
|
update-vscode-plugin
command
Command update-vscode-plugin regenerates the VS Code extension's TextMate grammar (editors/vscode-gad/syntaxes/gad.tmLanguage.json) from the current Gad language vocabulary, so highlighting stays in sync with the compiler.
|
Command update-vscode-plugin regenerates the VS Code extension's TextMate grammar (editors/vscode-gad/syntaxes/gad.tmLanguage.json) from the current Gad language vocabulary, so highlighting stays in sync with the compiler. |
|
Package debug provides a breakpoint/stepping debugger engine for the Gad VM.
|
Package debug provides a breakpoint/stepping debugger engine for the Gad VM. |
|
fmt
Package fmt provides the importable `fmt` module.
|
Package fmt provides the importable `fmt` module. |
|
strings
Package strings provides the importable `strings` module.
|
Package strings provides the importable `strings` module. |
|
test
Package test provides the `test` builtin module and the `T` context passed to test/benchmark functions run by `gad test`.
|
Package test provides the `test` builtin module and the `T` context passed to test/benchmark functions run by `gad test`. |
|
time
Package time provides the importable `time` module.
|
Package time provides the importable `time` module. |
|
web
|
|
|
app
Package webapp provides access to the built web UI.
|
Package webapp provides access to the built web UI. |
|
gadbridge
Package gadbridge exposes Gad's format, diagnose and run capabilities behind a small, JSON-friendly API.
|
Package gadbridge exposes Gad's format, diagnose and run capabilities behind a small, JSON-friendly API. |
|
ide
Package ide implements the backend for `gad ide`: a small HTTP server that turns a workspace directory into a multi-file editing environment.
|
Package ide implements the backend for `gad ide`: a small HTTP server that turns a workspace directory into a multi-file editing environment. |
|
server
command
Command server is the backend example for the Gad CodeMirror integration.
|
Command server is the backend example for the Gad CodeMirror integration. |
|
wasm
command
Command wasm compiles the Gad bridge to WebAssembly.
|
Command wasm compiles the Gad bridge to WebAssembly. |