object

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const BOOLEAN = "BOOLEAN"
View Source
const BREAK = "BREAK"
View Source
const CLASS = "CLASS"
View Source
const CONTINUE = "CONTINUE"
View Source
const ERROR = "ERROR"
View Source
const FUNCTION = "FUNCTION"
View Source
const INSTANCE = "INSTANCE"
View Source
const LIBRARY_FUNCTION = "LIBRARY_FUNCTION"
View Source
const LIBRARY_MODULE = "LIBRARY_MODULE"
View Source
const LIBRARY_PROPERTY = "LIBRARY_PROPERTY"
View Source
const LIST = "LIST"
View Source
const MAP = "MAP"
View Source
const NULL = "NULL"
View Source
const NUMBER = "NUMBER"
View Source
const RETURN = "RETURN"
View Source
const SCOPE = "SCOPE"
View Source
const STRING = "STRING"
View Source
const TRAIT = "TRAIT"

Variables

This section is empty.

Functions

func IsError added in v0.18.0

func IsError(obj Object) bool

IsError determines if the referenced object is an error.

func IsFalse added in v0.18.0

func IsFalse(obj Object) bool

func IsTrue added in v0.18.0

func IsTrue(obj Object) bool

func ObjectToAnyValue added in v0.21.0

func ObjectToAnyValue(val Object) any

func RegisterEvaluator added in v0.18.0

func RegisterEvaluator(e func(node ast.Node, scope *Scope) Object)

Types

type Boolean

type Boolean struct {
	Value bool
}

Boolean objects consist of a boolean value.

func (*Boolean) MapKey

func (boolean *Boolean) MapKey() MapKey

MapKey defines a unique hash value for use as a map key.

func (*Boolean) Method added in v0.18.0

func (boolean *Boolean) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on boolean objects.

func (*Boolean) String added in v0.18.0

func (boolean *Boolean) String() string

String represents the boolean object's value as a string.

func (*Boolean) Type

func (boolean *Boolean) Type() Type

Type returns the boolean object type.

type Break added in v0.18.0

type Break struct{}

Break objects consist of a nil value.

func (*Break) Method added in v0.18.0

func (obj *Break) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on break objects.

func (*Break) String added in v0.18.0

func (obj *Break) String() string

String represents the break object's value as a string.

func (*Break) Type added in v0.18.0

func (obj *Break) Type() Type

Type returns the break object type.

type Class added in v0.18.0

type Class struct {
	Name        *ast.Identifier
	Scope       *Scope
	Environment *Environment
	Super       *Class
	Traits      []*Trait
}

Class objects consist of a body and an environment.

func (*Class) Method added in v0.18.0

func (class *Class) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on class objects.

func (*Class) String added in v0.18.0

func (class *Class) String() string

String represents the class object's value as a string.

func (*Class) Type added in v0.18.0

func (class *Class) Type() Type

Type returns the class object type.

type Continue added in v0.18.0

type Continue struct{}

Continue objects consist of a nil value.

func (*Continue) Method added in v0.18.0

func (obj *Continue) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on continue objects.

func (*Continue) String added in v0.18.0

func (obj *Continue) String() string

String represents the continue object's value as a string.

func (*Continue) Type added in v0.18.0

func (obj *Continue) Type() Type

Type returns the continue object type.

type Environment

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

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) All

func (environment *Environment) All() map[string]Object

func (*Environment) Call added in v0.19.0

func (environment *Environment) Call(function string, args []Object, writer io.Writer) Object

create a new function "Call" that can be used to call a function within the environment.

func (*Environment) Delete added in v0.3.0

func (environment *Environment) Delete(name string)

func (*Environment) Get

func (environment *Environment) Get(name string) (Object, bool)

func (*Environment) GetDirectory added in v0.14.0

func (environment *Environment) GetDirectory() string

func (*Environment) GetWriter added in v0.12.0

func (environment *Environment) GetWriter() io.Writer

func (*Environment) Has added in v0.18.0

func (environment *Environment) Has(name string) bool

func (*Environment) Set

