Documentation
¶
Overview ¶
* Package object helps represent the values encountered when evaluating the jaba program as an object. * Every value will be wrapped in a struct that fulfills the object interface. * The object system leverages on the host language (Go) data types and formatting methods to represent its values
* Package object helps represent the values encountered when evaluating the jaba program as an object. * Every value will be wrapped in a struct that fulfills the object interface. * The object system leverages on the host language (Go) data types and formatting methods to represent its values
Index ¶
Constants ¶
const ( INTEGER_OBJECT = "INTEGER" BOOLEAN_OBJECT = "BOOLEAN" NULL_OBJECT = "NULL" RETURN_VALUE_OBJECT = "RETURN_VALUE" ERROR_OBJECT = "ERROR" FUNCTION_OBJECT = "FUNCTION_OBJECT" STRING_OBJECT = "STRING" BUILTIN_OBJECT = "BUILTIN" ARRAY_OBJECT = "ARRAY" HASH_OBJECT = "HASH" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶ added in v0.0.6
type Array struct {
Elements []Object
}
Array represents a jaba builtin array of objects it fulfills the Object interface by implementing the Type() and Inspect() methods
func (*Array) Inspect ¶ added in v0.0.6
Inspect returns the string representation of the object value, array
func (*Array) Type ¶ added in v0.0.6
func (a *Array) Type() ObjectType
Type returns the type of the object, array
type Boolean ¶
type Boolean struct {
Value bool
}
Boolean is a jaba data type that represents true or false It fulfills the object interface by implementing the Type() and Inspect() methods
type Builtin ¶ added in v0.0.3
type Builtin struct {
Function BuiltinFunction
}
Builtin is a wrapper around golang function which is the host language it fulfills the Object interface by implementing the Type() and Inspect() methods
func (*Builtin) Inspect ¶ added in v0.0.3
Inspect returns the string representation of the object value, builtin
func (*Builtin) Type ¶ added in v0.0.3
func (b *Builtin) Type() ObjectType
Type returns the type of the object, builtin
type BuiltinFunction ¶ added in v0.0.3
BuiltinFunction represents a jaba builtin function which is from the host language that allows user to use host language functions
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is a wrapper of the map implementation that helps associate a string key with an object
func NewEnclosedEnvironment ¶
func NewEnclosedEnvironment(outer *Environment) *Environment
NewEnclosedEnvironment creates a new instance of an scoped environment it extends the Environment instance to cater for enclosed environments
func NewEnvironment ¶
func NewEnvironment() *Environment
NewEnvironment creates a new instance of the environment
type Error ¶
type Error struct {
Message string
}
Error represents internal jaba error it fulfills the Object interface by implementing the Type() and Inspect() methods
type Function ¶
type Function struct { // Parameters is a list of identifiers that should be passed to the function call Parameters []*ast.Identifier // Body contains a list of function statements to be evaluated Body *ast.BlockStatement // Env keeps track of variables during interpreter execution Env *Environment }
Function represents a jaba function and may include parameters and some statements to be executed it fulfills the Object interface by implementing the Type() and Inspect() methods
func (*Function) Type ¶
func (f *Function) Type() ObjectType
Type returns the type of the object, function
type Hash ¶ added in v0.0.7
Hash represents a jaba hash it fulfills the Object interface by implementing the Type() and Inspect() methods
func (*Hash) Inspect ¶ added in v0.0.7
Inspect returns the string representation of the object value, hash pair
func (*Hash) Type ¶ added in v0.0.7
func (p *Hash) Type() ObjectType
Type returns the type of the object, hash pair
type HashKey ¶ added in v0.0.7
type HashKey struct { // Type returns the type of the key (string, boolean, integer, ...) Type ObjectType // Value is hash used to represent the key Value uint64 }
HashKey represents a a comparison object used in hashing jaba maps(hashes)
type Hashable ¶ added in v0.0.7
type Hashable interface {
HashKey() HashKey
}
Hashable is an interface that can be used to evaluate if an object can be used as a hash key
type Integer ¶
type Integer struct {
Value int64
}
Integer is a jaba data type that represents numbers It fulfills the object interface by implementing the Type() and Inspect() methods
type Null ¶
type Null struct {
Value interface{}
}
Null represents absence of a value It fulfills the object interface by implementing the Type() and Inspect() methods
type Object ¶
type Object interface { // Type returns the type of the object Type() ObjectType // Inspect returns the string representation of the object value Inspect() string }
Object is an interface that helps represent the values encountered when evaluating the jaba program
type ReturnValue ¶
type ReturnValue struct {
Value Object
}
ReturnValue represents a jaba return value It fulfills the object interface by implementing the Type() and Inspect() methods
func (*ReturnValue) Inspect ¶
func (r *ReturnValue) Inspect() string
Inspect returns the string representation of the object value, return value
func (*ReturnValue) Type ¶
func (r *ReturnValue) Type() ObjectType
Type returns the type of the object
type String ¶
type String struct { // Value is the actual value of the string literal Value string }
String represents a jaba string which is an expression which evaluates to a value it fulfills the Object interface by implementing the Type() and Inspect() methods
func (*String) Type ¶
func (s *String) Type() ObjectType
Type returns the type of the object, string