Documentation
¶
Overview ¶
object/object.go
Index ¶
- Constants
- Variables
- type Array
- type Boolean
- type BoundMethod
- type Builtin
- type BuiltinFunction
- type CustomError
- type Environment
- type Error
- type Float
- type Function
- type Hash
- type HashKey
- type HashPair
- type Hashable
- type Instance
- type Integer
- type Namespace
- type None
- type Object
- type ObjectType
- type ReturnValue
- type Skip
- type Spellbook
- type Stop
- type String
- type Tuple
Constants ¶
View Source
const ( INTEGER_OBJ = "INTEGER" FLOAT_OBJ = "FLOAT" BOOLEAN_OBJ = "BOOLEAN" NONE_OBJ = "NONE" RETURN_VALUE_OBJ = "RETURN_VALUE" ERROR_OBJ = "ERROR" FUNCTION_OBJ = "FUNCTION" STRING_OBJ = "STRING" ARRAY_OBJ = "ARRAY" BUILTIN_OBJ = "BUILTIN" HASH_OBJ = "HASH" TUPLE_OBJ = "TUPLE" SPELLBOOK_OBJ = "SPELLBOOK" INSTANCE_OBJ = "INSTANCE" NAMESPACE_OBJ = "NAMESPACE" )
View Source
const (
CUSTOM_ERROR_OBJ = "USER DEFINED ERROR"
)
Variables ¶
View Source
var ( STOP = &Stop{} SKIP = &Skip{} )
View Source
var NONE = &None{}
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
Elements []Object
}
func (*Array) Type ¶
func (ao *Array) Type() ObjectType
type Boolean ¶
type Boolean struct {
Value bool
}
func (*Boolean) Type ¶
func (b *Boolean) Type() ObjectType
type BoundMethod ¶
func (*BoundMethod) Inspect ¶
func (bm *BoundMethod) Inspect() string
func (*BoundMethod) Type ¶
func (bm *BoundMethod) Type() ObjectType
type Builtin ¶
type Builtin struct {
Fn BuiltinFunction
}
func (*Builtin) Type ¶
func (b *Builtin) Type() ObjectType
type BuiltinFunction ¶
type CustomError ¶
type CustomError struct {
Name string // Name of the error type (e.g., "ValueError")
Message string // Error message
Details map[string]Object // Additional details (optional)
ErrorType *Spellbook // The spellbook (class) this error belongs to (renamed to avoid conflict)
Instance *Instance // Instance of the error (if applicable)
}
CustomError represents a user-defined error in the language.
func NewCustomError ¶
func NewCustomError(name, message string) *CustomError
NewCustomError creates a new CustomError object.
func (*CustomError) AddDetail ¶
func (ce *CustomError) AddDetail(key string, value Object)
AddDetail adds a key-value pair to the error's details.
func (*CustomError) Inspect ¶
func (ce *CustomError) Inspect() string
Inspect returns a string representation of the error (implements the Object interface).
func (*CustomError) Type ¶
func (ce *CustomError) Type() ObjectType
Type returns the type of the object (implements the Object interface).
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
environment.go
func NewEnclosedEnvironment ¶
func NewEnclosedEnvironment(outer *Environment) *Environment
func NewEnvironment ¶
func NewEnvironment() *Environment
func (*Environment) GetNames ¶
func (e *Environment) GetNames() []string
func (*Environment) GetOuter ¶
func (e *Environment) GetOuter() *Environment
type Error ¶
type Error struct {
Message string
}
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type Float ¶
type Float struct {
Value float64
}
func (*Float) Type ¶
func (f *Float) Type() ObjectType
type Function ¶
type Function struct {
Parameters []*ast.Parameter
Body *ast.BlockStatement
Env *Environment
IsAbstract bool
IsPrivate bool
IsProtected bool
}
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type HashKey ¶
type HashKey struct {
Type ObjectType
Value uint64
}
type Instance ¶
type Instance struct {
Spellbook *Spellbook
Env *Environment
}
Ensure Instance type implements Object
func (*Instance) Type ¶
func (i *Instance) Type() ObjectType
type Integer ¶
type Integer struct {
Value int64
}
func (*Integer) Type ¶
func (i *Integer) Type() ObjectType
type Namespace ¶
type Namespace struct {
Env *Environment // Holds all exported members of the imported module
}
func (*Namespace) Type ¶
func (n *Namespace) Type() ObjectType
type Object ¶
type Object interface {
Type() ObjectType
Inspect() string
}
type ObjectType ¶
type ObjectType string
type ReturnValue ¶
type ReturnValue struct {
Value Object
}
func (*ReturnValue) Inspect ¶
func (rv *ReturnValue) Inspect() string
func (*ReturnValue) Type ¶
func (rv *ReturnValue) Type() ObjectType
type Spellbook ¶
type Spellbook struct {
Name string
Methods map[string]*Function
InitMethod *Function
Inherits *Spellbook
Env *Environment // Add environment to store the spellbook's scope
IsArcane bool
}
Update Object (object.go)
func (*Spellbook) Type ¶
func (s *Spellbook) Type() ObjectType
Click to show internal directories.
Click to hide internal directories.