Documentation ¶
Overview ¶
Package object contains types that represent in-memory objects while the interpreter is evaluating source code.
Index ¶
Constants ¶
const (
// TypeArray is the type for an array value
TypeArray = "Array"
)
const (
// TypeBoolean is the type for a boolean value
TypeBoolean = "Boolean"
)
const (
// TypeCharacter is the type for a character value.
TypeCharacter = "Character"
)
const (
// TypeError is the type for an error value.
TypeError = "error"
)
const (
// TypeFunction is the type for a function value
TypeFunction = "Function"
)
const (
// TypeHash is the type returned by hash objects.
TypeHash = "Hash"
)
const (
// TypeNull is the type for null objects.
TypeNull = "null"
)
const (
// TypeNumber is the type for a numerical value
TypeNumber = "Number"
)
const (
// TypeReturnValue is the object type for `return` values.
TypeReturnValue = "ReturnValue"
)
const (
// TypeString is the type for a string value.
TypeString = "String"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
Elements []Object
}
The Array type represents an array of objects
type Atomic ¶
type Atomic struct {
// contains filtered or unexported fields
}
The Atomic type is a wrapper around Object that indicates the object is atomic. The value must be accessed via the getters/setters that use a mutex.
func MakeAtomic ¶
MakeAtomic converts a given object into an atomic one
type Boolean ¶
type Boolean struct {
Value bool
}
The Boolean type represents a true/false value in memory.
func (*Boolean) Clone ¶
Clone creates a copy of the current object that can be used without modifying the original value
type Builtin ¶
The Builtin type represents a built-in function that can be called from the source code.
type Character ¶
type Character struct {
Value rune
}
The Character type represents a character value in memory.
func (*Character) Clone ¶
Clone creates a copy of the current object that can be used without modifying the original value
type Constant ¶
type Constant struct {
Value Object
}
The Constant type is a wrapper around Object that indicates the object is immutable.
type Function ¶
type Function struct { Name *ast.Identifier Parameters []*ast.Identifier Body *ast.BlockStatement Async bool }
The Function type represents a function definition in memory that can be called/executed.
type Hash ¶
The Hash type represents a hash stored in memory. Each key is uniquely generated based on the type used as the underlying key.
type Hashable ¶
type Hashable interface {
HashKey() HashKey
}
The Hashable interfaces defines a type that can be stored in a hash
type Number ¶
type Number struct {
Value float64
}
The Number type represents a number stored in memory. All numbers are 64 bit floating point numbers.
func (*Number) Clone ¶
Clone creates a copy of the current object that can be used without modifying the original value
type ReturnValue ¶
type ReturnValue struct {
Value Object
}
The ReturnValue type represents a return value in the source code. For example return 1
func (*ReturnValue) Clone ¶
func (rv *ReturnValue) Clone() Object
Clone creates a copy of the current object that can be used without modifying the original value
func (*ReturnValue) String ¶
func (rv *ReturnValue) String() string
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
The Scope type contains all accessible objects for a certain scope. It allows for objects with the same name to be declared at different scopes and access them in order of current scope to last parent scope.
func (*Scope) Get ¶
Get attempts to obtain an object from the scope using the given name. If it does not exist at the current scope, the parent is checked until the value is found.
func (*Scope) NewChildScope ¶
NewChildScope creates a new scope using the called scope as the parent.
type String ¶
type String struct {
Value string
}
The String type represents a string value in memory.
func (*String) Clone ¶
Clone creates a copy of the current object that can be used without modifying the original value