Documentation ¶
Index ¶
- Variables
- func CountObjects(o Object) (c int)
- func Format(format string, a ...Object) (string, error)
- 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
- func (o *Array) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (i *ArrayIterator) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (o *Bool) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (o *BuiltinFunction) BinaryOp(op token.Token, rhs Object) (Object, error)
- func (o *BuiltinFunction) Call(args ...Object) (Object, error)
- func (o *BuiltinFunction) Copy() Object
- func (o *BuiltinFunction) Equals(x Object) bool
- func (o *BuiltinFunction) IsFalsy() bool
- func (o *BuiltinFunction) String() string
- func (o *BuiltinFunction) TypeName() string
- type BuiltinModule
- type Bytes
- func (o *Bytes) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (i *BytesIterator) BinaryOp(op token.Token, rhs Object) (Object, error)
- func (i *BytesIterator) Copy() Object
- func (i *BytesIterator) Equals(Object) bool
- func (i *BytesIterator) IsFalsy() 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 Callable
- type CallableFunc
- type Char
- type Closure
- type CompiledFunction
- func (o *CompiledFunction) BinaryOp(op token.Token, rhs Object) (Object, error)
- func (o *CompiledFunction) Copy() Object
- func (o *CompiledFunction) Equals(x Object) bool
- func (o *CompiledFunction) IsFalsy() bool
- func (o *CompiledFunction) SourcePos(ip int) source.Pos
- func (o *CompiledFunction) String() string
- func (o *CompiledFunction) TypeName() string
- type ErrInvalidArgumentType
- type Error
- type Float
- type ImmutableArray
- func (o *ImmutableArray) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (o *ImmutableMap) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- type IndexAssignable
- type Indexable
- type Int
- type Iterable
- type Iterator
- type Map
- func (o *Map) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (i *MapIterator) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- 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
- type ObjectPtr
- type SourceModule
- type String
- func (o *String) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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
- func (i *StringIterator) BinaryOp(op token.Token, rhs Object) (Object, error)
- 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 Time
- type Undefined
- func (o *Undefined) BinaryOp(op token.Token, rhs Object) (Object, error)
- func (o *Undefined) Copy() Object
- func (o *Undefined) Equals(x Object) bool
- func (o *Undefined) IndexGet(index 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
- func (o *UserFunction) BinaryOp(op token.Token, rhs Object) (Object, error)
- func (o *UserFunction) Call(args ...Object) (Object, error)
- func (o *UserFunction) Copy() Object
- func (o *UserFunction) Equals(x Object) bool
- func (o *UserFunction) IsFalsy() bool
- func (o *UserFunction) String() string
- func (o *UserFunction) TypeName() string
Constants ¶
This section is empty.
Variables ¶
var Builtins = []*BuiltinFunction{
{
Name: "len",
Value: builtinLen,
},
{
Name: "copy",
Value: builtinCopy,
},
{
Name: "append",
Value: builtinAppend,
},
{
Name: "string",
Value: builtinString,
},
{
Name: "int",
Value: builtinInt,
},
{
Name: "bool",
Value: builtinBool,
},
{
Name: "float",
Value: builtinFloat,
},
{
Name: "char",
Value: builtinChar,
},
{
Name: "bytes",
Value: builtinBytes,
},
{
Name: "time",
Value: builtinTime,
},
{
Name: "is_int",
Value: builtinIsInt,
},
{
Name: "is_float",
Value: builtinIsFloat,
},
{
Name: "is_string",
Value: builtinIsString,
},
{
Name: "is_bool",
Value: builtinIsBool,
},
{
Name: "is_char",
Value: builtinIsChar,
},
{
Name: "is_bytes",
Value: builtinIsBytes,
},
{
Name: "is_array",
Value: builtinIsArray,
},
{
Name: "is_immutable_array",
Value: builtinIsImmutableArray,
},
{
Name: "is_map",
Value: builtinIsMap,
},
{
Name: "is_immutable_map",
Value: builtinIsImmutableMap,
},
{
Name: "is_iterable",
Value: builtinIsIterable,
},
{
Name: "is_time",
Value: builtinIsTime,
},
{
Name: "is_error",
Value: builtinIsError,
},
{
Name: "is_undefined",
Value: builtinIsUndefined,
},
{
Name: "is_function",
Value: builtinIsFunction,
},
{
Name: "is_callable",
Value: builtinIsCallable,
},
{
Name: "type_name",
Value: builtinTypeName,
},
{
Name: "format",
Value: builtinFormat,
},
}
Builtins contains all default builtin functions. Use GetBuiltinFunctions instead of accessing Builtins directly.
var ErrBytesLimit = errors.New("exceeding bytes size limit")
ErrBytesLimit represents an error where the size of bytes value exceeds the limit.
var ErrIndexOutOfBounds = errors.New("index out of bounds")
ErrIndexOutOfBounds is an error where a given index is out of the bounds.
var ErrInvalidIndexType = errors.New("invalid index type")
ErrInvalidIndexType represents an invalid index type.
var ErrInvalidIndexValueType = errors.New("invalid index value type")
ErrInvalidIndexValueType represents an invalid index value type.
var ErrInvalidOperator = errors.New("invalid operator")
ErrInvalidOperator represents an error for invalid operator usage.
var ErrStringLimit = errors.New("exceeding string size limit")
ErrStringLimit represents an error where the size of string value exceeds the limit.
var ErrWrongNumArguments = errors.New("wrong number of arguments")
ErrWrongNumArguments represents a wrong number of arguments error.
Functions ¶
func CountObjects ¶ added in v1.13.0
CountObjects returns the number of objects that a given object o contains. For scalar value types, it will always be 1. For compound value types, this will include its elements and all of their elements recursively.
func Format ¶ added in v1.23.0
Format formats according to a format specifier and returns the resulting string.
func ToByteSlice ¶
ToByteSlice will try to convert object o to []byte value.
func ToInterface ¶ added in v1.14.2
func ToInterface(o Object) (res interface{})
ToInterface attempts to convert an object o to an interface{} value
Types ¶
type Array ¶
type Array struct {
Value []Object
}
Array represents an array of objects.
func (*Array) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Array) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type ArrayIterator ¶
type ArrayIterator struct {
// contains filtered or unexported fields
}
ArrayIterator is an iterator for an array.
func (*ArrayIterator) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*ArrayIterator) Equals ¶
func (i *ArrayIterator) Equals(Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*ArrayIterator) IsFalsy ¶
func (i *ArrayIterator) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*ArrayIterator) Key ¶
func (i *ArrayIterator) Key() Object
Key returns the key or index value of the current element.
func (*ArrayIterator) Next ¶
func (i *ArrayIterator) Next() bool
Next returns true if there are more elements to iterate.
func (*ArrayIterator) String ¶
func (i *ArrayIterator) String() string
func (*ArrayIterator) TypeName ¶
func (i *ArrayIterator) TypeName() string
TypeName returns the name of the type.
func (*ArrayIterator) Value ¶
func (i *ArrayIterator) Value() Object
Value returns the value of the current element.
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool represents a boolean value.
func (*Bool) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Bool) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type BuiltinFunction ¶
type BuiltinFunction struct { Name string Value CallableFunc }
BuiltinFunction represents a builtin function.
func (*BuiltinFunction) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*BuiltinFunction) Call ¶
func (o *BuiltinFunction) Call(args ...Object) (Object, error)
Call executes a builtin function.
func (*BuiltinFunction) Copy ¶
func (o *BuiltinFunction) Copy() Object
Copy returns a copy of the type.
func (*BuiltinFunction) Equals ¶
func (o *BuiltinFunction) Equals(x Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*BuiltinFunction) IsFalsy ¶
func (o *BuiltinFunction) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*BuiltinFunction) String ¶
func (o *BuiltinFunction) String() string
func (*BuiltinFunction) TypeName ¶
func (o *BuiltinFunction) TypeName() string
TypeName returns the name of the type.
type BuiltinModule ¶ added in v1.17.0
BuiltinModule is an importable module that's written in Go.
func (*BuiltinModule) AsImmutableMap ¶ added in v1.18.0
func (m *BuiltinModule) AsImmutableMap(moduleName string) *ImmutableMap
AsImmutableMap converts builtin module into an immutable map.
func (*BuiltinModule) Import ¶ added in v1.17.0
func (m *BuiltinModule) Import(moduleName string) (interface{}, error)
Import returns an immutable map for the module.
type Bytes ¶
type Bytes struct {
Value []byte
}
Bytes represents a byte array.
func (*Bytes) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Bytes) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type BytesIterator ¶ added in v1.19.0
type BytesIterator struct {
// contains filtered or unexported fields
}
BytesIterator represents an iterator for a string.
func (*BytesIterator) BinaryOp ¶ added in v1.19.0
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*BytesIterator) Copy ¶ added in v1.19.0
func (i *BytesIterator) Copy() Object
Copy returns a copy of the type.
func (*BytesIterator) Equals ¶ added in v1.19.0
func (i *BytesIterator) Equals(Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*BytesIterator) IsFalsy ¶ added in v1.19.0
func (i *BytesIterator) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*BytesIterator) Key ¶ added in v1.19.0
func (i *BytesIterator) Key() Object
Key returns the key or index value of the current element.
func (*BytesIterator) Next ¶ added in v1.19.0
func (i *BytesIterator) Next() bool
Next returns true if there are more elements to iterate.
func (*BytesIterator) String ¶ added in v1.19.0
func (i *BytesIterator) String() string
func (*BytesIterator) TypeName ¶ added in v1.19.0
func (i *BytesIterator) TypeName() string
TypeName returns the name of the type.
func (*BytesIterator) Value ¶ added in v1.19.0
func (i *BytesIterator) Value() Object
Value returns the value of the current element.
type Callable ¶
type Callable interface { // Call should take an arbitrary number of arguments // and returns a return value and/or an error, // which the VM will consider as a run-time error. Call(args ...Object) (ret Object, err error) }
Callable represents an object that can be called like a function.
type CallableFunc ¶
CallableFunc is a function signature for the callable functions.
type Char ¶
type Char struct {
Value rune
}
Char represents a character value.
func (*Char) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Char) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type Closure ¶
type Closure struct { Fn *CompiledFunction Free []*ObjectPtr }
Closure represents a function closure.
func (*Closure) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Closure) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type CompiledFunction ¶
type CompiledFunction struct { Instructions []byte NumLocals int // number of local variables (including function parameters) NumParameters int VarArgs bool SourceMap map[int]source.Pos }
CompiledFunction represents a compiled function.
func (*CompiledFunction) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*CompiledFunction) Copy ¶
func (o *CompiledFunction) Copy() Object
Copy returns a copy of the type.
func (*CompiledFunction) Equals ¶
func (o *CompiledFunction) Equals(x Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*CompiledFunction) IsFalsy ¶
func (o *CompiledFunction) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*CompiledFunction) SourcePos ¶ added in v1.18.2
func (o *CompiledFunction) SourcePos(ip int) source.Pos
SourcePos returns the source position of the instruction at ip.
func (*CompiledFunction) String ¶
func (o *CompiledFunction) String() string
func (*CompiledFunction) TypeName ¶
func (o *CompiledFunction) TypeName() string
TypeName returns the name of the type.
type ErrInvalidArgumentType ¶ added in v1.9.0
ErrInvalidArgumentType represents an invalid argument value type error.
func (ErrInvalidArgumentType) Error ¶ added in v1.9.0
func (e ErrInvalidArgumentType) Error() string
type Error ¶
type Error struct {
Value Object
}
Error represents a string value.
func (*Error) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Error) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type Float ¶
type Float struct {
Value float64
}
Float represents a floating point number value.
func (*Float) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Float) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type ImmutableArray ¶
type ImmutableArray struct {
Value []Object
}
ImmutableArray represents an immutable array of objects.
func (*ImmutableArray) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*ImmutableArray) Copy ¶
func (o *ImmutableArray) Copy() Object
Copy returns a copy of the type.
func (*ImmutableArray) Equals ¶
func (o *ImmutableArray) Equals(x Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*ImmutableArray) IndexGet ¶
func (o *ImmutableArray) IndexGet(index Object) (res Object, err error)
IndexGet returns an element at a given index.
func (*ImmutableArray) IsFalsy ¶
func (o *ImmutableArray) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*ImmutableArray) Iterate ¶
func (o *ImmutableArray) Iterate() Iterator
Iterate creates an array iterator.
func (*ImmutableArray) String ¶
func (o *ImmutableArray) String() string
func (*ImmutableArray) TypeName ¶
func (o *ImmutableArray) TypeName() string
TypeName returns the name of the type.
type ImmutableMap ¶
ImmutableMap represents an immutable map object.
func (*ImmutableMap) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*ImmutableMap) Equals ¶
func (o *ImmutableMap) Equals(x Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*ImmutableMap) IndexGet ¶
func (o *ImmutableMap) IndexGet(index Object) (res Object, err error)
IndexGet returns the value for the given key.
func (*ImmutableMap) IsFalsy ¶
func (o *ImmutableMap) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*ImmutableMap) Iterate ¶
func (o *ImmutableMap) Iterate() Iterator
Iterate creates an immutable map iterator.
func (*ImmutableMap) String ¶
func (o *ImmutableMap) String() string
func (*ImmutableMap) TypeName ¶
func (o *ImmutableMap) TypeName() string
TypeName returns the name of the type.
type Importable ¶ added in v1.17.0
type Importable interface { // Import should return either an Object or module source code ([]byte). Import(moduleName string) (interface{}, error) }
Importable interface represents importable module instance.
type IndexAssignable ¶
type IndexAssignable interface { // IndexSet should take an index Object and a value Object. // If an error is returned, it will be treated as a run-time error. IndexSet(index, value Object) error }
IndexAssignable is an object that can take an index and a value on the left-hand side of the assignment statement.
type Indexable ¶
type Indexable interface { // IndexGet should take an index Object and return a result Object or an error. // If error is returned, the runtime will treat it as a run-time error and ignore returned value. // If nil is returned as value, it will be converted to Undefined value by the runtime. IndexGet(index Object) (value Object, err error) }
Indexable is an object that can take an index and return an object.
type Int ¶
type Int struct {
Value int64
}
Int represents an integer value.
func (*Int) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Int) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type Iterable ¶
type Iterable interface { // Iterate should return an Iterator for the type. Iterate() Iterator }
Iterable represents an object that has iterator.
type Iterator ¶
type Iterator interface { Object // Next returns true if there are more elements to iterate. Next() bool // Key returns the key or index value of the current element. Key() Object // Value returns the value of the current element. Value() Object }
Iterator represents an iterator for underlying data type.
type Map ¶
Map represents a map of objects.
func (*Map) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Map) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type MapIterator ¶
type MapIterator struct {
// contains filtered or unexported fields
}
MapIterator represents an iterator for the map.
func (*MapIterator) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*MapIterator) Equals ¶
func (i *MapIterator) Equals(Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*MapIterator) IsFalsy ¶
func (i *MapIterator) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*MapIterator) Key ¶
func (i *MapIterator) Key() Object
Key returns the key or index value of the current element.
func (*MapIterator) Next ¶
func (i *MapIterator) Next() bool
Next returns true if there are more elements to iterate.
func (*MapIterator) String ¶
func (i *MapIterator) String() string
func (*MapIterator) TypeName ¶
func (i *MapIterator) TypeName() string
TypeName returns the name of the type.
func (*MapIterator) Value ¶
func (i *MapIterator) Value() Object
Value returns the value of the current element.
type ModuleMap ¶ added in v1.18.0
type ModuleMap struct {
// contains filtered or unexported fields
}
ModuleMap represents a set of named modules. Use NewModuleMap to create a new module map.
func NewModuleMap ¶ added in v1.18.0
func NewModuleMap() *ModuleMap
NewModuleMap creates a new module map.
func (*ModuleMap) Add ¶ added in v1.18.0
func (m *ModuleMap) Add(name string, module Importable)
Add adds an import module.
func (*ModuleMap) AddBuiltinModule ¶ added in v1.18.0
AddBuiltinModule adds a builtin module.
func (*ModuleMap) AddSourceModule ¶ added in v1.18.0
AddSourceModule adds a source module.
func (*ModuleMap) Get ¶ added in v1.18.0
func (m *ModuleMap) Get(name string) Importable
Get returns an import module identified by name. It returns if the name is not found.
func (*ModuleMap) GetBuiltinModule ¶ added in v1.18.0
func (m *ModuleMap) GetBuiltinModule(name string) *BuiltinModule
GetBuiltinModule returns a builtin module identified by name. It returns if the name is not found or the module is not a builtin module.
func (*ModuleMap) GetSourceModule ¶ added in v1.18.0
func (m *ModuleMap) GetSourceModule(name string) *SourceModule
GetSourceModule returns a source module identified by name. It returns if the name is not found or the module is not a source module.
type Object ¶
type Object interface { // TypeName should return the name of the type. TypeName() string // String should return a string representation of the type's value. String() string // BinaryOp should return another object that is the result of // a given binary operator and a right-hand side object. // If BinaryOp returns an error, the VM will treat it as a run-time error. BinaryOp(op token.Token, rhs Object) (Object, error) // IsFalsy should return true if the value of the type // should be considered as falsy. IsFalsy() bool // Equals should return true if the value of the type // should be considered as equal to the value of another object. Equals(another Object) bool // Copy should return a copy of the type (and its value). // Copy function will be used for copy() builtin function // which is expected to deep-copy the values generally. Copy() Object }
Object represents an object in the VM.
func FromInterface ¶
FromInterface will attempt to convert an interface{} v to a Tengo Object
type ObjectPtr ¶ added in v1.15.0
type ObjectPtr struct {
Value *Object
}
ObjectPtr represents a free variable.
func (*ObjectPtr) BinaryOp ¶ added in v1.15.0
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*ObjectPtr) Equals ¶ added in v1.15.0
Equals returns true if the value of the type is equal to the value of another object.
type SourceModule ¶ added in v1.17.0
type SourceModule struct {
Src []byte
}
SourceModule is an importable module that's written in Tengo.
func (*SourceModule) Import ¶ added in v1.17.0
func (m *SourceModule) Import(_ string) (interface{}, error)
Import returns a module source code.
type String ¶
type String struct { Value string // contains filtered or unexported fields }
String represents a string value.
func (*String) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*String) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type StringIterator ¶
type StringIterator struct {
// contains filtered or unexported fields
}
StringIterator represents an iterator for a string.
func (*StringIterator) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*StringIterator) Copy ¶
func (i *StringIterator) Copy() Object
Copy returns a copy of the type.
func (*StringIterator) Equals ¶
func (i *StringIterator) Equals(Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*StringIterator) IsFalsy ¶
func (i *StringIterator) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*StringIterator) Key ¶
func (i *StringIterator) Key() Object
Key returns the key or index value of the current element.
func (*StringIterator) Next ¶
func (i *StringIterator) Next() bool
Next returns true if there are more elements to iterate.
func (*StringIterator) String ¶
func (i *StringIterator) String() string
func (*StringIterator) TypeName ¶
func (i *StringIterator) TypeName() string
TypeName returns the name of the type.
func (*StringIterator) Value ¶
func (i *StringIterator) Value() Object
Value returns the value of the current element.
type Time ¶
Time represents a time value.
func (*Time) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Time) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type Undefined ¶
type Undefined struct{}
Undefined represents an undefined value.
func (*Undefined) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*Undefined) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type UserFunction ¶
type UserFunction struct { Name string Value CallableFunc EncodingID string }
UserFunction represents a user function.
func (*UserFunction) BinaryOp ¶
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*UserFunction) Call ¶
func (o *UserFunction) Call(args ...Object) (Object, error)
Call invokes a user function.
func (*UserFunction) Equals ¶
func (o *UserFunction) Equals(x Object) bool
Equals returns true if the value of the type is equal to the value of another object.
func (*UserFunction) IsFalsy ¶
func (o *UserFunction) IsFalsy() bool
IsFalsy returns true if the value of the type is falsy.
func (*UserFunction) String ¶
func (o *UserFunction) String() string
func (*UserFunction) TypeName ¶
func (o *UserFunction) TypeName() string
TypeName returns the name of the type.
Source Files ¶
- array.go
- array_iterator.go
- bool.go
- builtin_append.go
- builtin_convert.go
- builtin_copy.go
- builtin_format.go
- builtin_function.go
- builtin_len.go
- builtin_module.go
- builtin_type.go
- builtin_type_checks.go
- builtins.go
- bytes.go
- bytes_iterator.go
- callable.go
- callable_func.go
- char.go
- closure.go
- compiled_function.go
- conversion.go
- count_objects.go
- error.go
- errors.go
- float.go
- formatter.go
- immautable_array.go
- immutable_map.go
- importable.go
- index_assignable.go
- indexable.go
- int.go
- iterable.go
- iterator.go
- map.go
- map_iterator.go
- module_map.go
- object.go
- object_ptr.go
- objects.go
- source_module.go
- string.go
- string_iterator.go
- time.go
- undefined.go
- user_function.go