Documentation ¶
Overview ¶
Package object describes a named language entity such as a type, variable, function, or literal. All objects implement the Object interface.
Package object describes a named language entity such as a type, variable, function, or literal. All objects implement the Object interface.
Index ¶
Constants ¶
const ( BOOLEAN_OBJ = "BOOLEAN" BUILTIN_OBJ = "BUILTIN" ERROR_OBJ = "ERROR" FUNCTION_OBJ = "FUNCTION" LIST_OBJ = "LIST" MAP_OBJ = "MAP" MODULE_OBJ = "MODULE" NULL_OBJ = "NULL" NUMBER_OBJ = "NUMBER" PACKAGE_OBJ = "PACKAGE" RETURN_VALUE_OBJ = "RETURN_VALUE" STRING_OBJ = "STRING" NoMethodFound = "no method '%s' for %s found" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Boolean ¶
type Boolean struct {
Value bool
}
func (*Boolean) CallMethod ¶ added in v0.10.0
func (*Boolean) Type ¶
func (b *Boolean) Type() ObjectType
type Builtin ¶
type Builtin struct { Name string Fn BuiltinFunction }
func (*Builtin) CallMethod ¶ added in v0.10.0
func (*Builtin) Type ¶
func (b *Builtin) Type() ObjectType
type BuiltinFunction ¶
type BuiltinFunction func(env *Environment, line int, args ...Object) Object
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is an object that holds a mapping of names to bound objects
func NewEnclosedEnvironment ¶
func NewEnclosedEnvironment(outer *Environment) *Environment
NewEnclosedEnvironment constructs a new Environment, extending off a pre-existing environment.
func NewEnvironment ¶
func NewEnvironment() *Environment
NewEnvironment constructs a new Environment object to hold bindings of identifiers to their names
func (*Environment) All ¶
func (e *Environment) All() map[string]Object
All returns all stored identifiers.
func (*Environment) Delete ¶ added in v0.3.0
func (e *Environment) Delete(name string)
Delete removes the object with the given name
func (*Environment) Exported ¶
func (e *Environment) Exported() *Map
type Error ¶
type Error struct {
Message string
}
func (*Error) CallMethod ¶ added in v0.10.0
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type Function ¶
type Function struct { Parameters []*ast.IdentifierLiteral Body *ast.BlockStatement Defaults map[string]ast.Expression Env *Environment }
func (*Function) CallMethod ¶ added in v0.10.0
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type List ¶
type List struct {
Elements []Object
}
func (*List) CallMethod ¶ added in v0.10.0
func (*List) Type ¶
func (l *List) Type() ObjectType
type Map ¶
func (*Map) CallMethod ¶ added in v0.10.0
func (*Map) GetKeyType ¶ added in v0.6.0
func (m *Map) GetKeyType(key string) ObjectType
func (*Map) Type ¶
func (m *Map) Type() ObjectType
type MapKey ¶
type MapKey struct { Type ObjectType Value uint64 }
MapKey defines the key for maps that can be comparable and unique.
type Module ¶
type Module struct { Name string Functions []BuiltinFunction }
func (*Module) CallMethod ¶ added in v0.10.0
func (*Module) Type ¶
func (m *Module) Type() ObjectType
type Mutable ¶
type Mutable interface {
Set(obj Object)
}
Mutable interface is implemented by all mutable objects.
type Null ¶
type Null struct{}
func (*Null) CallMethod ¶ added in v0.10.0
func (*Null) Type ¶
func (n *Null) Type() ObjectType
type Number ¶
func (*Number) CallMethod ¶ added in v0.10.0
func (*Number) Type ¶
func (n *Number) Type() ObjectType
type Object ¶
type Object interface { Type() ObjectType Inspect() string CallMethod(method string, args []Object) Object }
Object interface is implemented by all objects.
type ObjectType ¶
type ObjectType string
type Package ¶ added in v0.4.0
func (*Package) CallMethod ¶ added in v0.10.0
func (*Package) Type ¶ added in v0.4.0
func (m *Package) Type() ObjectType
type ReturnValue ¶
type ReturnValue struct {
Value Object
}
func (*ReturnValue) CallMethod ¶ added in v0.10.0
func (rv *ReturnValue) CallMethod(method string, args []Object) Object
func (*ReturnValue) Inspect ¶
func (rv *ReturnValue) Inspect() string
func (*ReturnValue) Type ¶
func (rv *ReturnValue) Type() ObjectType
type String ¶
type String struct {
Value string
}
func (*String) CallMethod ¶ added in v0.10.0
func (*String) Type ¶
func (s *String) Type() ObjectType