objects

package
v1.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Builtins = []BuiltinFunction{
	{
		Name:  "print",
		Value: builtinPrint,
	},
	{
		Name:  "printf",
		Value: builtinPrintf,
	},
	{
		Name:  "sprintf",
		Value: builtinSprintf,
	},
	{
		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_time",
		Value: builtinIsTime,
	},
	{
		Name:  "is_error",
		Value: builtinIsError,
	},
	{
		Name:  "is_undefined",
		Value: builtinIsUndefined,
	},
	{
		Name:  "is_function",
		Value: builtinIsFunction,
	},
	{
		Name:  "is_callable",
		Value: builtinIsCallable,
	},
	{
		Name:  "to_json",
		Value: builtinToJSON,
	},
	{
		Name:  "from_json",
		Value: builtinFromJSON,
	},
	{
		Name:  "type_name",
		Value: builtinTypeName,
	},
}

Builtins contains all default builtin functions. Use GetBuiltinFunctions instead of accessing Builtins directly.

View Source
var ErrBytesLimit = errors.New("exceeding bytes size limit")

ErrBytesLimit represents an error where the size of bytes value exceeds the limit.

View Source
var ErrIndexOutOfBounds = errors.New("index out of bounds")

ErrIndexOutOfBounds is an error where a given index is out of the bounds.

View Source
var ErrInvalidIndexType = errors.New("invalid index type")

ErrInvalidIndexType represents an invalid index type.

View Source
var ErrInvalidIndexValueType = errors.New("invalid index value type")

ErrInvalidIndexValueType represents an invalid index value type.

View Source
var ErrInvalidOperator = errors.New("invalid operator")

ErrInvalidOperator represents an error for invalid operator usage.

View Source
var ErrStringLimit = errors.New("exceeding string size limit")

ErrStringLimit represents an error where the size of string value exceeds the limit.

View Source
var ErrWrongNumArguments = errors.New("wrong number of arguments")

ErrWrongNumArguments represents a wrong number of arguments error.

Functions

func AllBuiltinFunctionNames added in v1.10.1

func AllBuiltinFunctionNames() []string

AllBuiltinFunctionNames returns a list of all default builtin function names.

func ToBool

func ToBool(o Object) (v bool, ok bool)

ToBool will try to convert object o to bool value.

func ToByteSlice

func ToByteSlice(o Object) (v []byte, ok bool)

ToByteSlice will try to convert object o to []byte value.

func ToFloat64

func ToFloat64(o Object) (v float64, ok bool)

ToFloat64 will try to convert object o to float64 value.

func ToInt

func ToInt(o Object) (v int, ok bool)

ToInt will try to convert object o to int value.

func ToInt64

func ToInt64(o Object) (v int64, ok bool)

ToInt64 will try to convert object o to int64 value.

func ToRune

func ToRune(o Object) (v rune, ok bool)

ToRune will try to convert object o to rune value.

func ToString

func ToString(o Object) (v string, ok bool)

ToString will try to convert object o to string value.

func ToTime

func ToTime(o Object) (v time.Time, ok bool)

ToTime will try to convert object o to time.Time value.

Types

type Array

type Array struct {
	Value []Object
}

Array represents an array of objects.

func (*Array) BinaryOp

func (o *Array) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Array) Copy

func (o *Array) Copy() Object

Copy returns a copy of the type.

func (*Array) Equals

func (o *Array) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Array) IndexGet

func (o *Array) IndexGet(index Object) (res Object, err error)

IndexGet returns an element at a given index.

func (*Array) IndexSet

func (o *Array) IndexSet(index, value Object) (err error)

IndexSet sets an element at a given index.

func (*Array) IsFalsy

func (o *Array) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Array) Iterate

func (o *Array) Iterate() Iterator

Iterate creates an array iterator.

func (*Array) String

func (o *Array) String() string

func (*Array) TypeName

func (o *Array) TypeName() string

TypeName returns the name of the type.

type ArrayIterator

type ArrayIterator struct {
	// contains filtered or unexported fields
}

ArrayIterator is an iterator for an array.

func (*ArrayIterator) BinaryOp

func (i *ArrayIterator) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*ArrayIterator) Copy

func (i *ArrayIterator) Copy() Object

Copy returns a copy of the type.

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

func (o *Bool) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Bool) Copy

func (o *Bool) Copy() Object

Copy returns a copy of the type.

func (*Bool) Equals

func (o *Bool) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Bool) GobDecode

func (o *Bool) GobDecode(b []byte) (err error)

GobDecode decodes bool value from input bytes.

func (*Bool) GobEncode

func (o *Bool) GobEncode() (b []byte, err error)

GobEncode encodes bool values into bytes.

func (*Bool) IsFalsy

func (o *Bool) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Bool) String

func (o *Bool) String() string

func (*Bool) TypeName

func (o *Bool) TypeName() string

TypeName returns the name of the type.

type Break

type Break struct{}

Break represents a break statement.

func (*Break) BinaryOp

func (o *Break) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Break) Copy

func (o *Break) Copy() Object

Copy returns a copy of the type.

func (*Break) Equals

func (o *Break) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Break) IsFalsy

