evaluator

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

src/evaluator/enhanced_error_integration.go

Index

Constants

This section is empty.

Variables

View Source
var (
	NONE  = &object.None{Value: "None"}
	TRUE  = &object.Boolean{Value: true}
	FALSE = &object.Boolean{Value: false}

	MAX_CALL_DEPTH              = 1000
	CurrentContext *CallContext = nil
)
View Source
var LineReader *liner.State

Functions

func CleanupCallStack added in v0.1.6

func CleanupCallStack(fn *object.Function)

CleanupCallStack removes entries from call stack for specific function

func CleanupGlobalState added in v0.1.6

func CleanupGlobalState()

CleanupGlobalState clears all global state maps to prevent memory leaks

func CleanupGoroutineManager added in v0.1.8

func CleanupGoroutineManager()

CleanupGoroutineManager waits for goroutines to finish and resets the manager

func CleanupRecursionDepth added in v0.1.6

func CleanupRecursionDepth(node *ast.BlockStatement)

CleanupRecursionDepth removes recursion tracking for specific AST node

func CollectEnhancedErrors added in v0.1.8

func CollectEnhancedErrors(objects []object.Object) []*object.EnhancedError

CollectEnhancedErrors collects all enhanced errors from a slice of objects

func CreateArgumentCountError added in v0.1.8

func CreateArgumentCountError(functionName string, expected, actual int, sourceCode string, filename string, line, column int) *object.EnhancedError

CreateArgumentCountError creates an argument count error

func CreateIndexOutOfBoundsError added in v0.1.8

func CreateIndexOutOfBoundsError(index, length int, sourceCode string, filename string, line, column int) *object.EnhancedError

CreateIndexOutOfBoundsError creates an index out of bounds error

func CreateTypeMismatchError added in v0.1.8

func CreateTypeMismatchError(operation string, leftType, rightType object.ObjectType, sourceCode string, filename string, line, column int) *object.EnhancedError

CreateTypeMismatchError creates a type mismatch error

func CreateUndefinedIdentifierError added in v0.1.8

func CreateUndefinedIdentifierError(identifier string, sourceCode string, filename string, line, column int) *object.EnhancedError

CreateUndefinedIdentifierError creates an error for undefined identifiers

func DisableEnhancedErrors added in v0.1.8

func DisableEnhancedErrors(evaluator *EnhancedEvaluator)

DisableEnhancedErrors disables enhanced error handling (fallback to basic errors)

func EnableVerboseErrors added in v0.1.8

func EnableVerboseErrors(evaluator *EnhancedEvaluator)

EnableVerboseErrors enables verbose error output

func EnhancedNewError added in v0.1.8

func EnhancedNewError(message string, sourceCode string, filename string, line, column int) *object.EnhancedError

EnhancedNewError creates an enhanced error with suggestions

func EnhancedNewErrorf added in v0.1.8

func EnhancedNewErrorf(sourceCode string, filename string, line, column int, format string, args ...interface{}) *object.EnhancedError

EnhancedNewErrorf creates an enhanced error with formatted message

func Eval

func Eval(node ast.Node, env *object.Environment, ctx *CallContext) object.Object

Main evaluation function

func EvalWithDebug added in v0.1.6

func EvalWithDebug(node ast.Node, env *object.Environment, ctx *CallContext, debugConfig *debug.Config) object.Object

EvalWithDebug evaluates an AST node with debug output

func ExampleEnhancedErrorUsage added in v0.1.8

func ExampleEnhancedErrorUsage()

ExampleEnhancedErrorUsage demonstrates how to use enhanced errors

func GetBuiltins added in v0.1.8

func GetBuiltins() map[string]*object.Builtin

GetBuiltins returns a copy of the built-ins map for external access

func HasEnhancedErrors added in v0.1.8

func HasEnhancedErrors(objects []object.Object) bool

HasEnhancedErrors checks if a slice of objects contains enhanced errors

func LoadModules added in v0.1.7

func LoadModules(env *object.Environment)

func LoadMuninStdlib

func LoadMuninStdlib(env *object.Environment) error

func MergeEnhancedErrors added in v0.1.8

func MergeEnhancedErrors(errors []*object.EnhancedError) *object.EnhancedError

MergeEnhancedErrors merges multiple enhanced errors into a single error

func MigrateToEnhancedError added in v0.1.8

func MigrateToEnhancedError(obj object.Object, sourceCode, filename string, line, column int) object.Object

MigrateToEnhancedError migrates existing error handling code to use enhanced errors

func PrintEnhancedError added in v0.1.8

func PrintEnhancedError(err *object.EnhancedError)

PrintEnhancedError prints an enhanced error with full context

func PrintEnhancedErrorSimple added in v0.1.8

func PrintEnhancedErrorSimple(err *object.EnhancedError)

PrintEnhancedErrorSimple prints an enhanced error with minimal context

func SetStdlibEnv added in v0.1.7

func SetStdlibEnv(env *object.Environment)

SetStdlibEnv sets the global reference to the standard library environment

func SetupEnhancedErrorHandling added in v0.1.8

func SetupEnhancedErrorHandling(evaluator *EnhancedEvaluator, config *object.ErrorConfig)

SetupEnhancedErrorHandling configures enhanced error handling for the evaluator

func UpgradeExistingError added in v0.1.8

func UpgradeExistingError(err object.Object, sourceCode string, filename string, line, column int) *object.EnhancedError

UpgradeExistingError upgrades an existing error to enhanced error

Types

type CallContext added in v0.1.6

type CallContext struct {
	FunctionName string
	Node         ast.Node
	Parent       *CallContext

	IsDirectExecution bool             // True when file is run directly, false when imported
	MethodGrimoire    *object.Grimoire // The grimoire that owns the current method
	// contains filtered or unexported fields
}

CallContext tracks function call state for better error reporting

type EnhancedEvaluator added in v0.1.8

type EnhancedEvaluator struct {
	Context *object.ErrorContext
}

EnhancedEvaluator wraps the standard evaluator with enhanced error handling

func NewEnhancedEvaluator added in v0.1.8

func NewEnhancedEvaluator(filename, sourceCode string) *EnhancedEvaluator

NewEnhancedEvaluator creates a new enhanced evaluator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL