Versions in this module Expand all Collapse all v2 v2.6.4 Mar 6, 2021 Changes in this version + const GlobalsSize + const MaxFrames + const StackSize + var ErrBytesLimit = errors.New("exceeding bytes size limit") + var ErrIndexOutOfBounds = errors.New("index out of bounds") + var ErrInvalidIndexOnError = errors.New("invalid index on error") + var ErrInvalidIndexType = errors.New("invalid index type") + var ErrInvalidIndexValueType = errors.New("invalid index value type") + var ErrInvalidOperator = errors.New("invalid operator") + var ErrNotImplemented = errors.New("not implemented") + var ErrNotIndexAssignable = errors.New("not index-assignable") + var ErrNotIndexable = errors.New("not indexable") + var ErrObjectAllocLimit = errors.New("object allocation limit exceeded") + var ErrStackOverflow = errors.New("stack overflow") + var ErrStringLimit = errors.New("exceeding string size limit") + var ErrWrongNumArguments = errors.New("wrong number of arguments") + var MaxBytesLen = 2147483647 + var MaxStringLen = 2147483647 + func CountObjects(o Object) (c int) + func Format(format string, a ...Object) (string, error) + func FormatInstructions(b []byte, posOffset int) []string + func MakeInstruction(opcode parser.Opcode, operands ...int) []byte + func ToBool(o Object) (v bool, ok bool) + func ToByteSlice(o Object) (v []byte, ok bool) + func ToFloat64(o Object) (v float64, ok bool) + func ToInt(o Object) (v int, ok bool) + func ToInt64(o Object) (v int64, ok bool) + func ToInterface(o Object) (res interface{}) + func ToRune(o Object) (v rune, ok bool) + func ToString(o Object) (v string, ok bool) + func ToTime(o Object) (v time.Time, ok bool) + type Array struct + Value []Object + func (o *Array) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *Array) CanIterate() bool + func (o *Array) Copy() Object + func (o *Array) Equals(x Object) bool + func (o *Array) IndexGet(index Object) (res Object, err error) + func (o *Array) IndexSet(index, value Object) (err error) + func (o *Array) IsFalsy() bool + func (o *Array) Iterate() Iterator + func (o *Array) String() string + func (o *Array) TypeName() string + type ArrayIterator struct + func (i *ArrayIterator) Copy() Object + func (i *ArrayIterator) Equals(Object) bool + func (i *ArrayIterator) IsFalsy() bool + func (i *ArrayIterator) Key() Object + func (i *ArrayIterator) Next() bool + func (i *ArrayIterator) String() string + func (i *ArrayIterator) TypeName() string + func (i *ArrayIterator) Value() Object + type Bool struct + func (o *Bool) Copy() Object + func (o *Bool) Equals(x Object) bool + func (o *Bool) GobDecode(b []byte) (err error) + func (o *Bool) GobEncode() (b []byte, err error) + func (o *Bool) IsFalsy() bool + func (o *Bool) String() string + func (o *Bool) TypeName() string + type BuiltinFunction struct + Name string + Value CallableFunc + func GetAllBuiltinFunctions() []*BuiltinFunction + func (o *BuiltinFunction) Call(args ...Object) (Object, error) + func (o *BuiltinFunction) CanCall() bool + func (o *BuiltinFunction) Copy() Object + func (o *BuiltinFunction) Equals(_ Object) bool + func (o *BuiltinFunction) String() string + func (o *BuiltinFunction) TypeName() string + type BuiltinModule struct + Attrs map[string]Object + func (m *BuiltinModule) AsImmutableMap(moduleName string) *ImmutableMap + func (m *BuiltinModule) Import(moduleName string) (interface{}, error) + type Bytecode struct + Constants []Object + FileSet *parser.SourceFileSet + MainFunction *CompiledFunction + func (b *Bytecode) CountObjects() int + func (b *Bytecode) Decode(r io.Reader, modules *ModuleMap) error + func (b *Bytecode) Encode(w io.Writer) error + func (b *Bytecode) FormatConstants() (output []string) + func (b *Bytecode) FormatInstructions() []string + func (b *Bytecode) RemoveDuplicates() + type Bytes struct + Value []byte + func (o *Bytes) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *Bytes) CanIterate() bool + func (o *Bytes) Copy() Object + func (o *Bytes) Equals(x Object) bool + func (o *Bytes) IndexGet(index Object) (res Object, err error) + func (o *Bytes) IsFalsy() bool + func (o *Bytes) Iterate() Iterator + func (o *Bytes) String() string + func (o *Bytes) TypeName() string + type BytesIterator struct + func (i *BytesIterator) Copy() Object + func (i *BytesIterator) Equals(Object) bool + func (i *BytesIterator) Key() Object + func (i *BytesIterator) Next() bool + func (i *BytesIterator) String() string + func (i *BytesIterator) TypeName() string + func (i *BytesIterator) Value() Object + type CallableFunc = func(args ...Object) (ret Object, err error) + type Char struct + Value rune + func (o *Char) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *Char) Copy() Object + func (o *Char) Equals(x Object) bool + func (o *Char) IsFalsy() bool + func (o *Char) String() string + func (o *Char) TypeName() string + type Compiled struct + func (c *Compiled) Clone() *Compiled + func (c *Compiled) Get(name string) *Variable + func (c *Compiled) GetAll() []*Variable + func (c *Compiled) IsDefined(name string) bool + func (c *Compiled) Run() error + func (c *Compiled) RunContext(ctx context.Context) (err error) + func (c *Compiled) Set(name string, value interface{}) error + type CompiledFunction struct + Free []*ObjectPtr + Instructions []byte + NumLocals int + NumParameters int + SourceMap map[int]parser.Pos + UsesReceiver bool + VarArgs bool + func (o *CompiledFunction) CanCall() bool + func (o *CompiledFunction) Copy() Object + func (o *CompiledFunction) Equals(_ Object) bool + func (o *CompiledFunction) SourcePos(ip int) parser.Pos + func (o *CompiledFunction) String() string + func (o *CompiledFunction) TypeName() string + type Compiler struct + func NewCompiler(file *parser.SourceFile, symbolTable *SymbolTable, constants []Object, ...) *Compiler + func (c *Compiler) Bytecode() *Bytecode + func (c *Compiler) Compile(node parser.Node) error + func (c *Compiler) EnableFileImport(enable bool) + func (c *Compiler) SetImportDir(dir string) + type CompilerError struct + Err error + FileSet *parser.SourceFileSet + Node parser.Node + func (e *CompilerError) Error() string + type ErrInvalidArgumentType struct + Expected string + Found string + Name string + func (e ErrInvalidArgumentType) Error() string + type Error struct + Value Object + func (o *Error) Copy() Object + func (o *Error) Equals(x Object) bool + func (o *Error) IndexGet(index Object) (res Object, err error) + func (o *Error) IsFalsy() bool + func (o *Error) String() string + func (o *Error) TypeName() string + type Float struct + Value float64 + func (o *Float) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *Float) Copy() Object + func (o *Float) Equals(x Object) bool + func (o *Float) IsFalsy() bool + func (o *Float) String() string + func (o *Float) TypeName() string + type ImmutableArray struct + Value []Object + func (o *ImmutableArray) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *ImmutableArray) CanIterate() bool + func (o *ImmutableArray) Copy() Object + func (o *ImmutableArray) Equals(x Object) bool + func (o *ImmutableArray) IndexGet(index Object) (res Object, err error) + func (o *ImmutableArray) IsFalsy() bool + func (o *ImmutableArray) Iterate() Iterator + func (o *ImmutableArray) String() string + func (o *ImmutableArray) TypeName() string + type ImmutableMap struct + Value map[string]Object + func (o *ImmutableMap) CanIterate() bool + func (o *ImmutableMap) Copy() Object + func (o *ImmutableMap) Equals(x Object) bool + func (o *ImmutableMap) IndexGet(index Object) (res Object, err error) + func (o *ImmutableMap) IsFalsy() bool + func (o *ImmutableMap) Iterate() Iterator + func (o *ImmutableMap) String() string + func (o *ImmutableMap) TypeName() string + type Importable interface + Import func(moduleName string) (interface{}, error) + type Int struct + Value int64 + func (o *Int) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *Int) Copy() Object + func (o *Int) Equals(x Object) bool + func (o *Int) IsFalsy() bool + func (o *Int) String() string + func (o *Int) TypeName() string + type Iterator interface + Key func() Object + Next func() bool + Value func() Object + type Map struct + Value map[string]Object + func (o *Map) CanIterate() bool + func (o *Map) Copy() Object + func (o *Map) Equals(x Object) bool + func (o *Map) IndexGet(index Object) (res Object, err error) + func (o *Map) IndexSet(index, value Object) (err error) + func (o *Map) IsFalsy() bool + func (o *Map) Iterate() Iterator + func (o *Map) String() string + func (o *Map) TypeName() string + type MapIterator struct + func (i *MapIterator) Copy() Object + func (i *MapIterator) Equals(Object) bool + func (i *MapIterator) IsFalsy() bool + func (i *MapIterator) Key() Object + func (i *MapIterator) Next() bool + func (i *MapIterator) String() string + func (i *MapIterator) TypeName() string + func (i *MapIterator) Value() Object + type ModuleMap struct + func NewModuleMap() *ModuleMap + func (m *ModuleMap) Add(name string, module Importable) + func (m *ModuleMap) AddBuiltinModule(name string, attrs map[string]Object) + func (m *ModuleMap) AddMap(o *ModuleMap) + func (m *ModuleMap) AddSourceModule(name string, src []byte) + func (m *ModuleMap) Copy() *ModuleMap + func (m *ModuleMap) Get(name string) Importable + func (m *ModuleMap) GetBuiltinModule(name string) *BuiltinModule + func (m *ModuleMap) GetSourceModule(name string) *SourceModule + func (m *ModuleMap) Len() int + func (m *ModuleMap) Remove(name string) + type Object interface + BinaryOp func(op token.Token, rhs Object) (Object, error) + Call func(args ...Object) (ret Object, err error) + CanCall func() bool + CanIterate func() bool + Copy func() Object + Equals func(another Object) bool + IndexGet func(index Object) (value Object, err error) + IndexSet func(index, value Object) error + IsFalsy func() bool + Iterate func() Iterator + String func() string + TypeName func() string + var FalseValue Object = &Bool{ ... } + var TrueValue Object = &Bool{ ... } + var UndefinedValue Object = &Undefined{} + func FromInterface(v interface{}) (Object, error) + type ObjectImpl struct + func (o *ObjectImpl) BinaryOp(_ token.Token, _ Object) (Object, error) + func (o *ObjectImpl) Call(_ ...Object) (ret Object, err error) + func (o *ObjectImpl) CanCall() bool + func (o *ObjectImpl) CanIterate() bool + func (o *ObjectImpl) Copy() Object + func (o *ObjectImpl) Equals(x Object) bool + func (o *ObjectImpl) IndexGet(_ Object) (res Object, err error) + func (o *ObjectImpl) IndexSet(_, _ Object) (err error) + func (o *ObjectImpl) IsFalsy() bool + func (o *ObjectImpl) Iterate() Iterator + func (o *ObjectImpl) String() string + func (o *ObjectImpl) TypeName() string + type ObjectPtr struct + Value *Object + func (o *ObjectPtr) Copy() Object + func (o *ObjectPtr) Equals(x Object) bool + func (o *ObjectPtr) IsFalsy() bool + func (o *ObjectPtr) String() string + func (o *ObjectPtr) TypeName() string + type Script struct + func NewScript(input []byte) *Script + func (s *Script) Add(name string, value interface{}) error + func (s *Script) Compile() (*Compiled, error) + func (s *Script) EnableFileImport(enable bool) + func (s *Script) Remove(name string) bool + func (s *Script) Run() (compiled *Compiled, err error) + func (s *Script) RunContext(ctx context.Context) (compiled *Compiled, err error) + func (s *Script) SetImportDir(dir string) error + func (s *Script) SetImports(modules *ModuleMap) + func (s *Script) SetMaxAllocs(n int64) + func (s *Script) SetMaxConstObjects(n int) + type SourceModule struct + Src []byte + func (m *SourceModule) Import(_ string) (interface{}, error) + type String struct + Value string + func (o *String) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *String) CanIterate() bool + func (o *String) Copy() Object + func (o *String) Equals(x Object) bool + func (o *String) IndexGet(index Object) (res Object, err error) + func (o *String) IsFalsy() bool + func (o *String) Iterate() Iterator + func (o *String) String() string + func (o *String) TypeName() string + type StringIterator struct + func (i *StringIterator) Copy() Object + func (i *StringIterator) Equals(Object) bool + func (i *StringIterator) IsFalsy() bool + func (i *StringIterator) Key() Object + func (i *StringIterator) Next() bool + func (i *StringIterator) String() string + func (i *StringIterator) TypeName() string + func (i *StringIterator) Value() Object + type Symbol struct + Index int + LocalAssigned bool + Name string + Scope SymbolScope + type SymbolScope string + const ScopeBuiltin + const ScopeFree + const ScopeGlobal + const ScopeLocal + type SymbolTable struct + func NewSymbolTable() *SymbolTable + func (t *SymbolTable) BuiltinSymbols() []*Symbol + func (t *SymbolTable) Define(name string) *Symbol + func (t *SymbolTable) DefineBuiltin(index int, name string) *Symbol + func (t *SymbolTable) Fork(block bool) *SymbolTable + func (t *SymbolTable) FreeSymbols() []*Symbol + func (t *SymbolTable) MaxSymbols() int + func (t *SymbolTable) Names() []string + func (t *SymbolTable) Parent(skipBlock bool) *SymbolTable + func (t *SymbolTable) Resolve(name string, recur bool) (*Symbol, int, bool) + type Time struct + Value time.Time + func (o *Time) BinaryOp(op token.Token, rhs Object) (Object, error) + func (o *Time) Copy() Object + func (o *Time) Equals(x Object) bool + func (o *Time) IsFalsy() bool + func (o *Time) String() string + func (o *Time) TypeName() string + type Undefined struct + func (o *Undefined) CanIterate() bool + func (o *Undefined) Copy() Object + func (o *Undefined) Equals(x Object) bool + func (o *Undefined) IndexGet(_ Object) (Object, error) + func (o *Undefined) IsFalsy() bool + func (o *Undefined) Iterate() Iterator + func (o *Undefined) Key() Object + func (o *Undefined) Next() bool + func (o *Undefined) String() string + func (o *Undefined) TypeName() string + func (o *Undefined) Value() Object + type UserFunction struct + EncodingID string + Name string + Value CallableFunc + func (o *UserFunction) Call(args ...Object) (Object, error) + func (o *UserFunction) CanCall() bool + func (o *UserFunction) Copy() Object + func (o *UserFunction) Equals(_ Object) bool + func (o *UserFunction) String() string + func (o *UserFunction) TypeName() string + type VM struct + func NewVM(bytecode *Bytecode, globals []Object, maxAllocs int64) *VM + func (v *VM) Abort() + func (v *VM) IsStackEmpty() bool + func (v *VM) Run() (err error) + type Variable struct + func NewVariable(name string, value interface{}) (*Variable, error) + func (v *Variable) Array() []interface{} + func (v *Variable) Bool() bool + func (v *Variable) Bytes() []byte + func (v *Variable) Char() rune + func (v *Variable) Error() error + func (v *Variable) Float() float64 + func (v *Variable) Int() int + func (v *Variable) Int64() int64 + func (v *Variable) IsUndefined() bool + func (v *Variable) Map() map[string]interface{} + func (v *Variable) Name() string + func (v *Variable) Object() Object + func (v *Variable) String() string + func (v *Variable) Value() interface{} + func (v *Variable) ValueType() string Other modules containing this package github.com/DawDavis/tengo