func (environment *Environment) Set(name string, value Object) Object

func (*Environment) SetDirectory added in v0.14.0

func (environment *Environment) SetDirectory(directory string)

func (*Environment) SetWriter added in v0.12.0

func (environment *Environment) SetWriter(writer io.Writer)

type Error

type Error struct {
	Message string
}

Error objects consist of a nil value.

func NewError added in v0.18.0

func NewError(format string, a ...interface{}) *Error

func (*Error) Method added in v0.18.0

func (err *Error) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on error objects.

func (*Error) String added in v0.18.0

func (err *Error) String() string

String represents the error object's value as a string.

func (*Error) Type

func (err *Error) Type() Type

Type returns the error object type.

type Function

type Function struct {
	Parameters []*ast.Identifier
	Body       *ast.Block
	Defaults   map[string]ast.ExpressionNode
	Scope      *Scope
}

Function objects consist of a user-generated function.

func (*Function) Evaluate added in v0.18.0

func (function *Function) Evaluate(args []Object, writer io.Writer) Object

Evaluate evaluates the function's body ast.Block and returns the result.

func (*Function) Method added in v0.18.0

func (function *Function) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on function objects.

func (*Function) String added in v0.18.0

func (function *Function) String() string

String represents the function object's value as a string.

func (*Function) Type

func (function *Function) Type() Type

Type returns the function object type.

type GoFunction added in v0.18.0

type GoFunction func(scope *Scope, tok token.Token, args ...Object) Object

type GoProperty added in v0.18.0

type GoProperty func(scope *Scope, tok token.Token) Object

type HasMethods added in v0.18.0

type HasMethods interface {
	Method(method string, args []Object) (Object, bool)
}

type Instance added in v0.18.0

type Instance struct {
	Class       *Class
	Environment *Environment
}

Instance objects consist of a body and an environment.

func (*Instance) Call added in v0.18.0

func (instance *Instance) Call(name string, arguments []Object, tok token.Token) Object

func (*Instance) Method added in v0.18.0

func (instance *Instance) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on instance objects.

func (*Instance) String added in v0.18.0

func (instance *Instance) String() string

String represents the instance object's value as a string.

func (*Instance) Type added in v0.18.0

func (instance *Instance) Type() Type

Type returns the instance object type.

type LibraryFunction added in v0.18.0

type LibraryFunction struct {
	Name     string
	Function GoFunction
}

LibraryFunction objects consist of a native Go function.

func (*LibraryFunction) Method added in v0.18.0

func (libraryFunction *LibraryFunction) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on library function objects.

func (*LibraryFunction) String added in v0.18.0

func (libraryFunction *LibraryFunction) String() string

String represents the library function's value as a string.

func (*LibraryFunction) Type added in v0.18.0

func (libraryFunction *LibraryFunction) Type() Type

Type returns the library function object type.

type LibraryModule added in v0.18.0

type LibraryModule struct {
	Name       string
	Methods    map[string]*LibraryFunction
	Properties map[string]*LibraryProperty
}

LibraryModule objects consist of a slice of LibraryFunctions.

func (*LibraryModule) Method added in v0.18.0

func (libraryModule *LibraryModule) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on library module objects.

func (*LibraryModule) String added in v0.18.0

func (libraryModule *LibraryModule) String() string

String represents the library module's value as a string.

func (*LibraryModule) Type added in v0.18.0

func (libraryModule *LibraryModule) Type() Type

Type returns the library module object type.

type LibraryProperty added in v0.18.0

type LibraryProperty struct {
	Name     string
	Property GoProperty
}

LibraryProperty objects consist of a native Go property.

func (*LibraryProperty) Method added in v0.18.0

func (libraryProperty *LibraryProperty) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on library property objects.

func (*LibraryProperty) String added in v0.18.0

func (libraryProperty *LibraryProperty) String() string

String represents the library property's value as a string.

func (*LibraryProperty) Type added in v0.18.0

func (libraryProperty *LibraryProperty) Type() Type

Type returns the library property object type.

type List

type List struct {
	Elements []Object
}