func (o *Break) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Break) String

func (o *Break) String() string

func (*Break) TypeName

func (o *Break) TypeName() string

TypeName returns the name of the type.

type BuiltinFunction

type BuiltinFunction struct {
	Name  string
	Value CallableFunc
}

BuiltinFunction represents a builtin function.

func GetAllBuiltinFunctions added in v1.10.1

func GetAllBuiltinFunctions() []*BuiltinFunction

GetAllBuiltinFunctions returns all builtin functions.

func GetBuiltinFunctions added in v1.10.1

func GetBuiltinFunctions(names ...string) []*BuiltinFunction

GetBuiltinFunctions returns a slice of builtin function objects. GetBuiltinFunctions removes the duplicate names, and, the returned builtin functions are not guaranteed to be in the same order as names.

func (*BuiltinFunction) BinaryOp

func (o *BuiltinFunction) BinaryOp(op token.Token, rhs Object) (Object, error)

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 Bytes

type Bytes struct {
	Value []byte
}

Bytes represents a byte array.

func (*Bytes) BinaryOp

func (o *Bytes) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Bytes) Copy

func (o *Bytes) Copy() Object

Copy returns a copy of the type.

func (*Bytes) Equals

func (o *Bytes) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Bytes) IndexGet

func (o *Bytes) IndexGet(index Object) (res Object, err error)

IndexGet returns an element (as Int) at a given index.

func (*Bytes) IsFalsy

func (o *Bytes) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Bytes) String

func (o *Bytes) String() string

func (*Bytes) TypeName

func (o *Bytes) TypeName() string

TypeName returns the name of the type.

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

type CallableFunc = func(args ...Object) (ret Object, err error)

CallableFunc is a function signature for the callable functions.

type Char

type Char struct {
	Value rune
}

Char represents a character value.

func (*Char) BinaryOp

func (o *Char) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Char) Copy

func (o *Char) Copy() Object

Copy returns a copy of the type.

func (*Char) Equals

func (o *Char) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Char) IsFalsy

func (o *Char) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Char) String

func (o *Char) String() string

func (*Char) TypeName

func (o *Char) TypeName() string

TypeName returns the name of the type.

type Closure

type Closure struct {
	Fn   *CompiledFunction
	Free []*Object
}

Closure represents a function closure.

func (*Closure) BinaryOp

func (o *Closure) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Closure) Copy

func (o *Closure) Copy() Object

Copy returns a copy of the type.

func (*Closure) Equals

func (o *Closure) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Closure) IsFalsy

func (o *Closure) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Closure) String

func (o *Closure) String() string

func (*Closure) TypeName

func (o *Closure) TypeName() string

TypeName returns the name of the type.

type CompiledFunction

type CompiledFunction struct {
	Instructions  []byte
	NumLocals     int // number of local variables (including function parameters)
	NumParameters int
	SourceMap     map[int]source.Pos
}

CompiledFunction represents a compiled function.

func (*CompiledFunction) BinaryOp

func (o *CompiledFunction) BinaryOp(op token.Token, rhs Object) (Object, error)

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) String

func (o *CompiledFunction) String() string

func (*CompiledFunction) TypeName

func (o *CompiledFunction) TypeName() string

TypeName returns the name of the type.

type Continue

type Continue struct {
}

Continue represents a continue statement.

func (*Continue) BinaryOp

func (o *Continue) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Continue) Copy

func (o *Continue) Copy() Object

Copy returns a copy of the type.

func (*Continue) Equals

func (o *Continue) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Continue) IsFalsy

func (o *Continue) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Continue) String

func (o *Continue) String() string

func (*Continue) TypeName

func (o *Continue) TypeName() string

TypeName returns the name of the type.

type ErrInvalidArgumentType added in v1.9.0

type ErrInvalidArgumentType struct {
	Name     string
	Expected string
	Found    string
}

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

func (o *Error) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Error) Copy

func (o *Error) Copy() Object

Copy returns a copy of the type.

func (*Error) Equals

func (o *Error) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Error) IsFalsy

func (o *Error) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Error) String

func (o *Error) String() string

func (*Error) TypeName

func (o *Error) TypeName() string

TypeName returns the name of the type.

type Float

type Float struct {
	Value float64
}

Float represents a floating point number value.

func (*Float) BinaryOp

func (o *Float) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Float) Copy

func (o *Float) Copy() Object

Copy returns a copy of the type.

func (*Float) Equals

func (o *Float) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Float) IsFalsy

func (o *Float) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Float) String

func (o *Float) String() string

func (*Float) TypeName

func (o *Float) TypeName() string

TypeName returns the name of the type.

type ImmutableArray

type ImmutableArray struct {
	Value []Object
}

ImmutableArray represents an immutable array of objects.

func (*ImmutableArray) BinaryOp

func (o *ImmutableArray) BinaryOp(op token.Token, rhs Object) (Object, error)

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

type ImmutableMap struct {
	Value map[string]Object
}

ImmutableMap represents an immutable map object.

func (*ImmutableMap) BinaryOp

func (o *ImmutableMap) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*ImmutableMap) Copy

