Documentation
¶
Overview ¶
object/object.go
src/object/error_trace.go
Index ¶
- Constants
- Variables
- type Array
- type Boolean
- type BoundMethod
- type Builtin
- type BuiltinFunction
- type CaughtError
- type CustomError
- type Environment
- func (e *Environment) Clone() *Environment
- func (e *Environment) Get(name string) (Object, bool)
- func (e *Environment) GetDebugConfig() *debug.Config
- func (e *Environment) GetNames() []string
- func (e *Environment) GetOuter() *Environment
- func (e *Environment) IsGlobal(name string) bool
- func (e *Environment) MarkGlobal(name string)
- func (e *Environment) Set(name string, val Object) Object
- func (e *Environment) SetDebugConfig(config *debug.Config)
- func (e *Environment) SetGlobal(name string, val Object) Object
- func (e *Environment) SetWithGlobalCheck(name string, val Object) Object
- type Error
- type ErrorWithTrace
- func (e *ErrorWithTrace) AddDetail(key string, value Object) *ErrorWithTrace
- func (e *ErrorWithTrace) AddStackEntry(functionName string, pos SourcePosition) *ErrorWithTrace
- func (e *ErrorWithTrace) Inspect() string
- func (e *ErrorWithTrace) String() string
- func (e *ErrorWithTrace) Type() ObjectType
- func (e *ErrorWithTrace) WithCause(cause *ErrorWithTrace) *ErrorWithTrace
- type Float
- type Function
- type Grimoire
- 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 SourcePosition
- type StackTraceEntry
- type Stop
- type String
- type Tuple
Constants ¶
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" GRIMOIRE_OBJ = "GRIMOIRE" INSTANCE_OBJ = "INSTANCE" NAMESPACE_OBJ = "NAMESPACE" )
const (
CUSTOM_ERROR_OBJ = "USER DEFINED ERROR"
)
Variables ¶
var ( STOP = &Stop{} SKIP = &Skip{} )
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 CaughtError ¶ added in v0.1.7
type CaughtError struct {
OriginalError Object
}
CaughtError wraps an error that has been caught by an ensnare clause This prevents it from being treated as a propagatable error
func (*CaughtError) Inspect ¶ added in v0.1.7
func (ce *CaughtError) Inspect() string
func (*CaughtError) Type ¶ added in v0.1.7
func (ce *CaughtError) Type() ObjectType
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 *Grimoire // The grimoire (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) Clone ¶ added in v0.1.6
func (e *Environment) Clone() *Environment
Clone creates a deep copy of the environment to prevent shared references
func (*Environment) GetDebugConfig ¶ added in v0.1.6
func (e *Environment) GetDebugConfig() *debug.Config
GetDebugConfig returns the debug configuration
func (*Environment) GetNames ¶
func (e *Environment) GetNames() []string
func (*Environment) GetOuter ¶
func (e *Environment) GetOuter() *Environment
func (*Environment) IsGlobal ¶ added in v0.1.7
func (e *Environment) IsGlobal(name string) bool
IsGlobal checks if a variable is marked as global in this environment
func (*Environment) MarkGlobal ¶ added in v0.1.7
func (e *Environment) MarkGlobal(name string)
MarkGlobal marks a variable as global in the current environment
func (*Environment) SetDebugConfig ¶ added in v0.1.6
func (e *Environment) SetDebugConfig(config *debug.Config)
SetDebugConfig sets the debug configuration for this environment
func (*Environment) SetGlobal ¶ added in v0.1.7
func (e *Environment) SetGlobal(name string, val Object) Object
SetGlobal sets a variable in the global scope (outermost environment)
func (*Environment) SetWithGlobalCheck ¶ added in v0.1.7
func (e *Environment) SetWithGlobalCheck(name string, val Object) Object
SetWithGlobalCheck sets a variable, checking if it should be set in global scope
type Error ¶
type Error struct {
Message string
}
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type ErrorWithTrace ¶ added in v0.1.6
type ErrorWithTrace struct {
ErrorType ObjectType // Changed from Type to ErrorType to avoid conflict
Message string
Position SourcePosition
Cause *ErrorWithTrace
Stack []StackTraceEntry
CustomDetails map[string]Object
}
ErrorWithTrace extends the basic error with stack trace and source position information
func (*ErrorWithTrace) AddDetail ¶ added in v0.1.6
func (e *ErrorWithTrace) AddDetail(key string, value Object) *ErrorWithTrace
func (*ErrorWithTrace) AddStackEntry ¶ added in v0.1.6
func (e *ErrorWithTrace) AddStackEntry(functionName string, pos SourcePosition) *ErrorWithTrace
func (*ErrorWithTrace) Inspect ¶ added in v0.1.6
func (e *ErrorWithTrace) Inspect() string
func (*ErrorWithTrace) String ¶ added in v0.1.6
func (e *ErrorWithTrace) String() string
Optional, so fmt.Println(err) prints same view.
func (*ErrorWithTrace) Type ¶ added in v0.1.6
func (e *ErrorWithTrace) Type() ObjectType
To satisfy the Object interface
func (*ErrorWithTrace) WithCause ¶ added in v0.1.6
func (e *ErrorWithTrace) WithCause(cause *ErrorWithTrace) *ErrorWithTrace
Added setter methods for fluent API
type Float ¶
type Float struct {
Value float64
}
func (*Float) Type ¶
func (f *Float) Type() ObjectType
type Function ¶
type Function struct {
// Parameters holds function parameters, either simple identifiers or full Parameter nodes
Parameters []ast.Expression
Body *ast.BlockStatement
Env *Environment
IsAbstract bool
IsPrivate bool
IsProtected bool
}
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type Grimoire ¶ added in v0.1.6
type Grimoire struct {
Name string
Methods map[string]*Function
InitMethod *Function
Inherits *Grimoire
Env *Environment // Add environment to store the grimoire's scope
IsArcane bool
}
Update Object (object.go)
func (*Grimoire) Type ¶ added in v0.1.6
func (s *Grimoire) Type() ObjectType
type HashKey ¶
type HashKey struct {
Type ObjectType
Value uint64
}
type Instance ¶
type Instance struct {
Grimoire *Grimoire
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 SourcePosition ¶ added in v0.1.6
SourcePosition tracks the location of code in source files
func (SourcePosition) String ¶ added in v0.1.6
func (sp SourcePosition) String() string
type StackTraceEntry ¶ added in v0.1.6
type StackTraceEntry struct {
FunctionName string
Position SourcePosition
}
StackTraceEntry represents a single frame in the error stack trace
func (StackTraceEntry) String ¶ added in v0.1.6
func (ste StackTraceEntry) String() string