List objects consist of a nil value.

func (*List) Method added in v0.18.0

func (list *List) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on list objects.

func (*List) String added in v0.18.0

func (list *List) String() string

String represents the list object's value as a string.

func (*List) Type

func (list *List) Type() Type

Type returns the list object type.

type Map

type Map struct {
	Pairs map[MapKey]MapPair
}

Map objects consist of a map value.

func NewMap added in v0.18.0

func NewMap(values map[string]interface{}) *Map

func (*Map) Method added in v0.18.0

func (mapObject *Map) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on map objects.

func (*Map) String added in v0.18.0

func (mapObject *Map) String() string

String represents the map object's value as a string.

func (*Map) Type

func (mapObject *Map) Type() Type

Type returns the map object type.

type MapKey

type MapKey struct {
	Type  Type
	Value uint64
}

type MapPair

type MapPair struct {
	Key   Object
	Value Object
}

type Mappable

type Mappable interface {
	MapKey() MapKey
}

type Null

type Null struct{}

Null objects consist of a nil value.

func (*Null) Method added in v0.18.0

func (null *Null) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on null objects.

func (*Null) String added in v0.18.0

func (null *Null) String() string

String represents the null object's value as a string.

func (*Null) Type

func (null *Null) Type() Type

Type returns the null object type.

type Number

type Number struct {
	Value decimal.Decimal
}

Number objects consist of a decimal value.

func (*Number) MapKey

func (number *Number) MapKey() MapKey

MapKey defines a unique hash value for use as a map key.

func (*Number) Method added in v0.18.0

func (number *Number) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on number objects.

func (*Number) String added in v0.18.0

func (number *Number) String() string

String represents the number object's value as a string.

func (*Number) Type

func (number *Number) Type() Type

Type returns the number object type.

type Object

type Object interface {
	HasMethods
	Type() Type
	String() string
}

Object is the interface for all object values.

func AnyValueToObject added in v0.21.0

func AnyValueToObject(val any) Object

type ObjectMethod added in v0.18.0

type ObjectMethod func(value interface{}, args ...Object) (Object, bool)

type Return added in v0.18.0

type Return struct {
	Value Object
}

Return objects consist of a value.

func (*Return) Method added in v0.18.0

func (obj *Return) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on return objects.

func (*Return) String added in v0.18.0

func (obj *Return) String() string

String represents the return object's value as a string.

func (*Return) Type added in v0.18.0

func (obj *Return) Type() Type

Type returns the return object type.

type Scope added in v0.18.0

type Scope struct {
	Environment *Environment
	Self        Object
}

Scope objects consist of an environment and parent object.

func (*Scope) Method added in v0.18.0

func (scope *Scope) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on scope objects.

func (*Scope) String added in v0.18.0

func (scope *Scope) String() string

String represents the scope object's value as a string.

func (*Scope) Type added in v0.18.0

func (scope *Scope) Type() Type

Type returns the scope object type.

type String

type String struct {
	Value string
}

String objects consist of a string value.

func (*String) MapKey

func (str *String) MapKey() MapKey

MapKey defines a unique hash value for use as a map key.

func (*String) Method added in v0.18.0

func (str *String) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on string objects.

func (*String) String added in v0.18.0

func (str *String) String() string

String represents the string object's value as a string. So meta.

func (*String) Type

func (str *String) Type() Type

Type returns the string object type.

type Trait added in v0.28.0

type Trait struct {
	Name        *ast.Identifier
	Scope       *Scope
	Environment *Environment
}

Trait objects consist of a body and an environment.

func (*Trait) Method added in v0.28.0

func (trait *Trait) Method(method string, args []Object) (Object, bool)

Method defines the set of methods available on trait objects.

func (*Trait) String added in v0.28.0

func (trait *Trait) String() string

String represents the class object's value as a string.

func (*Trait) Type added in v0.28.0

func (trait *Trait) Type() Type

Type returns the trait object type.

type Type added in v0.18.0

type Type string

Type is the type of the object given as a string.

Jump to

Keyboard shortcuts

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