Documentation ¶
Index ¶
- Constants
- func IsError(obj Object) bool
- func IsFalse(obj Object) bool
- func IsTrue(obj Object) bool
- func ObjectToAnyValue(val Object) any
- func RegisterEvaluator(e func(node ast.Node, scope *Scope) Object)
- type Boolean
- type Break
- type Class
- type Continue
- type Environment
- func (environment *Environment) All() map[string]Object
- func (environment *Environment) Call(function string, args []Object, writer io.Writer) Object
- func (environment *Environment) Delete(name string)
- func (environment *Environment) Get(name string) (Object, bool)
- func (environment *Environment) GetDirectory() string
- func (environment *Environment) GetWriter() io.Writer
- func (environment *Environment) Has(name string) bool
- func (environment *Environment) Set(name string, value Object) Object
- func (environment *Environment) SetDirectory(directory string)
- func (environment *Environment) SetWriter(writer io.Writer)
- type Error
- type Function
- type GoFunction
- type GoProperty
- type HasMethods
- type Instance
- type LibraryFunction
- type LibraryModule
- type LibraryProperty
- type List
- type Map
- type MapKey
- type MapPair
- type Mappable
- type Null
- type Number
- type Object
- type ObjectMethod
- type Return
- type Scope
- type String
- type Trait
- type Type
Constants ¶
const BOOLEAN = "BOOLEAN"
const BREAK = "BREAK"
const CLASS = "CLASS"
const CONTINUE = "CONTINUE"
const ERROR = "ERROR"
const FUNCTION = "FUNCTION"
const INSTANCE = "INSTANCE"
const LIBRARY_FUNCTION = "LIBRARY_FUNCTION"
const LIBRARY_MODULE = "LIBRARY_MODULE"
const LIBRARY_PROPERTY = "LIBRARY_PROPERTY"
const LIST = "LIST"
const MAP = "MAP"
const NULL = "NULL"
const NUMBER = "NUMBER"
const RETURN = "RETURN"
const SCOPE = "SCOPE"
const STRING = "STRING"
const TRAIT = "TRAIT"
Variables ¶
This section is empty.
Functions ¶
func ObjectToAnyValue ¶ added in v0.21.0
Types ¶
type Boolean ¶
type Boolean struct {
Value bool
}
Boolean objects consist of a boolean value.
func (*Boolean) Method ¶ added in v0.18.0
Method defines the set of methods available on boolean objects.
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
Method defines the set of methods available on break objects.
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
Method defines the set of methods available on class objects.
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
Method defines the set of methods available on continue objects.
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
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) 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) 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 (*Error) Method ¶ added in v0.18.0
Method defines the set of methods available on error objects.
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
Evaluate evaluates the function's body ast.Block and returns the result.
func (*Function) Method ¶ added in v0.18.0
Method defines the set of methods available on function objects.
type GoFunction ¶ added in v0.18.0
type HasMethods ¶ added in v0.18.0
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) Method ¶ added in v0.18.0
Method defines the set of methods available on instance objects.
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.
type Map ¶
Map objects consist of a map value.
type Null ¶
type Null struct{}
Null objects consist of a nil value.
type Number ¶
Number objects consist of a decimal value.
func (*Number) Method ¶ added in v0.18.0
Method defines the set of methods available on number objects.
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
type ObjectMethod ¶ added in v0.18.0
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
Method defines the set of methods available on return objects.
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
Method defines the set of methods available on scope objects.
type String ¶
type String struct {
Value string
}
String objects consist of a string value.
func (*String) Method ¶ added in v0.18.0
Method defines the set of methods available on string objects.
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
Method defines the set of methods available on trait objects.