func (o *ImmutableMap) Copy() Object

Copy returns a copy of the type.

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 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

func (o *Int) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Int) Copy

func (o *Int) Copy() Object

Copy returns a copy of the type.

func (*Int) Equals

func (o *Int) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Int) IsFalsy

func (o *Int) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Int) String

func (o *Int) String() string

func (*Int) TypeName

func (o *Int) TypeName() string

TypeName returns the name of the type.

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

type Map struct {
	Value map[string]Object
}

Map represents a map of objects.

func (*Map) BinaryOp

func (o *Map) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Map) Copy

func (o *Map) Copy() Object

Copy returns a copy of the type.

func (*Map) Equals

func (o *Map) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Map) IndexGet

func (o *Map) IndexGet(index Object) (res Object, err error)

IndexGet returns the value for the given key.

func (*Map) IndexSet

func (o *Map) IndexSet(index, value Object) (err error)

IndexSet sets the value for the given key.

func (*Map) IsFalsy

func (o *Map) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Map) Iterate

func (o *Map) Iterate() Iterator

Iterate creates a map iterator.

func (*Map) String

func (o *Map) String() string

func (*Map) TypeName

func (o *Map) TypeName() string

TypeName returns the name of the type.

type MapIterator

type MapIterator struct {
	// contains filtered or unexported fields
}

MapIterator represents an iterator for the map.

func (*MapIterator) BinaryOp

func (i *MapIterator) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*MapIterator) Copy

func (i *MapIterator) Copy() Object

Copy returns a copy of the type.

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 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.

var (
	// TrueValue represents a true value.
	TrueValue Object = &Bool{value: true}

	// FalseValue represents a false value.
	FalseValue Object = &Bool{value: false}

	// UndefinedValue represents an undefined value.
	UndefinedValue Object = &Undefined{}
)

func FromInterface

func FromInterface(v interface{}) (Object, error)

FromInterface will attempt to convert an interface{} v to a Tengo Object

type ReturnValue

type ReturnValue struct {
	Value Object
}

ReturnValue represents a value that is being returned.

func (*ReturnValue) BinaryOp

func (o *ReturnValue) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*ReturnValue) Copy

func (o *ReturnValue) Copy() Object

Copy returns a copy of the type.

func (*ReturnValue) Equals

func (o *ReturnValue) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*ReturnValue) IsFalsy

func (o *ReturnValue) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*ReturnValue) String

func (o *ReturnValue) String() string

func (*ReturnValue) TypeName

func (o *ReturnValue) TypeName() string

TypeName returns the name of the type.

type String

type String struct {
	Value string
	// contains filtered or unexported fields
}

String represents a string value.

func (*String) BinaryOp

func (o *String) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*String) Copy

func (o *String) Copy() Object

Copy returns a copy of the type.

func (*String) Equals

func (o *String) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*String) IndexGet

func (o *String) IndexGet(index Object) (res Object, err error)

IndexGet returns a character at a given index.

func (*String) IsFalsy

func (o *String) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*String) Iterate

func (o *String) Iterate() Iterator

Iterate creates a string iterator.

func (*String) String

func (o *String) String() string

func (*String) TypeName

func (o *String) TypeName() string

TypeName returns the name of the type.

type StringIterator

type StringIterator struct {
	// contains filtered or unexported fields
}

StringIterator represents an iterator for a string.

func (*StringIterator) BinaryOp

func (i *StringIterator) BinaryOp(op token.Token, rhs Object) (Object, error)

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

type Time struct {
	Value time.Time
}

Time represents a time value.

func (*Time) BinaryOp

func (o *Time) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Time) Copy

func (o *Time) Copy() Object

Copy returns a copy of the type.

func (*Time) Equals

func (o *Time) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Time) IsFalsy

func (o *Time) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Time) String

func (o *Time) String() string

func (*Time) TypeName

func (o *Time) TypeName() string

TypeName returns the name of the type.

type Undefined

type Undefined struct{}

Undefined represents an undefined value.

func (*Undefined) BinaryOp

func (o *Undefined) BinaryOp(op token.Token, rhs Object) (Object, error)

BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.

func (*Undefined) Copy

func (o *Undefined) Copy() Object

Copy returns a copy of the type.

func (*Undefined) Equals

func (o *Undefined) Equals(x Object) bool

Equals returns true if the value of the type is equal to the value of another object.

func (*Undefined) IndexGet added in v1.8.0

func (o *Undefined) IndexGet(index Object) (Object, error)

IndexGet returns an element at a given index.

func (*Undefined) IsFalsy

func (o *Undefined) IsFalsy() bool

IsFalsy returns true if the value of the type is falsy.

func (*Undefined) String

func (o *Undefined) String() string

func (*Undefined) TypeName

func (o *Undefined) TypeName() string

TypeName returns the name of the type.

type UserFunction

type UserFunction struct {
	Name  string
	Value CallableFunc
}

UserFunction represents a user function.

func (*UserFunction) BinaryOp

func (o *UserFunction) BinaryOp(op token.Token, rhs Object) (Object, error)

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) Copy

func (o *UserFunction) Copy() Object

Copy returns a copy of the type.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL