Documentation
¶
Overview ¶
src/object/enhanced_errors.go
object/object.go
src/object/error_integration.go
src/object/error_trace.go
Index ¶
- Constants
- Variables
- func IsEnhancedError(obj Object) bool
- type Array
- type Boolean
- type BoundMethod
- type Builtin
- type BuiltinFunction
- type CaughtError
- type CustomError
- type Duration
- type EnhancedError
- func ChainErrors(primary *EnhancedError, secondary *EnhancedError) *EnhancedError
- func CreateCompoundError(errors []Object, context *ErrorContext) *EnhancedError
- func ExtractEnhancedError(obj Object) *EnhancedError
- func MergeErrors(errors []*EnhancedError) *EnhancedError
- func NewEnhancedError(errorType ObjectType, message string, span ErrorSpan) *EnhancedError
- func NewIOError(message string, span ErrorSpan) *EnhancedError
- func NewImportError(message string, span ErrorSpan) *EnhancedError
- func NewRuntimeError(message string, span ErrorSpan) *EnhancedError
- func NewSemanticError(message string, span ErrorSpan) *EnhancedError
- func NewSyntaxError(message string, span ErrorSpan) *EnhancedError
- func NewTypeError(message string, span ErrorSpan) *EnhancedError
- func PropagateError(err Object, context *ErrorContext) *EnhancedError
- func UpgradeToEnhancedError(oldError Object, span ErrorSpan) *EnhancedError
- func WrapError(err Object, wrapMessage string, context *ErrorContext) *EnhancedError
- func (e *EnhancedError) AddContext(key string, value Object) *EnhancedError
- func (e *EnhancedError) AddLabel(span ErrorSpan, message string, level ErrorLevel) *EnhancedError
- func (e *EnhancedError) AddNote(message string, level ErrorLevel, span *ErrorSpan) *EnhancedError
- func (e *EnhancedError) AddRelatedError(related *EnhancedError) *EnhancedError
- func (e *EnhancedError) AddStackEntry(functionName string, pos SourcePosition) *EnhancedError
- func (e *EnhancedError) AddSuggestion(title, description string, fixes ...ErrorFix) *EnhancedError
- func (e *EnhancedError) Inspect() string
- func (e *EnhancedError) String() string
- func (e *EnhancedError) Type() ObjectType
- func (e *EnhancedError) WithCategory(category ErrorCategory) *EnhancedError
- func (e *EnhancedError) WithCause(cause *EnhancedError) *EnhancedError
- func (e *EnhancedError) WithCode(code string) *EnhancedError
- func (e *EnhancedError) WithLevel(level ErrorLevel) *EnhancedError
- func (e *EnhancedError) WithSpan(span ErrorSpan) *EnhancedError
- func (e *EnhancedError) WithTitle(title string) *EnhancedError
- 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) GetStore() map[string]Object
- 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 ErrorCategory
- type ErrorConfig
- type ErrorContext
- func (ctx *ErrorContext) AddVariable(name, value string)
- func (ctx *ErrorContext) ClearCallStack()
- func (ctx *ErrorContext) CreatePosition() SourcePosition
- func (ctx *ErrorContext) CreateSpan() ErrorSpan
- func (ctx *ErrorContext) CreateUndefinedVariableError(variableName string) *EnhancedError
- func (ctx *ErrorContext) NewEnhancedArgumentError(functionName string, expected, actual int) *EnhancedError
- func (ctx *ErrorContext) NewEnhancedIndexError(index int, length int) *EnhancedError
- func (ctx *ErrorContext) NewEnhancedRuntimeError(message string) *EnhancedError
- func (ctx *ErrorContext) NewEnhancedSyntaxError(message string, token string) *EnhancedError
- func (ctx *ErrorContext) NewEnhancedTypeError(message string, expectedType, actualType string) *EnhancedError
- func (ctx *ErrorContext) PopCallContext()
- func (ctx *ErrorContext) PushCallContext(functionName string, position SourcePosition)
- func (ctx *ErrorContext) SetFunction(functionName string)
- func (ctx *ErrorContext) SetPosition(line, column int)
- func (ctx *ErrorContext) UpgradeError(err Object) *EnhancedError
- type ErrorFix
- type ErrorLabel
- type ErrorLevel
- type ErrorNote
- type ErrorSpan
- type ErrorSuggestion
- 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 Goroutine
- type GoroutineManager
- func (gm *GoroutineManager) AddAnonymousGoroutine(goroutine *Goroutine) error
- func (gm *GoroutineManager) AddNamedGoroutine(name string, goroutine *Goroutine) error
- func (gm *GoroutineManager) CleanupCompletedGoroutines()
- func (gm *GoroutineManager) ClearAll()
- func (gm *GoroutineManager) GetAllAnonymousGoroutines() []*Goroutine
- func (gm *GoroutineManager) GetAllNamedGoroutines() map[string]*Goroutine
- func (gm *GoroutineManager) GetCapacityInfo() (namedCount, namedMax, anonymousCount, anonymousMax int)
- func (gm *GoroutineManager) GetCompletedCount() (namedCompleted, anonymousCompleted int)
- func (gm *GoroutineManager) GetLimits() (maxNamed, maxAnonymous int, autoCleanup bool)
- func (gm *GoroutineManager) GetNamedGoroutine(name string) (*Goroutine, bool)
- func (gm *GoroutineManager) Inspect() string
- func (gm *GoroutineManager) IsAtCapacity() (namedAtCapacity, anonymousAtCapacity bool)
- func (gm *GoroutineManager) RemoveAndCleanupNamed(name string)
- func (gm *GoroutineManager) RemoveNamedGoroutine(name string)
- func (gm *GoroutineManager) Reset()
- func (gm *GoroutineManager) SetAutoCleanup(enabled bool)
- func (gm *GoroutineManager) SetMaxLimits(maxNamed, maxAnonymous int)
- func (gm *GoroutineManager) Type() ObjectType
- 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 StaticMethod
- type Stop
- type String
- type Super
- type Time
- 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" MAP_OBJ = "MAP" TUPLE_OBJ = "TUPLE" GRIMOIRE_OBJ = "GRIMOIRE" INSTANCE_OBJ = "INSTANCE" NAMESPACE_OBJ = "NAMESPACE" GOROUTINE_OBJ = "GOROUTINE" GOROUTINE_MANAGER_OBJ = "GOROUTINE_MANAGER" CAUGHT_ERROR_OBJ = "CAUGHT_ERROR" STOP_OBJ = "STOP" SKIP_OBJ = "SKIP" SUPER_OBJ = "SUPER" TIME_OBJ = "TIME" DURATION_OBJ = "DURATION" )
const (
CUSTOM_ERROR_OBJ = "USER DEFINED ERROR"
)
Variables ¶
var ( STOP = &Stop{} SKIP = &Skip{} )
var CommonErrorSuggestions = map[string]ErrorSuggestion{ "UNDEFINED_VARIABLE": { Title: "Variable not defined", Description: "The variable you're trying to use hasn't been defined yet.", Fixes: []ErrorFix{ { Description: "Define the variable before using it", }, }, }, "UNDEFINED_FUNCTION": { Title: "Function not defined", Description: "The function you're trying to call hasn't been defined yet.", Fixes: []ErrorFix{ { Description: "Define the function before calling it", }, }, }, "WRONG_ARGUMENT_COUNT": { Title: "Wrong number of arguments", Description: "The function call has the wrong number of arguments.", Fixes: []ErrorFix{ { Description: "Check the function definition and provide the correct number of arguments", }, }, }, "INVALID_ASSIGNMENT": { Title: "Invalid assignment target", Description: "You can only assign to variables, not to expressions.", Fixes: []ErrorFix{ { Description: "Make sure the left side of the assignment is a variable", }, }, }, "DIVISION_BY_ZERO": { Title: "Division by zero", Description: "You cannot divide by zero.", Fixes: []ErrorFix{ { Description: "Check that the divisor is not zero before dividing", }, }, }, "TYPE_MISMATCH": { Title: "Type mismatch", Description: "The operation cannot be performed on values of these types.", Fixes: []ErrorFix{ { Description: "Convert the values to compatible types before performing the operation", }, }, }, "EXPECTED_TOKEN": { Title: "Expected token", Description: "The parser expected a specific token but found something else.", Fixes: []ErrorFix{ { Description: "Check the syntax and add the missing token", }, }, }, "UNEXPECTED_TOKEN": { Title: "Unexpected token", Description: "The parser found a token that doesn't belong here.", Fixes: []ErrorFix{ { Description: "Remove the unexpected token or check the syntax", }, }, }, "MISSING_COLON": { Title: "Missing colon", Description: "Control structures like if, for, while, etc. require a colon at the end.", Fixes: []ErrorFix{ { Description: "Add a colon (:) at the end of the statement", }, }, }, "INDENTATION_ERROR": { Title: "Indentation error", Description: "The code is not properly indented.", Fixes: []ErrorFix{ { Description: "Use consistent indentation (4 spaces per level)", }, }, }, }
Predefined error suggestions for common cases
var NONE = &None{}
Functions ¶
func IsEnhancedError ¶ added in v0.1.8
IsEnhancedError checks if an object is an enhanced error
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) GetMessage ¶ added in v0.1.8
func (ce *CaughtError) GetMessage() string
GetMessage returns the error message
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 Duration ¶ added in v0.1.8
func (*Duration) Type ¶ added in v0.1.8
func (dur *Duration) Type() ObjectType
type EnhancedError ¶ added in v0.1.8
type EnhancedError struct { ErrorType ObjectType Code string // Error code (e.g., "E0001", "SYNTAX_ERROR") Title string // Main error title Message string // Detailed error message Level ErrorLevel // Error severity level Category ErrorCategory // Error category MainSpan ErrorSpan // Primary error location Labels []ErrorLabel // Additional labels pointing to relevant code Suggestions []ErrorSuggestion // Suggestions for fixing the error Notes []ErrorNote // Additional notes and context Cause *EnhancedError // Underlying cause Stack []StackTraceEntry // Call stack Context map[string]Object // Additional context information RelatedErrors []*EnhancedError // Related errors }
EnhancedError represents a comprehensive error with detailed context and suggestions
func ChainErrors ¶ added in v0.1.8
func ChainErrors(primary *EnhancedError, secondary *EnhancedError) *EnhancedError
ChainErrors creates a chain of related errors
func CreateCompoundError ¶ added in v0.1.8
func CreateCompoundError(errors []Object, context *ErrorContext) *EnhancedError
CreateCompoundError creates a compound error from multiple individual errors
func ExtractEnhancedError ¶ added in v0.1.8
func ExtractEnhancedError(obj Object) *EnhancedError
ExtractEnhancedError extracts an enhanced error from an object
func MergeErrors ¶ added in v0.1.8
func MergeErrors(errors []*EnhancedError) *EnhancedError
MergeErrors merges multiple errors into a single enhanced error
func NewEnhancedError ¶ added in v0.1.8
func NewEnhancedError(errorType ObjectType, message string, span ErrorSpan) *EnhancedError
Constructor functions
func NewIOError ¶ added in v0.1.8
func NewIOError(message string, span ErrorSpan) *EnhancedError
func NewImportError ¶ added in v0.1.8
func NewImportError(message string, span ErrorSpan) *EnhancedError
func NewRuntimeError ¶ added in v0.1.8
func NewRuntimeError(message string, span ErrorSpan) *EnhancedError
func NewSemanticError ¶ added in v0.1.8
func NewSemanticError(message string, span ErrorSpan) *EnhancedError
func NewSyntaxError ¶ added in v0.1.8
func NewSyntaxError(message string, span ErrorSpan) *EnhancedError
func NewTypeError ¶ added in v0.1.8
func NewTypeError(message string, span ErrorSpan) *EnhancedError
func PropagateError ¶ added in v0.1.8
func PropagateError(err Object, context *ErrorContext) *EnhancedError
PropagateError propagates an error up the call stack
func UpgradeToEnhancedError ¶ added in v0.1.8
func UpgradeToEnhancedError(oldError Object, span ErrorSpan) *EnhancedError
Helper function to convert old errors to enhanced errors
func WrapError ¶ added in v0.1.8
func WrapError(err Object, wrapMessage string, context *ErrorContext) *EnhancedError
WrapError wraps an error with additional context
func (*EnhancedError) AddContext ¶ added in v0.1.8
func (e *EnhancedError) AddContext(key string, value Object) *EnhancedError
func (*EnhancedError) AddLabel ¶ added in v0.1.8
func (e *EnhancedError) AddLabel(span ErrorSpan, message string, level ErrorLevel) *EnhancedError
func (*EnhancedError) AddNote ¶ added in v0.1.8
func (e *EnhancedError) AddNote(message string, level ErrorLevel, span *ErrorSpan) *EnhancedError
func (*EnhancedError) AddRelatedError ¶ added in v0.1.8
func (e *EnhancedError) AddRelatedError(related *EnhancedError) *EnhancedError
func (*EnhancedError) AddStackEntry ¶ added in v0.1.8
func (e *EnhancedError) AddStackEntry(functionName string, pos SourcePosition) *EnhancedError
func (*EnhancedError) AddSuggestion ¶ added in v0.1.8
func (e *EnhancedError) AddSuggestion(title, description string, fixes ...ErrorFix) *EnhancedError
func (*EnhancedError) Inspect ¶ added in v0.1.8
func (e *EnhancedError) Inspect() string
func (*EnhancedError) String ¶ added in v0.1.8
func (e *EnhancedError) String() string
func (*EnhancedError) Type ¶ added in v0.1.8
func (e *EnhancedError) Type() ObjectType
Implement Object interface
func (*EnhancedError) WithCategory ¶ added in v0.1.8
func (e *EnhancedError) WithCategory(category ErrorCategory) *EnhancedError
func (*EnhancedError) WithCause ¶ added in v0.1.8
func (e *EnhancedError) WithCause(cause *EnhancedError) *EnhancedError
func (*EnhancedError) WithCode ¶ added in v0.1.8
func (e *EnhancedError) WithCode(code string) *EnhancedError
Builder methods for fluent API
func (*EnhancedError) WithLevel ¶ added in v0.1.8
func (e *EnhancedError) WithLevel(level ErrorLevel) *EnhancedError
func (*EnhancedError) WithSpan ¶ added in v0.1.8
func (e *EnhancedError) WithSpan(span ErrorSpan) *EnhancedError
func (*EnhancedError) WithTitle ¶ added in v0.1.8
func (e *EnhancedError) WithTitle(title string) *EnhancedError
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) GetStore ¶ added in v0.1.8
func (e *Environment) GetStore() map[string]Object
GetStore returns a copy of the environment's store for external access
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 ErrorCategory ¶ added in v0.1.8
type ErrorCategory int
ErrorCategory defines the category of error for better organization
const ( ERROR_CATEGORY_SYNTAX ErrorCategory = iota ERROR_CATEGORY_TYPE ERROR_CATEGORY_RUNTIME ERROR_CATEGORY_SEMANTIC ERROR_CATEGORY_IMPORT ERROR_CATEGORY_IO ERROR_CATEGORY_CUSTOM )
func (ErrorCategory) String ¶ added in v0.1.8
func (ec ErrorCategory) String() string
type ErrorConfig ¶ added in v0.1.8
type ErrorConfig struct { UseEnhancedErrors bool ShowSuggestions bool ShowStackTrace bool VerboseMode bool }
ErrorConfig holds configuration for error handling
func DefaultErrorConfig ¶ added in v0.1.8
func DefaultErrorConfig() *ErrorConfig
DefaultErrorConfig returns a default error configuration
type ErrorContext ¶ added in v0.1.8
type ErrorContext struct { CurrentFile string CurrentFunction string CurrentLine int CurrentColumn int SourceCode string CallStack []StackTraceEntry Environment map[string]string // Variable state Config *ErrorConfig }
ErrorContext holds context information for error creation
func NewErrorContext ¶ added in v0.1.8
func NewErrorContext(filename string, sourceCode string) *ErrorContext
NewErrorContext creates a new error context
func (*ErrorContext) AddVariable ¶ added in v0.1.8
func (ctx *ErrorContext) AddVariable(name, value string)
AddVariable adds a variable to the context environment
func (*ErrorContext) ClearCallStack ¶ added in v0.1.8
func (ctx *ErrorContext) ClearCallStack()
ClearCallStack clears the call stack
func (*ErrorContext) CreatePosition ¶ added in v0.1.8
func (ctx *ErrorContext) CreatePosition() SourcePosition
CreatePosition creates a SourcePosition from the current context
func (*ErrorContext) CreateSpan ¶ added in v0.1.8
func (ctx *ErrorContext) CreateSpan() ErrorSpan
CreateSpan creates an ErrorSpan from the current context
func (*ErrorContext) CreateUndefinedVariableError ¶ added in v0.1.8
func (ctx *ErrorContext) CreateUndefinedVariableError(variableName string) *EnhancedError
CreateUndefinedVariableError creates an error for undefined variables
func (*ErrorContext) NewEnhancedArgumentError ¶ added in v0.1.8
func (ctx *ErrorContext) NewEnhancedArgumentError(functionName string, expected, actual int) *EnhancedError
NewEnhancedArgumentError creates an argument error with context
func (*ErrorContext) NewEnhancedIndexError ¶ added in v0.1.8
func (ctx *ErrorContext) NewEnhancedIndexError(index int, length int) *EnhancedError
NewEnhancedIndexError creates an index error with context
func (*ErrorContext) NewEnhancedRuntimeError ¶ added in v0.1.8
func (ctx *ErrorContext) NewEnhancedRuntimeError(message string) *EnhancedError
NewEnhancedRuntimeError creates a runtime error with context
func (*ErrorContext) NewEnhancedSyntaxError ¶ added in v0.1.8
func (ctx *ErrorContext) NewEnhancedSyntaxError(message string, token string) *EnhancedError
NewEnhancedSyntaxError creates a syntax error with context
func (*ErrorContext) NewEnhancedTypeError ¶ added in v0.1.8
func (ctx *ErrorContext) NewEnhancedTypeError(message string, expectedType, actualType string) *EnhancedError
NewEnhancedTypeError creates a type error with context
func (*ErrorContext) PopCallContext ¶ added in v0.1.8
func (ctx *ErrorContext) PopCallContext()
PopCallContext pops the current call context from the stack
func (*ErrorContext) PushCallContext ¶ added in v0.1.8
func (ctx *ErrorContext) PushCallContext(functionName string, position SourcePosition)
PushCallContext pushes a new call context onto the stack
func (*ErrorContext) SetFunction ¶ added in v0.1.8
func (ctx *ErrorContext) SetFunction(functionName string)
SetFunction updates the current function in the context
func (*ErrorContext) SetPosition ¶ added in v0.1.8
func (ctx *ErrorContext) SetPosition(line, column int)
SetPosition updates the current position in the context
func (*ErrorContext) UpgradeError ¶ added in v0.1.8
func (ctx *ErrorContext) UpgradeError(err Object) *EnhancedError
UpgradeError upgrades an existing error to enhanced error with context
type ErrorLabel ¶ added in v0.1.8
type ErrorLabel struct { Span ErrorSpan Message string Level ErrorLevel }
ErrorLabel represents a label pointing to a specific part of code
type ErrorLevel ¶ added in v0.1.8
type ErrorLevel int
ErrorLevel defines the severity of an error
const ( ERROR_LEVEL_ERROR ErrorLevel = iota ERROR_LEVEL_WARNING ERROR_LEVEL_NOTE ERROR_LEVEL_HELP )
func (ErrorLevel) String ¶ added in v0.1.8
func (el ErrorLevel) String() string
type ErrorNote ¶ added in v0.1.8
type ErrorNote struct { Message string Level ErrorLevel Span *ErrorSpan // Optional span for the note }
ErrorNote represents additional information about an error
type ErrorSpan ¶ added in v0.1.8
type ErrorSpan struct { Start SourcePosition End SourcePosition Source string // The actual source code that caused the error }
ErrorSpan represents a span of code in the source
type ErrorSuggestion ¶ added in v0.1.8
ErrorSuggestion represents a suggestion for fixing the error
func GetSuggestionForError ¶ added in v0.1.8
func GetSuggestionForError(errorMessage string) *ErrorSuggestion
Helper function to get suggestions based on error patterns
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 ReturnType ast.Expression Body *ast.BlockStatement Env *Environment IsAbstract bool IsPrivate bool IsProtected bool }
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type Goroutine ¶ added in v0.1.8
type Goroutine struct { Name string Done chan bool Result Object Error Object IsRunning bool // contains filtered or unexported fields }
Goroutine represents a running goroutine in Carrion
func (*Goroutine) Cleanup ¶ added in v0.1.8
func (g *Goroutine) Cleanup()
Cleanup closes channels and releases resources when a goroutine finishes
func (*Goroutine) IsCompleted ¶ added in v0.1.8
IsCompleted checks if the goroutine has finished execution
func (*Goroutine) Type ¶ added in v0.1.8
func (g *Goroutine) Type() ObjectType
type GoroutineManager ¶ added in v0.1.8
type GoroutineManager struct { Goroutines map[string]*Goroutine Anonymous []*Goroutine MaxNamedSize int // Maximum number of named goroutines (0 = unlimited) MaxAnonymousSize int // Maximum number of anonymous goroutines (0 = unlimited) AutoCleanup bool // Whether to automatically clean up completed goroutines // contains filtered or unexported fields }
GoroutineManager manages all active goroutines
func NewGoroutineManager ¶ added in v0.1.8
func NewGoroutineManager() *GoroutineManager
func NewGoroutineManagerWithLimits ¶ added in v0.1.8
func NewGoroutineManagerWithLimits(maxNamed, maxAnonymous int, autoCleanup bool) *GoroutineManager
NewGoroutineManagerWithLimits creates a new GoroutineManager with specified limits
func (*GoroutineManager) AddAnonymousGoroutine ¶ added in v0.1.8
func (gm *GoroutineManager) AddAnonymousGoroutine(goroutine *Goroutine) error
AddAnonymousGoroutine adds an anonymous goroutine to the manager
func (*GoroutineManager) AddNamedGoroutine ¶ added in v0.1.8
func (gm *GoroutineManager) AddNamedGoroutine(name string, goroutine *Goroutine) error
AddNamedGoroutine adds a named goroutine to the manager
func (*GoroutineManager) CleanupCompletedGoroutines ¶ added in v0.1.8
func (gm *GoroutineManager) CleanupCompletedGoroutines()
CleanupCompletedGoroutines removes and cleans up all completed goroutines
func (*GoroutineManager) ClearAll ¶ added in v0.1.8
func (gm *GoroutineManager) ClearAll()
ClearAll removes all goroutines from the manager
func (*GoroutineManager) GetAllAnonymousGoroutines ¶ added in v0.1.8
func (gm *GoroutineManager) GetAllAnonymousGoroutines() []*Goroutine
GetAllAnonymousGoroutines returns a copy of all anonymous goroutines
func (*GoroutineManager) GetAllNamedGoroutines ¶ added in v0.1.8
func (gm *GoroutineManager) GetAllNamedGoroutines() map[string]*Goroutine
GetAllNamedGoroutines returns a copy of all named goroutines
func (*GoroutineManager) GetCapacityInfo ¶ added in v0.1.8
func (gm *GoroutineManager) GetCapacityInfo() (namedCount, namedMax, anonymousCount, anonymousMax int)
GetCapacityInfo returns current usage and capacity information
func (*GoroutineManager) GetCompletedCount ¶ added in v0.1.8
func (gm *GoroutineManager) GetCompletedCount() (namedCompleted, anonymousCompleted int)
GetCompletedCount returns the number of completed goroutines
func (*GoroutineManager) GetLimits ¶ added in v0.1.8
func (gm *GoroutineManager) GetLimits() (maxNamed, maxAnonymous int, autoCleanup bool)
GetLimits returns the current size limits and auto-cleanup setting
func (*GoroutineManager) GetNamedGoroutine ¶ added in v0.1.8
func (gm *GoroutineManager) GetNamedGoroutine(name string) (*Goroutine, bool)
GetNamedGoroutine retrieves a named goroutine from the manager
func (*GoroutineManager) Inspect ¶ added in v0.1.8
func (gm *GoroutineManager) Inspect() string
func (*GoroutineManager) IsAtCapacity ¶ added in v0.1.8
func (gm *GoroutineManager) IsAtCapacity() (namedAtCapacity, anonymousAtCapacity bool)
IsAtCapacity checks if either collection is at its maximum capacity
func (*GoroutineManager) RemoveAndCleanupNamed ¶ added in v0.1.8
func (gm *GoroutineManager) RemoveAndCleanupNamed(name string)
RemoveAndCleanupNamed removes a named goroutine and performs cleanup
func (*GoroutineManager) RemoveNamedGoroutine ¶ added in v0.1.8
func (gm *GoroutineManager) RemoveNamedGoroutine(name string)
RemoveNamedGoroutine removes a named goroutine from the manager
func (*GoroutineManager) Reset ¶ added in v0.1.8
func (gm *GoroutineManager) Reset()
Reset completely resets the manager to a fresh state
func (*GoroutineManager) SetAutoCleanup ¶ added in v0.1.8
func (gm *GoroutineManager) SetAutoCleanup(enabled bool)
SetAutoCleanup enables or disables automatic cleanup of completed goroutines
func (*GoroutineManager) SetMaxLimits ¶ added in v0.1.8
func (gm *GoroutineManager) SetMaxLimits(maxNamed, maxAnonymous int)
SetMaxLimits updates the maximum size limits for both collections
func (*GoroutineManager) Type ¶ added in v0.1.8
func (gm *GoroutineManager) 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
type StaticMethod ¶ added in v0.1.8
func (*StaticMethod) Inspect ¶ added in v0.1.8
func (sm *StaticMethod) Inspect() string
func (*StaticMethod) Type ¶ added in v0.1.8
func (sm *StaticMethod) Type() ObjectType
type String ¶
type String struct {
Value string
}
func (*String) Type ¶
func (s *String) Type() ObjectType
type Super ¶ added in v0.1.8
type Super struct { Instance *Instance // The instance calling super Parent *Grimoire // The parent grimoire to call methods on }
Super represents a reference to the parent class for method calls Used for super.method() calls in inheritance hierarchies
func (*Super) Type ¶ added in v0.1.8
func (s *Super) Type() ObjectType