core

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package core provides the fundamental types and interfaces for the M28 language.

Package core provides the fundamental types and interfaces for the M28 language.

Index

Constants

View Source
const (
	ErrDotMissingArgs      = "Dot notation requires both an object and a property/method name"
	ErrDotObjectEval       = "Failed to evaluate object for dot notation: %v"
	ErrDotPropertyEval     = "Failed to evaluate property name for dot notation: %v"
	ErrDotNoInterface      = "Type %T doesn't support dot notation (doesn't implement ObjProtocol interface)"
	ErrDotPropertyNotFound = "Object has no property '%s'"
	ErrDotModuleNoProperty = "Module '%s' has no property '%s'"
	ErrDotPropertyType     = "Property name must be a string or symbol, got %T"
	ErrDotMethodNotFound   = "Object has no method '%s'"
	ErrDotMethodCallError  = "Error calling method '%s': %v"
	ErrDotNotCallable      = "Property '%s' is not callable (type: %T)"
	ErrDotNestedAccess     = "Error accessing property %s.%s: %v"
	ErrDotEvaluatorMissing = "No evaluator available for applying lambda method '%s'"
	ErrTooManyArguments    = "Method '%s' takes %d arguments, got %d"
)

Error message templates for dot notation

View Source
const (
	MaxSafeInt float64 = 9007199254740992  // 2^53
	MinSafeInt float64 = -9007199254740992 // -2^53
)

Promotion constants for NumberValue -> BigIntValue conversion

Variables

View Source
var (
	True  = BoolValue(true)
	False = BoolValue(false)
)

Pre-defined boolean constants

View Source
var (
	Nil  = NilValue{}
	None = NilValue{} // Python-style alias
)

Predefined nil value

View Source
var BuiltinLogging = false

BuiltinLogging controls whether to log duplicate builtin registrations

View Source
var DocRegistryInstance = NewDocRegistry()

DocRegistryInstance is the global instance of the documentation registry

View Source
var Ellipsis = EllipsisValue{}

Predefined Ellipsis value

View Source
var EmptyList = NewList()

EmptyList is a shared empty list value

View Source
var (
	EmptyTuple = TupleValue{}
)

Predefined empty collections

View Source
var EvalHook func(Value, *Context) (Value, error)

EvalHook is a function that can be set by the eval package to provide eval() functionality This avoids circular dependencies between core and eval packages

View Source
var GeneratorExecFactory func(function Value, args []Value, ctx *Context) (GeneratorExecutor, error)

GeneratorExecFactory creates a GeneratorExecutor for a given function and arguments This is set by the eval package to avoid circular dependency

View Source
var GetOperatorFunc func(string) (Value, bool)

GetOperatorFunc is a hook to the operator registry's GetOperator function This avoids circular imports while allowing fast operator lookup

View Source
var NotImplemented = &NotImplementedValue{}

Predefined NotImplemented value This is a singleton - all references should be to the same instance for identity checks

Functions

func Compare

func Compare(a, b Value) int

Compare compares two values and returns: -1 if a < b 0 if a == b 1 if a > b

func DebugLog added in v0.3.0

func DebugLog(format string, args ...interface{})

DebugLog prints debug messages only if module debug is enabled

func EqualValues

func EqualValues(a, b Value) bool

EqualValues compares two values for equality

func ErrDotMethodCallf

func ErrDotMethodCallf(methodName string, err error) error

func ErrDotMissingInterfacef

func ErrDotMissingInterfacef(objType interface{}) error

func ErrDotModulePropertyf

func ErrDotModulePropertyf(moduleName, propName string) error

func ErrDotNestedAccessf

func ErrDotNestedAccessf(path, prop string, err error) error

func ErrDotNoMethodf

func ErrDotNoMethodf(name string) error

func ErrDotNoPropertyf

func ErrDotNoPropertyf(name string) error

Helper functions to generate error instances

func ErrDotNotCallablef

func ErrDotNotCallablef(propName string, propType interface{}) error

func ErrTooManyArgumentsf

func ErrTooManyArgumentsf(methodName string, expected, got int) error

func FindModule

func FindModule(name string) (string, error)

FindModule searches for a module file in the module paths

func FormatDocEntry

func FormatDocEntry(entry DocEntry) string

FormatDocEntry formats a DocEntry for display in the REPL

func FormatDocList

func FormatDocList(entries []DocEntry, title string) string

FormatDocList formats a list of DocEntries as a table

func GetBuiltinRegistrationInfo added in v0.2.0

func GetBuiltinRegistrationInfo() map[string]interface{}

GetBuiltinRegistrationInfo returns information about builtin registrations

func GetDuplicateBuiltinDetails added in v0.2.0

func GetDuplicateBuiltinDetails() map[string][]string

GetDuplicateBuiltinDetails returns detailed information about duplicate builtin registrations

func GetDuplicateBuiltins added in v0.2.0

func GetDuplicateBuiltins() []string

GetDuplicateBuiltins returns a list of builtin names that were attempted to be registered multiple times

func GetModulePaths

func GetModulePaths() []string

GetModulePaths returns the current module search paths

func GetSyntaxKindForValue added in v0.3.0

func GetSyntaxKindForValue(ctx *Context, val Value) int

GetSyntaxKindForValue is a helper to extract syntax kind for a value from context metadata Returns 0 (SyntaxLisp) if context, metadata, or syntax kind is not available

func InitDictMethods

func InitDictMethods()

InitDictMethods adds additional methods to the dict type descriptor

func InitListMethods

func InitListMethods()

InitListMethods adds additional methods to the list type descriptor

func InitSetMethods

func InitSetMethods()

InitSetMethods adds additional methods to the set type descriptor

func InitStringMethods

func InitStringMethods()

InitStringMethods adds additional string methods to the string type descriptor

func InitTraceConfig added in v0.3.0

func InitTraceConfig()

InitTraceConfig initializes tracing from environment variables

func InitializeTypeRegistryRefactored added in v0.3.0

func InitializeTypeRegistryRefactored()

InitializeTypeRegistryRefactored sets up type descriptors for all built-in types This is the refactored version that splits the god function into smaller pieces

func IsClass

func IsClass(v Value) bool

Helper function to check if a value is a class

func IsHashable

func IsHashable(v Value) bool

IsHashable determines if a value can be used as a dictionary key

func IsInSafeRange added in v0.3.0

func IsInSafeRange(f float64) bool

IsInSafeRange checks if an integer value fits precisely in float64

func IsInstance

func IsInstance(v Value) bool

Helper function to check if a value is an instance

func IsInstanceOf

func IsInstanceOf(instance *Instance, class *Class) bool

Helper function to check instance of class

func IsInteger added in v0.3.0

func IsInteger(f float64) bool

IsInteger checks if a float64 represents an integer value

func IsTruthy

func IsTruthy(v Value) bool

IsTruthy determines if a value is truthy

func ListModules

func ListModules() []string

ListModules is a convenience function for accessing the global registry

func ListTypes

func ListTypes() []string

ListTypes is a convenience function for accessing the global registry

func ParseFloat added in v0.3.0

func ParseFloat(s string) (float64, bool)

ParseFloat attempts to parse a string as a float

func ParseInt added in v0.3.0

func ParseInt(s string) (int64, bool)

ParseInt attempts to parse a string as an integer

func PrintErrorValue

func PrintErrorValue(err error) string

PrintValue for error values

func PrintValue

func PrintValue(val Value) string

PrintValue returns a string representation of a value

func PrintValueWithoutQuotes

func PrintValueWithoutQuotes(val Value) string

PrintValueWithoutQuotes returns a string representation without quotes for strings

func ProcessEscapeSequences

func ProcessEscapeSequences(s string) string

ProcessEscapeSequences processes escape sequences in a string

func RegisterDoc

func RegisterDoc(entry DocEntry)

RegisterDoc registers documentation for a symbol

func RegisterDocStrings

func RegisterDocStrings(docs map[string]string)

RegisterDocStrings registers a map of symbol names to documentation strings

func RegisterType

func RegisterType(desc *TypeDescriptor)

RegisterType registers a type descriptor with duplicate detection

func Repr added in v0.2.0

func Repr(val Value) string

Repr returns the developer-friendly representation of a value This checks for __repr__ methods on objects and falls back to default representations

func SetModuleLoader

func SetModuleLoader(loader ModuleLoader)

SetModuleLoader sets the global module loader

func SetModulePaths

func SetModulePaths(paths []string)

SetModulePaths sets the module search paths

func SetPythonLoader added in v0.3.0

func SetPythonLoader(loader func(string, *Context, func(Value, *Context) (Value, error), *DictValue) (*DictValue, error))

SetPythonLoader sets the Python module loader function

func SetupSlots added in v0.3.0

func SetupSlots(class *Class, slotsValue Value) error

SetupSlots sets up slot descriptors for a class based on its __slots__ attribute Handles slot inheritance from parent classes

func ShouldPromoteToBigInt added in v0.3.0

func ShouldPromoteToBigInt(f float64) bool

ShouldPromoteToBigInt determines if a NumberValue should be promoted to BigIntValue

func Sleep

func Sleep(seconds float64)

Sleep pauses execution for the specified duration

func TraceEnterFunction added in v0.3.0

func TraceEnterFunction(funcName string, args []Value)

TraceEnterFunction logs function entry

func TraceExitFunction added in v0.3.0

func TraceExitFunction(funcName string, result Value, err error)

TraceExitFunction logs function exit

func TraceValue added in v0.3.0

func TraceValue(label string, value Value)

TraceValue logs an arbitrary value with a label

func TraceVariable added in v0.3.0

func TraceVariable(varName string, value Value, location string)

TraceVariable logs a variable assignment

func TypedReceiver added in v0.3.0

func TypedReceiver[T Value](receiver Value, methodName string) (T, error)

TypedReceiver extracts and type-asserts the receiver

func ValidateArity added in v0.3.0

func ValidateArity(name string, args []Value, expected int) error

ValidateArity checks argument count and returns an error if invalid

func ValidateArityRange added in v0.3.0

func ValidateArityRange(name string, args []Value, min, max int) error

ValidateArityRange checks argument count is within range

func ValueToKey

func ValueToKey(v Value) string

ValueToKey converts a value to a string key for use in sets and dicts

Types

type AsyncFunction

type AsyncFunction struct {
	BaseObject
	Function Value
	Name     string
}

AsyncFunction wraps a function to run asynchronously

func NewAsyncFunction

func NewAsyncFunction(function Value, name string) *AsyncFunction

NewAsyncFunction creates a new async function

func (*AsyncFunction) Call

func (af *AsyncFunction) Call(args []Value, ctx *Context) (Value, error)

Call creates a coroutine object (does NOT execute the function) This matches Python behavior where calling an async function returns a coroutine

func (*AsyncFunction) String

func (af *AsyncFunction) String() string

String returns the string representation

func (*AsyncFunction) Type

func (af *AsyncFunction) Type() Type

Type returns the function type

type AttributeError added in v0.3.0

type AttributeError struct {
	ObjType  string
	AttrName string
	Message  string
	Location *SourceLocation
}

AttributeError represents an attribute access error

func (*AttributeError) Error added in v0.3.0

func (e *AttributeError) Error() string

type AttributeProvider added in v0.3.0

type AttributeProvider interface {
	Value
	GetRegistry() *MethodRegistry
	GetBaseObject() *BaseObject
}

AttributeProvider is an interface for types that provide attributes

type BaseContextManager added in v0.3.0

type BaseContextManager struct {
	BaseObject
	// contains filtered or unexported fields
}

BaseContextManager provides common functionality for context managers

func NewBaseContextManager added in v0.3.0

func NewBaseContextManager(typeName Type) *BaseContextManager

NewBaseContextManager creates a new base context manager

func (*BaseContextManager) GetAttr added in v0.3.0

func (cm *BaseContextManager) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*BaseContextManager) GetBaseObject added in v0.3.0

func (cm *BaseContextManager) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*BaseContextManager) GetRegistry added in v0.3.0

func (cm *BaseContextManager) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

type BaseObject

type BaseObject struct {
	// contains filtered or unexported fields
}

BaseObject provides a standard implementation of Object

func NewBaseObject

func NewBaseObject(typ Type) *BaseObject

NewBaseObject creates a new base object

func (*BaseObject) CallMethod

func (o *BaseObject) CallMethod(name string, args []Value, ctx *Context) (Value, error)

CallMethod implements Object.CallMethod

func (*BaseObject) GetAttr

func (o *BaseObject) GetAttr(name string) (Value, bool)

GetAttr implements Object.GetAttr

func (*BaseObject) SetAttr

func (o *BaseObject) SetAttr(name string, value Value) error

SetAttr implements Object.SetAttr

func (*BaseObject) String

func (o *BaseObject) String() string

String implements Value.String

func (*BaseObject) Type

func (o *BaseObject) Type() Type

Type implements Value.Type

type BigIntValue added in v0.3.0

type BigIntValue struct {
	// contains filtered or unexported fields
}

BigIntValue represents an arbitrary precision integer (Python's int type) This is used when integers exceed float64's safe integer range (2^53)

func NewBigInt added in v0.3.0

func NewBigInt(i *big.Int) BigIntValue

NewBigInt creates a BigIntValue from a big.Int (makes a copy)

func NewBigIntFromInt64 added in v0.3.0

func NewBigIntFromInt64(i int64) BigIntValue

NewBigIntFromInt64 creates a BigIntValue from an int64

func NewBigIntFromString added in v0.3.0

func NewBigIntFromString(s string, base int) (BigIntValue, error)

NewBigIntFromString creates a BigIntValue from a string in the given base

func PromoteToBigInt added in v0.3.0

func PromoteToBigInt(n NumberValue) BigIntValue

PromoteToBigInt converts a NumberValue to BigIntValue For large floats, uses string conversion to preserve precision

func (BigIntValue) FitsInFloat64 added in v0.3.0

func (b BigIntValue) FitsInFloat64() bool

FitsInFloat64 checks if the value can be safely represented as float64 without precision loss (i.e., fits in range -2^53 to 2^53)

func (BigIntValue) GetAttr added in v0.3.0

func (b BigIntValue) GetAttr(name string) (Value, bool)

GetAttr implements basic int methods using TypeDescriptor

func (BigIntValue) GetBigInt added in v0.3.0

func (b BigIntValue) GetBigInt() *big.Int

GetBigInt returns the underlying big.Int (for operators)

func (BigIntValue) Sign added in v0.3.0

func (b BigIntValue) Sign() int

Sign returns -1, 0, or 1 depending on whether the value is negative, zero, or positive

func (BigIntValue) String added in v0.3.0

func (b BigIntValue) String() string

String implements Value.String - returns the decimal representation

func (BigIntValue) ToFloat64 added in v0.3.0

func (b BigIntValue) ToFloat64() float64

ToFloat64 converts to float64 (may lose precision for large values)

func (BigIntValue) ToInt64 added in v0.3.0

func (b BigIntValue) ToInt64() (int64, bool)

ToInt64 converts to int64 if it fits, otherwise returns error

func (BigIntValue) Type added in v0.3.0

func (b BigIntValue) Type() Type

Type implements Value.Type

type BoolValue

type BoolValue bool

BoolValue represents a boolean value

func (BoolValue) GetAttr added in v0.3.0

func (b BoolValue) GetAttr(name string) (Value, bool)

GetAttr implements basic bool methods using TypeDescriptor

func (BoolValue) String

func (b BoolValue) String() string

String implements Value.String

func (BoolValue) Type

func (b BoolValue) Type() Type

Type implements Value.Type

type BoundClassMethod added in v0.3.0

type BoundClassMethod struct {
	Class    Value
	Function Value
}

BoundClassMethod represents a class method bound to a specific class

func (*BoundClassMethod) Call added in v0.3.0

func (b *BoundClassMethod) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable.Call Automatically injects the class as the first argument

func (*BoundClassMethod) CallWithKeywords added in v0.3.0

func (b *BoundClassMethod) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements keyword argument support for classmethods Automatically injects the class as the first argument

func (*BoundClassMethod) String added in v0.3.0

func (b *BoundClassMethod) String() string

String implements Value.String

func (*BoundClassMethod) Type added in v0.3.0

func (b *BoundClassMethod) Type() Type

Type implements Value.Type

type BoundInstanceMethod

type BoundInstanceMethod struct {
	Instance *Instance
	Method   interface {
		Call([]Value, *Context) (Value, error)
	}
	DefiningClass *Class // The class where this method was defined
}

BoundInstanceMethod represents a method bound to an instance

func (*BoundInstanceMethod) Call

func (bm *BoundInstanceMethod) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable interface

func (*BoundInstanceMethod) CallWithKeywords added in v0.3.0

func (bm *BoundInstanceMethod) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements keyword argument support for bound instance methods

func (*BoundInstanceMethod) GetAttr added in v0.3.0

func (bm *BoundInstanceMethod) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for bound instance methods Provides default values for standard function attributes

func (*BoundInstanceMethod) String

func (bm *BoundInstanceMethod) String() string

String returns the string representation

func (*BoundInstanceMethod) Type

func (bm *BoundInstanceMethod) Type() Type

Type returns the bound method type

type BoundListMethod added in v0.3.0

type BoundListMethod struct {
	ListInstance *ListInstance
	Method       interface {
		Call([]Value, *Context) (Value, error)
	}
	DefiningClass *Class
}

BoundListMethod represents a method bound to a ListInstance

func (*BoundListMethod) Call added in v0.3.0

func (b *BoundListMethod) Call(args []Value, ctx *Context) (Value, error)

Call calls the method with the ListInstance as the first argument

func (*BoundListMethod) String added in v0.3.0

func (b *BoundListMethod) String() string

String returns string representation

func (*BoundListMethod) Type added in v0.3.0

func (b *BoundListMethod) Type() Type

Type returns the type

type BoundMethod

type BoundMethod struct {
	Receiver Value
	Method   *MethodDescriptor
	TypeDesc *TypeDescriptor
}

BoundMethod represents a method bound to an instance

func (*BoundMethod) Call

func (bm *BoundMethod) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable

func (*BoundMethod) CallWithKeywords added in v0.3.0

func (bm *BoundMethod) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements keyword argument support for bound methods

func (*BoundMethod) GetAttr added in v0.3.0

func (bm *BoundMethod) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for bound methods Provides default values for standard function attributes

func (*BoundMethod) String

func (bm *BoundMethod) String() string

String implements Value.String

func (*BoundMethod) Type

func (bm *BoundMethod) Type() Type

Type implements Value.Type

type BoundSuperMethod added in v0.3.0

type BoundSuperMethod struct {
	BaseObject
	Method Value  // The underlying method
	Class  *Class // The class to set as __class__
}

BoundSuperMethod wraps a method from a Super object to inject __class__ when called

func (*BoundSuperMethod) Call added in v0.3.0

func (bsm *BoundSuperMethod) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable interface for BoundSuperMethod

func (*BoundSuperMethod) CallWithKeywords added in v0.3.0

func (bsm *BoundSuperMethod) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements CallWithKeywords interface for BoundSuperMethod

func (*BoundSuperMethod) String added in v0.3.0

func (bsm *BoundSuperMethod) String() string

String returns the string representation

func (*BoundSuperMethod) Type added in v0.3.0

func (bsm *BoundSuperMethod) Type() Type

Type returns the bound super method type

type BuiltinFunction

type BuiltinFunction struct {
	BaseObject
	// contains filtered or unexported fields
}

BuiltinFunction represents a Go function that can be called from M28

func NewBuiltinFunction

func NewBuiltinFunction(fn func(args []Value, ctx *Context) (Value, error)) *BuiltinFunction

NewBuiltinFunction creates a new builtin function

func NewNamedBuiltinFunction

func NewNamedBuiltinFunction(name string, fn func(args []Value, ctx *Context) (Value, error)) *BuiltinFunction

NewNamedBuiltinFunction creates a new builtin function with a name

func (*BuiltinFunction) Call

func (f *BuiltinFunction) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable.Call

func (*BuiltinFunction) CallWithKeywords added in v0.3.0

func (f *BuiltinFunction) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements keyword argument support for BuiltinFunction For Python compatibility, builtin functions ignore unknown keyword arguments by default. Functions that need to handle kwargs should use BuiltinFunctionWithKwargs.

func (*BuiltinFunction) GetAttr

func (f *BuiltinFunction) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*BuiltinFunction) GetBaseObject added in v0.3.0

func (f *BuiltinFunction) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*BuiltinFunction) GetRegistry added in v0.3.0

func (f *BuiltinFunction) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*BuiltinFunction) SetAttr added in v0.3.0

func (f *BuiltinFunction) SetAttr(name string, value Value) error

SetAttr implements attribute setting for builtin functions

func (*BuiltinFunction) String

func (f *BuiltinFunction) String() string

String implements Value.String

type BuiltinFunctionWithKwargs added in v0.3.0

type BuiltinFunctionWithKwargs struct {
	BaseObject
	Name string
	Fn   func(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
}

BuiltinFunctionWithKwargs represents a builtin function that supports keyword arguments

func (*BuiltinFunctionWithKwargs) Call added in v0.3.0

func (f *BuiltinFunctionWithKwargs) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable.Call

func (*BuiltinFunctionWithKwargs) CallWithKeywords added in v0.3.0

func (f *BuiltinFunctionWithKwargs) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements keyword argument support

func (*BuiltinFunctionWithKwargs) GetAttr added in v0.3.0

func (f *BuiltinFunctionWithKwargs) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for BuiltinFunctionWithKwargs

func (*BuiltinFunctionWithKwargs) SetAttr added in v0.3.0

func (f *BuiltinFunctionWithKwargs) SetAttr(name string, value Value)

SetAttr implements attribute setting for BuiltinFunctionWithKwargs

func (*BuiltinFunctionWithKwargs) String added in v0.3.0

func (f *BuiltinFunctionWithKwargs) String() string

String implements Value.String

func (*BuiltinFunctionWithKwargs) Type added in v0.3.0

func (f *BuiltinFunctionWithKwargs) Type() Type

Type implements Value.Type

type BuiltinMethod

type BuiltinMethod struct {
	BaseObject
	// contains filtered or unexported fields
}

BuiltinMethod represents a method that's implemented in Go

func (*BuiltinMethod) Bind

func (m *BuiltinMethod) Bind(receiver Value) Value

Bind implements Method.Bind

func (*BuiltinMethod) Call

func (m *BuiltinMethod) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable.Call

func (*BuiltinMethod) String

func (m *BuiltinMethod) String() string

String implements Value.String

func (*BuiltinMethod) Type

func (m *BuiltinMethod) Type() Type

Type implements Value.Type

type ByteArrayValue added in v0.3.0

type ByteArrayValue struct {
	// contains filtered or unexported fields
}

ByteArrayValue represents a mutable sequence of bytes

func NewByteArray added in v0.3.0

func NewByteArray(data []byte) *ByteArrayValue

NewByteArray creates a new bytearray

func (*ByteArrayValue) GetAttr added in v0.3.0

func (b *ByteArrayValue) GetAttr(name string) (Value, bool)

GetAttr implements basic bytearray methods using TypeDescriptor

func (*ByteArrayValue) GetData added in v0.3.0

func (b *ByteArrayValue) GetData() []byte

GetData returns the internal byte data

func (*ByteArrayValue) GetItem added in v0.3.0

func (b *ByteArrayValue) GetItem(index int) (Value, error)

GetItem gets a byte by index

func (*ByteArrayValue) Iterator added in v0.3.0

func (b *ByteArrayValue) Iterator() Iterator

Iterator implements Iterable

func (*ByteArrayValue) IteratorValue added in v0.3.0

func (b *ByteArrayValue) IteratorValue() Value

IteratorValue returns the iterator as a Value

func (*ByteArrayValue) SetItem added in v0.3.0

func (b *ByteArrayValue) SetItem(index int, value Value) error

SetItem sets a byte by index

func (*ByteArrayValue) String added in v0.3.0

func (b *ByteArrayValue) String() string

String implements Value.String

func (*ByteArrayValue) Type added in v0.3.0

func (b *ByteArrayValue) Type() Type

Type implements Value.Type

type BytesValue added in v0.3.0

type BytesValue []byte

BytesValue represents an immutable sequence of bytes

func (BytesValue) GetAttr added in v0.3.0

func (b BytesValue) GetAttr(name string) (Value, bool)

GetAttr implements basic bytes methods using TypeDescriptor

func (BytesValue) GetItem added in v0.3.0

func (b BytesValue) GetItem(index int) (Value, error)

GetItem gets a byte by index

func (BytesValue) Iterator added in v0.3.0

func (b BytesValue) Iterator() Iterator

Iterator implements Iterable

func (BytesValue) String added in v0.3.0

func (b BytesValue) String() string

String implements Value.String

func (BytesValue) Type added in v0.3.0

func (b BytesValue) Type() Type

Type implements Value.Type

type Callable

type Callable interface {
	Value

	// Call invokes the callable with arguments in a context
	Call(args []Value, ctx *Context) (Value, error)
}

Callable represents any value that can be called as a function

type Channel

type Channel struct {
	BaseObject
	// contains filtered or unexported fields
}

Channel represents a Go channel with Pythonic interface

func NewChannel

func NewChannel(capacity int) *Channel

NewChannel creates a new channel

func (*Channel) Close

func (c *Channel) Close() error

Close closes the channel

func (*Channel) GetAttr

func (c *Channel) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*Channel) GetBaseObject added in v0.3.0

func (c *Channel) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*Channel) GetChan

func (c *Channel) GetChan() chan Value

GetChan returns the internal Go channel

func (*Channel) GetRegistry added in v0.3.0

func (c *Channel) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*Channel) Receive

func (c *Channel) Receive() (Value, error)

Receive receives a value from the channel

func (*Channel) Send

func (c *Channel) Send(value Value) error

Send sends a value to the channel

func (*Channel) String

func (c *Channel) String() string

String returns the string representation

func (*Channel) TryReceive

func (c *Channel) TryReceive() (Value, bool)

TryReceive attempts to receive without blocking

func (*Channel) Type

func (c *Channel) Type() Type

Type returns the channel type

type Class

type Class struct {
	BaseObject
	Name        string            // Class name
	Module      string            // Module name (__module__ attribute)
	Doc         string            // Docstring (__doc__ attribute)
	Parent      *Class            // Parent class (for inheritance) - deprecated, use Parents
	Parents     []*Class          // Parent classes (for multiple inheritance)
	Methods     map[string]Value  // Class methods
	Attributes  map[string]Value  // Class attributes
	Constructor *MethodDescriptor // __init__ method
	SlotNames   []string          // __slots__ attribute (if defined)
}

Class represents a class definition

func NewClass

func NewClass(name string, parent *Class) *Class

NewClass creates a new class

func NewClassWithParents

func NewClassWithParents(name string, parents []*Class) *Class

NewClassWithParents creates a new class with multiple parents

func (*Class) Call

func (c *Class) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable interface for classes (instantiation)

func (*Class) CallWithKeywords added in v0.3.0

func (c *Class) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords implements keyword argument support for class instantiation This is the generic solution that unlocks full Python compatibility for all classes

func (*Class) GetAttr

func (c *Class) GetAttr(name string) (Value, bool)

GetAttr implements Object interface for classes

func (*Class) GetClassAttr

func (c *Class) GetClassAttr(name string) (Value, bool)

GetClassAttr gets a class attribute

func (*Class) GetMethod

func (c *Class) GetMethod(name string) (Value, bool)

GetMethod looks up a method in the class hierarchy

func (*Class) GetMethodWithClass added in v0.3.0

func (c *Class) GetMethodWithClass(name string) (Value, *Class, bool)

GetMethodWithClass looks up a method and returns the class where it was defined

func (*Class) GetSlotIndex added in v0.3.0

func (c *Class) GetSlotIndex(name string) int

GetSlotIndex returns the index of a slot by name, or -1 if not found

func (*Class) HasSlots added in v0.3.0

func (c *Class) HasSlots() bool

HasSlots returns true if a class uses __slots__

func (*Class) SetAttr

func (c *Class) SetAttr(name string, value Value) error

SetAttr implements Object interface for classes

func (*Class) SetClassAttr

func (c *Class) SetClassAttr(name string, value Value)

SetClassAttr sets a class attribute

func (*Class) SetMethod

func (c *Class) SetMethod(name string, method Value)

SetMethod adds a method to the class

func (*Class) String

func (c *Class) String() string

String returns the string representation of the class

func (*Class) Type

func (c *Class) Type() Type

Type returns the class type

type ClassMethodValue added in v0.3.0

type ClassMethodValue struct {
	Function Value
}

ClassMethodValue represents a Python class method

func (*ClassMethodValue) GetAttr added in v0.3.0

func (c *ClassMethodValue) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for classmethods

func (*ClassMethodValue) String added in v0.3.0

func (c *ClassMethodValue) String() string

String implements Value.String

func (*ClassMethodValue) Type added in v0.3.0

func (c *ClassMethodValue) Type() Type

Type implements Value.Type

type CodeType added in v0.3.0

type CodeType struct {
	BaseObject
	Function Value // Reference to the function this code belongs to
}

CodeType represents a Python code object

func NewCodeObject added in v0.3.0

func NewCodeObject(fn Value) *CodeType

NewCodeObject creates a new code object for a function

func (*CodeType) String added in v0.3.0

func (c *CodeType) String() string

type ComplexValue added in v0.3.0

type ComplexValue complex128

ComplexValue represents a complex number value

func (ComplexValue) GetAttr added in v0.3.0

func (c ComplexValue) GetAttr(name string) (Value, bool)

GetAttr implements basic complex methods using TypeDescriptor

func (ComplexValue) String added in v0.3.0

func (c ComplexValue) String() string

String implements Value.String

func (ComplexValue) Type added in v0.3.0

func (c ComplexValue) Type() Type

Type implements Value.Type

type ConstructorFunc

type ConstructorFunc func(args []Value, ctx *Context) (Value, error)

ConstructorFunc creates a new instance of a type

type Context

type Context struct {
	// Variables in the current scope
	Vars map[string]Value

	// Parent scope
	Outer *Context

	// Global scope for module-level variables
	Global *Context

	// Call stack for debugging and error reporting
	CallStack []TraceEntry

	// Current function name for error reporting
	CurrentFunction string

	// Metadata table for tracking source locations, types, comments
	// This is shared across all contexts in a program
	Metadata *IRMetadata

	// Variables declared as global in this scope (Python global statement)
	GlobalVars map[string]bool

	// Variables declared as nonlocal in this scope (Python nonlocal statement)
	NonlocalVars map[string]bool

	// Optional module dict to sync definitions to (for circular import support)
	// When set, Define() will also update this dict in real-time
	ModuleDict *DictValue

	// Evaluation counter for debugging and progress tracking
	EvalCount uint64

	// Current exception info for sys.exc_info()
	// Set when entering an except handler, cleared when exiting
	ExcType  Value
	ExcValue Value
	ExcTb    Value
}

Context holds the execution context for evaluation

func NewContext

func NewContext(outer *Context) *Context

NewContext creates a new evaluation context

func (*Context) DeclareGlobal added in v0.3.0

func (c *Context) DeclareGlobal(name string)

DeclareGlobal marks a variable as global in the current scope This means all assignments to this variable will modify the global scope

func (*Context) DeclareNonlocal added in v0.3.0

func (c *Context) DeclareNonlocal(name string) error

DeclareNonlocal marks a variable as nonlocal in the current scope This means all assignments to this variable will modify the nearest enclosing scope

func (*Context) Define

func (c *Context) Define(name string, value Value)

Define defines a new variable in the current scope

func (*Context) DefineBuiltin added in v0.2.0

func (c *Context) DefineBuiltin(name string, value Value) error

DefineBuiltin defines a builtin function with duplicate tracking This should be used instead of Define when registering builtins

func (*Context) Delete added in v0.3.0

func (c *Context) Delete(name string) error

Delete removes a variable from the current scope Returns error if variable doesn't exist in current scope

func (*Context) FormatStackTrace

func (c *Context) FormatStackTrace() string

FormatStackTrace returns a formatted stack trace for error reporting

func (*Context) GetAllSymbols

func (c *Context) GetAllSymbols() []string

GetAllSymbols returns all defined symbols in this context and its parents

func (*Context) IsGlobal added in v0.3.0

func (c *Context) IsGlobal(name string) bool

IsGlobal checks if a variable is declared as global in this scope

func (*Context) IsNonlocal added in v0.3.0

func (c *Context) IsNonlocal(name string) bool

IsNonlocal checks if a variable is declared as nonlocal in this scope

func (*Context) Lookup

func (c *Context) Lookup(name string) (Value, error)

Lookup finds a variable in the current or outer scopes

func (*Context) PopStack

func (c *Context) PopStack()

PopStack removes the most recent entry from the call stack

func (*Context) PushStack

func (c *Context) PushStack(function, file string, line, column int)

PushStack adds a new entry to the call stack

func (*Context) Set

func (c *Context) Set(name string, value Value) error

Set updates an existing variable in the nearest scope where it's defined

func (*Context) WithMetadata added in v0.3.0

func (c *Context) WithMetadata(metadata *IRMetadata) *Context

WithMetadata creates a new context with a specific metadata table Useful for module imports or testing

type ContextManager

type ContextManager interface {
	Value
	Enter() (Value, error)
	Exit(excType, excValue, excTraceback Value) (bool, error)
}

ContextManager interface defines the protocol for context managers

func IsContextManager

func IsContextManager(v Value) (ContextManager, bool)

Helper to check if a value implements context manager protocol

type Coroutine added in v0.3.0

type Coroutine struct {
	BaseObject
	Function Value
	Args     []Value
	Name     string
	// contains filtered or unexported fields
}

Coroutine represents a Python coroutine object (unevaluated async function call)

func NewCoroutine added in v0.3.0

func NewCoroutine(function Value, args []Value, name string) *Coroutine

NewCoroutine creates a new coroutine

func (*Coroutine) Close added in v0.3.0

func (c *Coroutine) Close() error

Close closes the coroutine (prevents it from being executed)

func (*Coroutine) GetAttr added in v0.3.0

func (c *Coroutine) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*Coroutine) GetBaseObject added in v0.3.0

func (c *Coroutine) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*Coroutine) GetRegistry added in v0.3.0

func (c *Coroutine) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*Coroutine) String added in v0.3.0

func (c *Coroutine) String() string

String returns the string representation

func (*Coroutine) Type added in v0.3.0

func (c *Coroutine) Type() Type

Type returns the coroutine type

type DecimalValue added in v0.3.0

type DecimalValue struct {
	Value decimal.Decimal
}

DecimalValue represents a high-precision decimal number

func NewDecimal added in v0.3.0

func NewDecimal(d decimal.Decimal) *DecimalValue

NewDecimal creates a new decimal value

func NewDecimalFromFloat added in v0.3.0

func NewDecimalFromFloat(f float64) *DecimalValue

NewDecimalFromFloat creates a decimal from a float64

func NewDecimalFromInt added in v0.3.0

func NewDecimalFromInt(i int64) *DecimalValue

NewDecimalFromInt creates a decimal from an int64

func NewDecimalFromString added in v0.3.0

func NewDecimalFromString(s string) (*DecimalValue, error)

NewDecimalFromString creates a decimal from a string

func (*DecimalValue) GetAttr added in v0.3.0

func (d *DecimalValue) GetAttr(name string) (Value, bool)

GetAttr implements basic decimal methods using TypeDescriptor

func (*DecimalValue) GetDecimal added in v0.3.0

func (d *DecimalValue) GetDecimal() decimal.Decimal

GetDecimal returns the underlying decimal.Decimal

func (*DecimalValue) String added in v0.3.0

func (d *DecimalValue) String() string

String implements Value.String

func (*DecimalValue) Type added in v0.3.0

func (d *DecimalValue) Type() Type

Type implements Value.Type

type DefaultModuleLoader

type DefaultModuleLoader struct {
	// contains filtered or unexported fields
}

DefaultModuleLoader is the default implementation of ModuleLoader

func NewDefaultModuleLoader

func NewDefaultModuleLoader(ctx *Context, evalFunc func(expr Value, ctx *Context) (Value, error), parseFunc func(code string) (Value, error)) *DefaultModuleLoader

NewDefaultModuleLoader creates a new DefaultModuleLoader

func (*DefaultModuleLoader) GetContext

func (l *DefaultModuleLoader) GetContext() *Context

GetContext returns the evaluation context

func (*DefaultModuleLoader) LoadModule

func (l *DefaultModuleLoader) LoadModule(name string, ctx *Context) (*DictValue, error)

LoadModule loads a module by name and returns its content

func (*DefaultModuleLoader) SetContext

func (l *DefaultModuleLoader) SetContext(ctx *Context)

SetContext sets the evaluation context

type DictDescriptor added in v0.3.0

type DictDescriptor struct {
	BaseObject
}

DictDescriptor is a descriptor for accessing __dict__ attribute of classes It implements the descriptor protocol with __get__ method

func NewDictDescriptor added in v0.3.0

func NewDictDescriptor() *DictDescriptor

NewDictDescriptor creates a new __dict__ descriptor

func (*DictDescriptor) GetAttr added in v0.3.0

func (d *DictDescriptor) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for DictDescriptor

type DictValue

type DictValue struct {
	BaseObject
	// contains filtered or unexported fields
}

DictValue represents a dictionary mapping keys to values

func NewDict

func NewDict() *DictValue

NewDict creates a new dictionary

func (*DictValue) Delete

func (d *DictValue) Delete(key string)

Delete removes a key by internal representation INTERNAL: Callers should use ValueToKey() to convert keys first

func (*DictValue) DeleteValue added in v0.2.0

func (d *DictValue) DeleteValue(key Value) bool

DeleteValue removes a key by M28 value (handles conversion) This is the preferred public API for deleting dict values

func (*DictValue) Get

func (d *DictValue) Get(key string) (Value, bool)

Get retrieves a value by internal key representation INTERNAL: Callers should use ValueToKey() to convert keys first

func (*DictValue) GetAttr

func (d *DictValue) GetAttr(name string) (Value, bool)

GetAttr implements Object interface using TypeDescriptor

func (*DictValue) GetValue added in v0.2.0

func (d *DictValue) GetValue(key Value) (Value, bool)

GetValue retrieves a value by M28 value key (handles conversion) This is the preferred public API for getting dict values

func (*DictValue) Iterator added in v0.3.0

func (d *DictValue) Iterator() Iterator

Iterator implements Iterable for dicts (iterates over keys)

func (*DictValue) Keys

func (d *DictValue) Keys() []string

Keys returns all internal key representations in insertion order INTERNAL: Use dict.keys() method instead which returns original keys

func (*DictValue) OriginalKeys added in v0.2.0

func (d *DictValue) OriginalKeys() []Value

OriginalKeys returns all original key values (not internal representations) This is what dict.keys() method uses

func (*DictValue) Set

func (d *DictValue) Set(key string, value Value)

Set sets a value by internal key representation INTERNAL: Use SetWithKey for proper key tracking when you have the original key This method will reconstruct the original key from the internal representation

func (*DictValue) SetAttr

func (d *DictValue) SetAttr(name string, value Value) error

SetAttr implements Object.SetAttr for dictionary key assignment

func (*DictValue) SetValue added in v0.2.0

func (d *DictValue) SetValue(key Value, value Value) error

SetValue sets a value by M28 value key (handles conversion) This is the preferred public API for setting dict values

func (*DictValue) SetWithKey

func (d *DictValue) SetWithKey(keyRepr string, origKey Value, value Value)

SetWithKey sets a value with both key representation and original key This is the preferred method for setting dict values

func (*DictValue) Size

func (d *DictValue) Size() int

Size returns the number of entries in the dictionary

func (*DictValue) String

func (d *DictValue) String() string

String implements Value.String

func (*DictValue) Type

func (d *DictValue) Type() Type

Type implements Value.Type

type DocEntry

type DocEntry struct {
	// Name of the symbol
	Name string

	// Type of the symbol (e.g. "function", "special-form", "class", "method")
	Type string

	// Brief one-line description
	Brief string

	// Detailed description (can include multiline text)
	Description string

	// Parameters documentation (only for callables)
	Params []ParamDoc

	// Return value documentation (only for callables)
	Returns string

	// Example usage
	Examples []string

	// Related topics
	Related []string

	// Module where this is defined (if applicable)
	Module string
}

DocEntry stores documentation for a symbol

func GetDoc

func GetDoc(name string) (DocEntry, bool)

GetDoc is a convenience function for accessing the global registry

func ListByModule

func ListByModule(moduleName string) []DocEntry

ListByModule is a convenience function for accessing the global registry

func ListByType

func ListByType(typeName string) []DocEntry

ListByType is a convenience function for accessing the global registry

type DocRegistry

type DocRegistry struct {
	// contains filtered or unexported fields
}

DocRegistry is the global documentation registry

func NewDocRegistry

func NewDocRegistry() *DocRegistry

NewDocRegistry creates a new documentation registry

func (*DocRegistry) GetDoc

func (r *DocRegistry) GetDoc(name string) (DocEntry, bool)

GetDoc retrieves documentation for a symbol

func (*DocRegistry) ListByModule

func (r *DocRegistry) ListByModule(moduleName string) []DocEntry

ListByModule retrieves all symbols from a given module

func (*DocRegistry) ListByType

func (r *DocRegistry) ListByType(typeName string) []DocEntry

ListByType retrieves all symbols of a given type

func (*DocRegistry) ListModules

func (r *DocRegistry) ListModules() []string

ListModules retrieves a list of all registered modules

func (*DocRegistry) ListTypes

func (r *DocRegistry) ListTypes() []string

ListTypes retrieves a list of all registered symbol types

func (*DocRegistry) Register

func (r *DocRegistry) Register(entry DocEntry)

Register adds a documentation entry to the registry

type EllipsisValue added in v0.3.0

type EllipsisValue struct{}

EllipsisValue represents Python's Ellipsis literal (...)

func (EllipsisValue) String added in v0.3.0

func (e EllipsisValue) String() string

String implements Value.String

func (EllipsisValue) Type added in v0.3.0

func (e EllipsisValue) Type() Type

Type implements Value.Type

type EnhancedModuleInfo

type EnhancedModuleInfo struct {
	Module       *Module   // The module object
	LoadTime     time.Time // When the module was loaded
	Dependencies []string  // List of modules this module depends on
}

ModuleRegistry enhancement for new module type

type EnhancedModuleRegistry

type EnhancedModuleRegistry struct {
	// contains filtered or unexported fields
}

EnhancedModuleRegistry keeps track of loaded modules

func NewEnhancedModuleRegistry

func NewEnhancedModuleRegistry() *EnhancedModuleRegistry

NewEnhancedModuleRegistry creates a new enhanced module registry

func (*EnhancedModuleRegistry) GetModule

func (r *EnhancedModuleRegistry) GetModule(name string) (*Module, bool)

GetModule returns a module from the enhanced registry

func (*EnhancedModuleRegistry) StoreModule

func (r *EnhancedModuleRegistry) StoreModule(module *Module, dependencies []string)

StoreModule stores a module in the enhanced registry

type EvalError

type EvalError struct {
	Type       string
	Message    string
	File       string
	Line       int
	Column     int
	Suggestion string
	Wrapped    error
	SyntaxKind int // Which frontend syntax (ast.SyntaxKind)
}

EvalError is raised during evaluation with context

func WrapEvalError

func WrapEvalError(err error, message string, ctx *Context) *EvalError

WrapEvalError wraps an existing error with evaluation context

func (*EvalError) Error

func (e *EvalError) Error() string

type ExceptionValue

type ExceptionValue struct {
	BaseObject
	Message string
	Cause   error
}

ExceptionValue represents an exception in the language

func NewException

func NewException(message string) *ExceptionValue

NewException creates a new exception with a message

func NewExceptionWithCause

func NewExceptionWithCause(message string, cause error) *ExceptionValue

NewExceptionWithCause creates a new exception with a message and a cause

func (*ExceptionValue) Error

func (e *ExceptionValue) Error() string

Error implements the error interface

func (*ExceptionValue) String

func (e *ExceptionValue) String() string

String implements Value.String

type File

type File struct {
	BaseObject
	Path string
	Mode string
	// contains filtered or unexported fields
}

File represents a file object

func NewFile

func NewFile(path string, mode string) (*File, error)

NewFile creates a new file object

func (*File) Close

func (f *File) Close() error

Close closes the file

func (*File) Enter

func (f *File) Enter() (Value, error)

Enter implements context manager protocol

func (*File) Exit

func (f *File) Exit(excType, excValue, excTraceback Value) (bool, error)

Exit implements context manager protocol

func (*File) GetAttr

func (f *File) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*File) GetBaseObject added in v0.3.0

func (f *File) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*File) GetRegistry added in v0.3.0

func (f *File) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*File) Iterator

func (f *File) Iterator() Iterator

Iterator returns an iterator over the file's lines

func (*File) Read

func (f *File) Read(size int) (Value, error)

Read reads from the file

func (*File) ReadLine

func (f *File) ReadLine() (Value, error)

ReadLine reads a single line

func (*File) ReadLines

func (f *File) ReadLines() (Value, error)

ReadLines reads all lines

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek changes the file position

func (*File) String

func (f *File) String() string

String returns the string representation

func (*File) Tell

func (f *File) Tell() (int64, error)

Tell returns the current file position

func (*File) Type

func (f *File) Type() Type

Type returns the file type

func (*File) Write

func (f *File) Write(data string) error

Write writes to the file

type FileContextManager

type FileContextManager struct {
	BaseObject
	Path     string
	Mode     string
	File     interface{} // Would be actual file handle
	IsClosed bool
	// contains filtered or unexported fields
}

FileContextManager represents a file that can be used with 'with'

func NewFileContextManager

func NewFileContextManager(path string, mode string) *FileContextManager

NewFileContextManager creates a new file context manager

func (*FileContextManager) Enter

func (f *FileContextManager) Enter() (Value, error)

Enter implements ContextManager.Enter

func (*FileContextManager) Exit

func (f *FileContextManager) Exit(excType, excValue, excTraceback Value) (bool, error)

Exit implements ContextManager.Exit

func (*FileContextManager) GetAttr

func (f *FileContextManager) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*FileContextManager) GetBaseObject added in v0.3.0

func (f *FileContextManager) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*FileContextManager) GetRegistry added in v0.3.0

func (f *FileContextManager) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*FileContextManager) String

func (f *FileContextManager) String() string

String implements Value.String

func (*FileContextManager) Type

func (f *FileContextManager) Type() Type

Type implements Value.Type

type FileIterator

type FileIterator struct {
	// contains filtered or unexported fields
}

FileIterator implements the Iterator interface for files

func (*FileIterator) Next

func (fi *FileIterator) Next() (Value, bool)

Next advances the iterator and returns the next line

func (*FileIterator) Reset

func (fi *FileIterator) Reset()

Reset resets the iterator to the beginning

type FileNotFoundError added in v0.3.0

type FileNotFoundError struct {
	Message  string
	Errno    int // Optional: errno number
	Filename string
	Location *SourceLocation
}

FileNotFoundError represents a file not found error (subclass of OSError in Python)

func NewFileNotFoundError added in v0.3.0

func NewFileNotFoundError(message string, filename string) *FileNotFoundError

NewFileNotFoundError creates a new file not found error

func (*FileNotFoundError) Error added in v0.3.0

func (e *FileNotFoundError) Error() string

type FrameType added in v0.3.0

type FrameType struct {
	BaseObject
}

FrameType represents a Python frame object

func NewFrame added in v0.3.0

func NewFrame() *FrameType

NewFrame creates a new frame object

func (*FrameType) String added in v0.3.0

func (f *FrameType) String() string

type FrozenSetValue added in v0.3.0

type FrozenSetValue struct {
	BaseObject
	// contains filtered or unexported fields
}

FrozenSetValue represents an immutable set of unique values

func NewFrozenSet added in v0.3.0

func NewFrozenSet() *FrozenSetValue

NewFrozenSet creates a new frozenset

func (*FrozenSetValue) Add added in v0.3.0

func (fs *FrozenSetValue) Add(value Value)

Add adds a value to the frozenset (internal use only during construction)

func (*FrozenSetValue) Contains added in v0.3.0

func (fs *FrozenSetValue) Contains(value Value) bool

Contains checks if a value is in the frozenset

func (*FrozenSetValue) GetAttr added in v0.3.0

func (fs *FrozenSetValue) GetAttr(name string) (Value, bool)

GetAttr implements Object interface using TypeDescriptor

func (*FrozenSetValue) Hash added in v0.3.0

func (fs *FrozenSetValue) Hash() uint64

Hash computes and caches the hash value for the frozenset

func (*FrozenSetValue) Iterator added in v0.3.0

func (fs *FrozenSetValue) Iterator() Iterator

Iterator implements Iterable

func (*FrozenSetValue) Size added in v0.3.0

func (fs *FrozenSetValue) Size() int

Size returns the number of elements

func (*FrozenSetValue) String added in v0.3.0

func (fs *FrozenSetValue) String() string

String implements Value.String

func (*FrozenSetValue) Type added in v0.3.0

func (fs *FrozenSetValue) Type() Type

Type implements Value.Type

type Generator

type Generator struct {
	BaseObject
	// contains filtered or unexported fields
}

Generator represents a generator object

func NewGenerator

func NewGenerator(name string, code Value, ctx *Context) *Generator

NewGenerator creates a new generator

func NewGeneratorExpression added in v0.3.0

func NewGeneratorExpression(name string, expr Value, varName string, varNames []string, iterable Value, condition Value, ctx *Context, evalFunc func(Value, *Context) (Value, error)) (*Generator, error)

NewGeneratorExpression creates a new generator for generator expressions This converts the iterable to items immediately, but evaluates the expression lazily

func (*Generator) Close

func (g *Generator) Close() (Value, error)

Close closes the generator

func (*Generator) GetAttr

func (g *Generator) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*Generator) GetBaseObject added in v0.3.0

func (g *Generator) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*Generator) GetCode

func (g *Generator) GetCode() Value

GetCode returns the generator's code

func (*Generator) GetRegistry added in v0.3.0

func (g *Generator) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*Generator) GetState

func (g *Generator) GetState() GeneratorState

GetState returns the generator's current state

func (*Generator) Iterator added in v0.2.0

func (g *Generator) Iterator() Iterator

Iterator returns an iterator for the generator

func (*Generator) Next

func (g *Generator) Next() (Value, error)

Next advances the generator and returns the next value

func (*Generator) Send

func (g *Generator) Send(value Value) (Value, error)

Send sends a value into the generator

func (*Generator) SetExecState added in v0.3.0

func (g *Generator) SetExecState(state GeneratorExecutor)

SetExecState sets the execution state for generator functions

func (*Generator) SetState

func (g *Generator) SetState(state GeneratorState)

SetState updates the generator's state

func (*Generator) String

func (g *Generator) String() string

String returns the string representation

func (*Generator) Throw added in v0.3.0

func (g *Generator) Throw(excType Value, excValue Value, excTb Value) (Value, error)

Throw throws an exception into the generator

func (*Generator) Type

func (g *Generator) Type() Type

Type returns the generator type

type GeneratorExecutor added in v0.3.0

type GeneratorExecutor interface {
	Next() (Value, error)
	Send(Value) (Value, error)
	Throw(excType Value, excValue Value, excTb Value) (Value, error)
}

GeneratorExecutor is an interface for executing generator functions This allows eval package to provide the implementation without circular dependency

type GeneratorFunction

type GeneratorFunction struct {
	BaseObject
	Function Value  // The underlying function
	Name     string // Function name
}

GeneratorFunction wraps a function that contains yield statements

func NewGeneratorFunction

func NewGeneratorFunction(function Value, name string) *GeneratorFunction

NewGeneratorFunction creates a new generator function

func (*GeneratorFunction) Call

func (gf *GeneratorFunction) Call(args []Value, ctx *Context) (Value, error)

Call creates and returns a new generator

func (*GeneratorFunction) CallWithKeywords added in v0.3.0

func (gf *GeneratorFunction) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

CallWithKeywords creates and returns a new generator with keyword arguments

func (*GeneratorFunction) GetAttr added in v0.3.0

func (gf *GeneratorFunction) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for generator functions Provides default values for standard function attributes

func (*GeneratorFunction) String

func (gf *GeneratorFunction) String() string

String returns the string representation

func (*GeneratorFunction) Type

func (gf *GeneratorFunction) Type() Type

Type returns the function type

type GeneratorIterator added in v0.2.0

type GeneratorIterator struct {
	// contains filtered or unexported fields
}

GeneratorIterator implements Iterator for generators

func (*GeneratorIterator) Next added in v0.2.0

func (gi *GeneratorIterator) Next() (Value, bool)

Next advances the iterator and returns the next value

func (*GeneratorIterator) Reset added in v0.2.0

func (gi *GeneratorIterator) Reset()

Reset resets the iterator to the beginning

type GeneratorState

type GeneratorState int

GeneratorState represents the state of a generator

const (
	GeneratorCreated GeneratorState = iota
	GeneratorSuspended
	GeneratorRunning
	GeneratorCompleted
)

type GenericAlias added in v0.3.0

type GenericAlias struct {
	BaseObject
	Origin *Class  // The origin class (e.g., list, dict)
	Args   []Value // The type parameters (e.g., [int] for list[int])
}

GenericAlias represents a parameterized generic type like list[int] or dict[str, int]

func NewGenericAlias added in v0.3.0

func NewGenericAlias(origin *Class, args []Value) *GenericAlias

NewGenericAlias creates a new generic alias

func (*GenericAlias) GetAttr added in v0.3.0

func (ga *GenericAlias) GetAttr(name string) (Value, bool)

GetAttr implements Object interface for generic aliases

func (*GenericAlias) String added in v0.3.0

func (ga *GenericAlias) String() string

String returns the string representation

func (*GenericAlias) Type added in v0.3.0

func (ga *GenericAlias) Type() Type

Type returns the generic alias type

type IRMetadata added in v0.3.0

type IRMetadata struct {
	// contains filtered or unexported fields
}

IRMetadata stores metadata about IR nodes that can't be embedded in the Value itself. This keeps Value types lightweight and avoids the "LocatedValue wrapper" problem.

The metadata is stored in separate maps indexed by the Value pointer. This allows us to track: - Source locations (for error messages) - Type annotations (for gradual typing) - Comments (for documentation) - Original syntax (Python vs Lisp for error display)

Usage:

metadata := NewIRMetadata()
ir := core.ListValue{...}
metadata.SetLocation(ir, &core.SourceLocation{File: "test.py", Line: 10, Col: 5})
loc := metadata.GetLocation(ir)  // Retrieve later

func NewIRMetadata added in v0.3.0

func NewIRMetadata() *IRMetadata

NewIRMetadata creates a new metadata table

func (*IRMetadata) Clear added in v0.3.0

func (m *IRMetadata) Clear()

Clear removes all metadata (useful for optimization passes)

func (*IRMetadata) GetComments added in v0.3.0

func (m *IRMetadata) GetComments(val Value) []string

GetComments retrieves comments for an IR value

func (*IRMetadata) GetLocation added in v0.3.0

func (m *IRMetadata) GetLocation(val Value) *SourceLocation

GetLocation retrieves the source location for an IR value

func (*IRMetadata) GetSyntaxKind added in v0.3.0

func (m *IRMetadata) GetSyntaxKind(val Value) (int, bool)

GetSyntaxKind retrieves the original syntax kind for an IR value

func (*IRMetadata) GetTypeAnnotation added in v0.3.0

func (m *IRMetadata) GetTypeAnnotation(val Value) interface{}

GetTypeAnnotation retrieves type annotation for an IR value

func (*IRMetadata) Merge added in v0.3.0

func (m *IRMetadata) Merge(other *IRMetadata)

Merge combines metadata from another table (useful for module imports)

func (*IRMetadata) SetComments added in v0.3.0

func (m *IRMetadata) SetComments(val Value, comments []string)

SetComments stores comments for an IR value

func (*IRMetadata) SetLocation added in v0.3.0

func (m *IRMetadata) SetLocation(val Value, loc *SourceLocation)

SetLocation stores the source location for an IR value

func (*IRMetadata) SetSyntaxKind added in v0.3.0

func (m *IRMetadata) SetSyntaxKind(val Value, kind int)

SetSyntaxKind stores the original syntax kind for an IR value

func (*IRMetadata) SetTypeAnnotation added in v0.3.0

func (m *IRMetadata) SetTypeAnnotation(val Value, typeInfo interface{})

SetTypeAnnotation stores type annotation for an IR value

func (*IRMetadata) Size added in v0.3.0

func (m *IRMetadata) Size() int

Size returns the number of tracked values

type ImportError added in v0.3.0

type ImportError struct {
	ModuleName string
	Message    string
	Location   *SourceLocation
}

ImportError represents a module import error

func (*ImportError) Error added in v0.3.0

func (e *ImportError) Error() string

type IndexError

type IndexError struct {
	Index    int
	Length   int
	Location *SourceLocation
}

IndexError represents an index out of bounds error

func (*IndexError) Error

func (e *IndexError) Error() string

type Instance

type Instance struct {
	BaseObject
	Class      *Class           // The class this is an instance of
	Attributes map[string]Value // Instance attributes (__dict__)
	SlotValues []Value          // Slot values (if class uses __slots__)
}

Instance represents an instance of a class

func NewInstance

func NewInstance(class *Class) *Instance

NewInstance creates a new instance of a class

func (*Instance) DelAttr added in v0.3.0

func (i *Instance) DelAttr(name string) error

DelAttr deletes an attribute from the instance Implements Python's descriptor protocol for deletion: 1. Check for descriptor with __delete__ in class 2. Delete from instance __dict__

func (*Instance) GetAttr

func (i *Instance) GetAttr(name string) (Value, bool)

GetAttr implements Object interface for instances Implements Python's descriptor protocol lookup order: 1. Data descriptors from class (has __set__ or __delete__) 2. Instance __dict__ 3. Non-data descriptors from class (has __get__ only) 4. Class attributes

func (*Instance) SetAttr

func (i *Instance) SetAttr(name string, value Value) error

SetAttr implements Object interface for instances Implements Python's descriptor protocol for setting: 1. Check for data descriptor with __set__ in class 2. Set in instance __dict__

func (*Instance) String

func (i *Instance) String() string

String returns the string representation of the instance

func (*Instance) Type

func (i *Instance) Type() Type

Type returns the instance type

type Iterable

type Iterable interface {
	Value

	// Iterator returns an iterator over the elements
	Iterator() Iterator
}

Iterable represents any value that can be iterated over

type Iterator

type Iterator interface {
	// Next advances the iterator and returns the next value
	Next() (Value, bool)

	// Reset resets the iterator to the beginning
	Reset()
}

Iterator represents an iterator over a collection

type IteratorWrapper added in v0.3.0

type IteratorWrapper struct {
	Iterator Iterator
}

IteratorWrapper wraps a Go Iterator to make it a Value with __next__

func (*IteratorWrapper) GetAttr added in v0.3.0

func (w *IteratorWrapper) GetAttr(name string) (Value, bool)

GetAttr implements __next__ method

func (*IteratorWrapper) String added in v0.3.0

func (w *IteratorWrapper) String() string

String returns string representation

func (*IteratorWrapper) Type added in v0.3.0

func (w *IteratorWrapper) Type() Type

Type returns the type

type KeyError

type KeyError struct {
	Key      Value
	Location *SourceLocation
}

KeyError represents a missing dictionary key

func (*KeyError) Error

func (e *KeyError) Error() string

type LispNumber

type LispNumber float64

LispNumber represents a numeric value in the M28 language

type LispString

type LispString string

LispString represents a string in the M28 language

type ListInstance added in v0.3.0

type ListInstance struct {
	Data  *ListValue // The underlying list data
	Class *Class     // The class this list is an instance of
}

ListInstance represents an instance of a class that inherits from list

func NewListInstance added in v0.3.0

func NewListInstance(class *Class, data *ListValue) *ListInstance

NewListInstance creates a new list instance of a class

func (*ListInstance) GetAttr added in v0.3.0

func (l *ListInstance) GetAttr(name string) (Value, bool)

GetAttr gets an attribute from the list's class

func (*ListInstance) Items added in v0.3.0

func (l *ListInstance) Items() []Value

Items returns the list items

func (*ListInstance) Iterator added in v0.3.0

func (l *ListInstance) Iterator() Iterator

Iterator returns an iterator for the list

func (*ListInstance) Len added in v0.3.0

func (l *ListInstance) Len() int

Len returns the length of the list

func (*ListInstance) String added in v0.3.0

func (l *ListInstance) String() string

String returns the string representation

func (*ListInstance) Type added in v0.3.0

func (l *ListInstance) Type() Type

Type returns the type of the list instance

type ListValue

type ListValue struct {
	BaseObject
	// contains filtered or unexported fields
}

ListValue represents a mutable list of values

func NewList added in v0.3.0

func NewList(values ...Value) *ListValue

NewList creates a new mutable list from values

func (*ListValue) Append added in v0.3.0

func (l *ListValue) Append(value Value)

Append adds an item to the end (mutates the list)

func (*ListValue) CallMethod

func (l *ListValue) CallMethod(name string, args []Value, ctx *Context) (Value, error)

CallMethod implements Object.CallMethod

func (*ListValue) Extend added in v0.3.0

func (l *ListValue) Extend(values []Value)

Extend adds multiple items to the end (mutates the list)

func (*ListValue) GetAttr

func (l *ListValue) GetAttr(name string) (Value, bool)

GetAttr implements Object interface using TypeDescriptor

func (*ListValue) GetItem

func (l *ListValue) GetItem(index int) (Value, error)

GetItem gets an item by index

func (*ListValue) Items added in v0.3.0

func (l *ListValue) Items() []Value

Items returns a copy of the underlying slice (for safe iteration)

func (*ListValue) Iterator

func (l *ListValue) Iterator() Iterator

Iterator implements Iterable

func (*ListValue) Len added in v0.3.0

func (l *ListValue) Len() int

Len returns the length of the list

func (*ListValue) SetAttr

func (l *ListValue) SetAttr(name string, value Value) error

SetAttr implements Object.SetAttr (not supported for lists)

func (*ListValue) SetItem

func (l *ListValue) SetItem(index int, value Value) error

SetItem sets an item by index (mutates the list)

func (*ListValue) SetSlice added in v0.3.0

func (l *ListValue) SetSlice(start, end *int, values *ListValue) error

SetSlice sets a slice of items (mutates the list) - implements x[start:end] = values

func (*ListValue) String

func (l *ListValue) String() string

String implements Value.String

func (*ListValue) Type

func (l *ListValue) Type() Type

Type implements Value.Type

type LocatedValue added in v0.2.0

type LocatedValue struct {
	Value    Value
	Location *SourceLocation
}

LocatedValue wraps a Value with source location information

func (LocatedValue) GetLocation added in v0.2.0

func (lv LocatedValue) GetLocation() *SourceLocation

GetLocation returns the source location of this value

func (LocatedValue) String added in v0.2.0

func (lv LocatedValue) String() string

String returns the string representation of the underlying value

func (LocatedValue) Type added in v0.2.0

func (lv LocatedValue) Type() Type

Type returns the type of the underlying value

func (LocatedValue) Unwrap added in v0.2.0

func (lv LocatedValue) Unwrap() Value

Unwrap returns the underlying value, handling nested LocatedValues

type MRODescriptor added in v0.3.0

type MRODescriptor struct {
	BaseObject
	// contains filtered or unexported fields
}

MRODescriptor is a descriptor for accessing __mro__ attribute It implements the descriptor protocol with __get__ method

func NewMRODescriptor added in v0.3.0

func NewMRODescriptor(class *Class) *MRODescriptor

NewMRODescriptor creates a new MRO descriptor

func (*MRODescriptor) GetAttr added in v0.3.0

func (m *MRODescriptor) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for MRODescriptor

type Method

type Method interface {
	Callable

	// Bind binds the method to a receiver object
	Bind(receiver Value) Value
}

Method represents a method that can be bound to an instance

type MethodDescriptor

type MethodDescriptor struct {
	Name         string
	Arity        int // -1 for variadic
	Doc          string
	Builtin      bool // Is it implemented in Go?
	Handler      MethodHandler
	KwargHandler MethodHandlerWithKwargs // Optional keyword argument handler
}

MethodDescriptor describes a method

type MethodEntry added in v0.3.0

type MethodEntry struct {
	Name    string
	Arity   int
	Doc     string
	Handler MethodHandler
}

MethodEntry describes a method that can be registered

func MakeContextEnterMethod added in v0.3.0

func MakeContextEnterMethod() *MethodEntry

MakeContextEnterMethod creates a standard __enter__ method

func MakeContextExitMethod added in v0.3.0

func MakeContextExitMethod(cleanup func(receiver Value) error) *MethodEntry

MakeContextExitMethod creates a standard __exit__ method with custom cleanup

func MakeIterMethod added in v0.3.0

func MakeIterMethod() *MethodEntry

MakeIterMethod creates a standard __iter__ method

func MakeMethod added in v0.3.0

func MakeMethod(name string, arity int, doc string, handler MethodHandler) *MethodEntry

MakeMethod creates a MethodEntry with common validation

type MethodHandler

type MethodHandler func(receiver Value, args []Value, ctx *Context) (Value, error)

MethodHandler is a function that implements a method

type MethodHandlerWithKwargs added in v0.3.0

type MethodHandlerWithKwargs func(receiver Value, args []Value, kwargs map[string]Value, ctx *Context) (Value, error)

MethodHandlerWithKwargs is a function that implements a method with keyword argument support

type MethodRegistry added in v0.3.0

type MethodRegistry struct {
	// contains filtered or unexported fields
}

MethodRegistry provides a registry for methods and properties

func NewMethodRegistry added in v0.3.0

func NewMethodRegistry() *MethodRegistry

NewMethodRegistry creates a new method registry

func (*MethodRegistry) GetAttr added in v0.3.0

func (r *MethodRegistry) GetAttr(receiver Value, name string) (Value, bool)

GetAttr looks up an attribute in the registry

func (*MethodRegistry) RegisterMethod added in v0.3.0

func (r *MethodRegistry) RegisterMethod(entry *MethodEntry)

RegisterMethod adds a method to the registry

func (*MethodRegistry) RegisterMethods added in v0.3.0

func (r *MethodRegistry) RegisterMethods(entries ...*MethodEntry)

RegisterMethods adds multiple methods at once

func (*MethodRegistry) RegisterProperties added in v0.3.0

func (r *MethodRegistry) RegisterProperties(entries ...*PropertyEntry)

RegisterProperties adds multiple properties at once

func (*MethodRegistry) RegisterProperty added in v0.3.0

func (r *MethodRegistry) RegisterProperty(entry *PropertyEntry)

RegisterProperty adds a property to the registry

type Module

type Module struct {
	BaseObject
	Name    string           // Module name
	Path    string           // File path
	Context *Context         // Module's execution context
	Exports map[string]Value // Explicitly exported values
	All     []string         // Names to export with * import
	Dict    *DictValue       // Backing dict for dynamic attribute lookups (optional)
}

Module represents a loaded module with export control

func NewModule

func NewModule(name, path string) *Module

NewModule creates a new module

func (*Module) Export

func (m *Module) Export(name string, value Value)

Export adds a value to the module's exports

func (*Module) GetAllExports

func (m *Module) GetAllExports() []string

GetAllExports returns all exported names

func (*Module) GetAttr

func (m *Module) GetAttr(name string) (Value, bool)

GetAttr implements object attribute access for modules

func (*Module) GetExport

func (m *Module) GetExport(name string) (Value, bool)

GetExport retrieves an exported value

func (*Module) SetAll

func (m *Module) SetAll(names []string)

SetAll sets the __all__ list for * imports

func (*Module) SetAttr added in v0.3.0

func (m *Module) SetAttr(name string, value Value) error

SetAttr implements attribute setting for modules

func (*Module) String

func (m *Module) String() string

String returns the string representation of the module

func (*Module) Type

func (m *Module) Type() Type

Type returns the module type

type ModuleInfo

type ModuleInfo struct {
	Module       *DictValue // The actual module contents
	Path         string     // Full path to the module file
	LoadTime     time.Time  // When the module was loaded
	Dependencies []string   // List of modules this module depends on
}

ModuleInfo holds information about a loaded module

type ModuleLoader

type ModuleLoader interface {
	// LoadModule loads a module by name and returns its content
	LoadModule(name string, ctx *Context) (*DictValue, error)

	// SetContext sets the evaluation context
	SetContext(ctx *Context)

	// GetContext returns the evaluation context
	GetContext() *Context
}

ModuleLoader interface defines methods for loading modules

func GetModuleLoader

func GetModuleLoader() ModuleLoader

GetModuleLoader returns the global module loader

type ModuleLoaderEnhanced added in v0.2.0

type ModuleLoaderEnhanced struct {
	DefaultModuleLoader
	// contains filtered or unexported fields
}

ModuleLoaderEnhanced is an enhanced module loader that supports builtin Go modules

func NewModuleLoaderEnhanced added in v0.2.0

func NewModuleLoaderEnhanced(
	ctx *Context,
	evalFunc func(expr Value, ctx *Context) (Value, error),
	parseFunc func(code string) (Value, error),
	getBuiltinModule func(name string) (*DictValue, bool),
) *ModuleLoaderEnhanced

NewModuleLoaderEnhanced creates a new enhanced module loader

func (*ModuleLoaderEnhanced) LoadModule added in v0.2.0

func (l *ModuleLoaderEnhanced) LoadModule(name string, ctx *Context) (*DictValue, error)

LoadModule loads a module by name and returns its content

type ModuleRegistry

type ModuleRegistry struct {
	// contains filtered or unexported fields
}

ModuleRegistry keeps track of loaded modules

func GetModuleRegistry

func GetModuleRegistry() *ModuleRegistry

GetModuleRegistry returns the global module registry

func NewModuleRegistry

func NewModuleRegistry() *ModuleRegistry

NewModuleRegistry creates a new ModuleRegistry

func (*ModuleRegistry) AddSearchPath

func (r *ModuleRegistry) AddSearchPath(path string)

AddSearchPath adds a directory to the module search path

func (*ModuleRegistry) ClearAllModules

func (r *ModuleRegistry) ClearAllModules()

ClearAllModules removes all modules from the registry

func (*ModuleRegistry) GetModule

func (r *ModuleRegistry) GetModule(name string) (*DictValue, bool)

GetModule returns a module from the registry

func (*ModuleRegistry) GetModuleInfo

func (r *ModuleRegistry) GetModuleInfo(name string) (ModuleInfo, bool)

GetModuleInfo returns information about a loaded module

func (*ModuleRegistry) GetSearchPaths

func (r *ModuleRegistry) GetSearchPaths() []string

GetSearchPaths returns a copy of the current search paths

func (*ModuleRegistry) IsLoading

func (r *ModuleRegistry) IsLoading(name string) bool

IsLoading checks if a module is currently being loaded

func (*ModuleRegistry) ListModules

func (r *ModuleRegistry) ListModules() []string

ListModules returns a list of all loaded module names

func (*ModuleRegistry) ReloadModule

func (r *ModuleRegistry) ReloadModule(name string) error

ReloadModule removes a module from the registry so it will be reloaded on next import

func (*ModuleRegistry) ResolveModulePath

func (r *ModuleRegistry) ResolveModulePath(name string) (string, error)

ResolveModulePath resolves a module name to its file path

func (*ModuleRegistry) SetLoading

func (r *ModuleRegistry) SetLoading(name string, loading bool)

SetLoading marks a module as being loaded

func (*ModuleRegistry) StoreModule

func (r *ModuleRegistry) StoreModule(name string, module *DictValue, path string, dependencies []string)

StoreModule stores a module in the registry

type NameError

type NameError struct {
	Name     string
	Location *SourceLocation
}

NameError is raised when a name is not found

func (*NameError) Error

func (e *NameError) Error() string

type NilValue

type NilValue struct{}

NilValue represents a nil/null/None value

func (NilValue) GetAttr added in v0.3.0

func (n NilValue) GetAttr(name string) (Value, bool)

GetAttr implements attribute access for None In Python, None has __class__ and other dunder attributes

func (NilValue) String

func (n NilValue) String() string

String implements Value.String

func (NilValue) Type

func (n NilValue) Type() Type

Type implements Value.Type

type NotImplementedValue added in v0.3.0

type NotImplementedValue struct{}

NotImplementedValue represents Python's NotImplemented singleton Used to indicate that a comparison operation is not implemented

func (NotImplementedValue) String added in v0.3.0

func (n NotImplementedValue) String() string

String implements Value.String

func (NotImplementedValue) Type added in v0.3.0

func (n NotImplementedValue) Type() Type

Type implements Value.Type

type NumberValue

type NumberValue float64

NumberValue represents a numeric value

func DemoteToNumber added in v0.3.0

func DemoteToNumber(b BigIntValue) (NumberValue, bool)

DemoteToNumber converts BigIntValue to NumberValue if it fits safely Returns (NumberValue, true) if demotion is safe, (0, false) otherwise

func (NumberValue) GetAttr

func (n NumberValue) GetAttr(name string) (Value, bool)

GetAttr implements basic number methods using TypeDescriptor

func (NumberValue) String

func (n NumberValue) String() string

String implements Value.String

func (NumberValue) Type

func (n NumberValue) Type() Type

Type implements Value.Type

type OSError added in v0.3.0

type OSError struct {
	Message  string
	Errno    int // Optional: errno number
	Filename string
	Location *SourceLocation
}

OSError represents an operating system error

func NewOSError added in v0.3.0

func NewOSError(message string, filename string) *OSError

NewOSError creates a new OS error

func (*OSError) Error added in v0.3.0

func (e *OSError) Error() string

type Object

type Object interface {
	Value

	// GetAttr retrieves an attribute by name
	GetAttr(name string) (Value, bool)

	// SetAttr sets an attribute value
	SetAttr(name string, value Value) error

	// CallMethod calls a method with arguments in a context
	CallMethod(name string, args []Value, ctx *Context) (Value, error)
}

Object represents any value that can have attributes and methods

type ParamDoc

type ParamDoc struct {
	// Parameter name
	Name string

	// Parameter type (if known)
	Type string

	// Description of the parameter
	Description string

	// Whether the parameter is optional
	Optional bool

	// Default value (if optional)
	Default string
}

ParamDoc documents a parameter

type PrintValueProvider

type PrintValueProvider interface {
	PrintValue() string
}

PrintValueProvider is an interface for types that can provide a custom string representation for the PrintValue function

type PropertyDescriptor

type PropertyDescriptor struct {
	Name     string
	ReadOnly bool
	Doc      string
	Getter   func(Value) (Value, error)
	Setter   func(Value, Value) error
}

PropertyDescriptor describes an attribute/property

type PropertyEntry added in v0.3.0

type PropertyEntry struct {
	Name   string
	Doc    string
	Getter PropertyGetter
}

PropertyEntry describes a property that can be registered

func MakeProperty added in v0.3.0

func MakeProperty(name, doc string, getter PropertyGetter) *PropertyEntry

MakeProperty creates a PropertyEntry

type PropertyGetter added in v0.3.0

type PropertyGetter func(receiver Value) (Value, error)

PropertyGetter is the function signature for property getters

type PropertyValue added in v0.3.0

type PropertyValue struct {
	Getter  Value
	Setter  Value
	Deleter Value
}

PropertyValue represents a Python property descriptor

func (*PropertyValue) GetAttr added in v0.3.0

func (p *PropertyValue) GetAttr(name string) (Value, bool)

GetAttr retrieves an attribute

func (*PropertyValue) SetAttr added in v0.3.0

func (p *PropertyValue) SetAttr(name string, value Value) error

SetAttr sets an attribute

func (*PropertyValue) String added in v0.3.0

func (p *PropertyValue) String() string

String implements Value.String

func (*PropertyValue) Type added in v0.3.0

func (p *PropertyValue) Type() Type

Type implements Value.Type

type RangeValue added in v0.2.0

type RangeValue struct {
	BaseObject
	Start float64
	Stop  float64
	Step  float64
	// contains filtered or unexported fields
}

RangeValue represents a lazy range object like Python's range

func NewRangeValue added in v0.2.0

func NewRangeValue(start, stop, step float64) (*RangeValue, error)

NewRangeValue creates a new range value

func (*RangeValue) Contains added in v0.2.0

func (r *RangeValue) Contains(value Value) bool

Contains checks if a value is in the range

func (*RangeValue) GetAttr added in v0.2.0

func (r *RangeValue) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*RangeValue) GetBaseObject added in v0.3.0

func (r *RangeValue) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*RangeValue) GetItem added in v0.2.0

func (r *RangeValue) GetItem(index int) (Value, error)

GetItem returns the item at the given index

func (*RangeValue) GetRegistry added in v0.3.0

func (r *RangeValue) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*RangeValue) Iterator added in v0.2.0

func (r *RangeValue) Iterator() Iterator

Iterator implements Iterable.Iterator

func (*RangeValue) Length added in v0.2.0

func (r *RangeValue) Length() int

Length returns the number of elements in the range

func (*RangeValue) String added in v0.2.0

func (r *RangeValue) String() string

String implements Value.String

func (*RangeValue) Type added in v0.2.0

func (r *RangeValue) Type() Type

Type implements Value.Type

type Registry added in v0.2.0

type Registry struct {
	// contains filtered or unexported fields
}

Registry provides thread-safe registration with duplicate detection

func GetBuiltinRegistry added in v0.2.0

func GetBuiltinRegistry() *Registry

GetBuiltinRegistry returns the global builtin registry

func NewRegistry added in v0.2.0

func NewRegistry(name string) *Registry

NewRegistry creates a new registry with the given name

func (*Registry) Clear added in v0.2.0

func (r *Registry) Clear()

Clear removes all entries (useful for testing)

func (*Registry) Get added in v0.2.0

func (r *Registry) Get(key string) (interface{}, bool)

Get retrieves a value from the registry

func (*Registry) GetAll added in v0.2.0

func (r *Registry) GetAll() map[string]interface{}

GetAll returns a copy of all entries

func (*Registry) GetDuplicates added in v0.2.0

func (r *Registry) GetDuplicates() map[string][]string

GetDuplicates returns a map of keys that have been registered multiple times

func (*Registry) Keys added in v0.2.0

func (r *Registry) Keys() []string

Keys returns all registered keys

func (*Registry) MustRegister added in v0.2.0

func (r *Registry) MustRegister(key string, value interface{})

MustRegister is like Register but panics on error

func (*Registry) Register added in v0.2.0

func (r *Registry) Register(key string, value interface{}) error

Register adds an entry to the registry, returning an error if it already exists

func (*Registry) RegisterWithDepth added in v0.2.0

func (r *Registry) RegisterWithDepth(key string, value interface{}, depth int) error

RegisterWithDepth adds an entry to the registry with custom call stack depth

type RegistryEntry added in v0.2.0

type RegistryEntry struct {
	Value    interface{}
	Location string // File:Line where it was registered
}

RegistryEntry tracks where an item was registered

type SelectCase

type SelectCase struct {
	Channel *Channel
	Value   Value                      // Value to send (for send cases)
	IsSend  bool                       // true for send, false for receive
	Body    func(Value) (Value, error) // Function to execute
}

SelectCase represents a case in a select statement

type SetValue

type SetValue struct {
	BaseObject
	// contains filtered or unexported fields
}

SetValue represents a set of unique values

func NewSet

func NewSet() *SetValue

NewSet creates a new set

func (*SetValue) Add

func (s *SetValue) Add(value Value)

Add adds a value to the set

func (*SetValue) Contains

func (s *SetValue) Contains(value Value) bool

Contains checks if a value is in the set

func (*SetValue) GetAttr

func (s *SetValue) GetAttr(name string) (Value, bool)

GetAttr implements Object interface using TypeDescriptor

func (*SetValue) Iterator added in v0.2.0

func (s *SetValue) Iterator() Iterator

Iterator implements Iterable

func (*SetValue) IteratorValue added in v0.3.0

func (s *SetValue) IteratorValue() Value

IteratorValue returns the iterator as a Value

func (*SetValue) Remove

func (s *SetValue) Remove(value Value) bool

Remove removes a value from the set

func (*SetValue) Size

func (s *SetValue) Size() int

Size returns the number of elements

func (*SetValue) String

func (s *SetValue) String() string

String implements Value.String

func (*SetValue) Type

func (s *SetValue) Type() Type

Type implements Value.Type

type SimpleContextManager

type SimpleContextManager struct {
	BaseContextManager
	EnterFunc func() (Value, error)
	ExitFunc  func(excType, excValue, excTraceback Value) (bool, error)
}

SimpleContextManager is a basic implementation for testing

func NewSimpleContextManager

func NewSimpleContextManager(enterFunc func() (Value, error), exitFunc func(excType, excValue, excTraceback Value) (bool, error)) *SimpleContextManager

NewSimpleContextManager creates a new simple context manager

func (*SimpleContextManager) Enter

func (cm *SimpleContextManager) Enter() (Value, error)

Enter implements ContextManager.Enter

func (*SimpleContextManager) Exit

func (cm *SimpleContextManager) Exit(excType, excValue, excTraceback Value) (bool, error)

Exit implements ContextManager.Exit

func (*SimpleContextManager) String

func (cm *SimpleContextManager) String() string

String implements Value.String

func (*SimpleContextManager) Type

func (cm *SimpleContextManager) Type() Type

Type implements Value.Type

type SliceValue added in v0.2.0

type SliceValue struct {
	Start Value
	Stop  Value
	Step  Value
}

SliceValue represents a slice object with start, stop, and step

func (*SliceValue) CallMethod added in v0.2.0

func (s *SliceValue) CallMethod(name string, args []Value, ctx *Context) (Value, error)

CallMethod implements Object.CallMethod

func (*SliceValue) GetAttr added in v0.2.0

func (s *SliceValue) GetAttr(name string) (Value, bool)

GetAttr implements Object interface

func (*SliceValue) SetAttr added in v0.2.0

func (s *SliceValue) SetAttr(name string, value Value) error

SetAttr implements Object.SetAttr (not supported for slices)

func (*SliceValue) String added in v0.2.0

func (s *SliceValue) String() string

String implements Value.String

func (*SliceValue) Type added in v0.2.0

func (s *SliceValue) Type() Type

Type implements Value.Type

type SlotDescriptor added in v0.3.0

type SlotDescriptor struct {
	BaseObject
	Name      string // Name of the slot
	SlotIndex int    // Index in the instance's slot values array
}

SlotDescriptor represents a __slots__ descriptor Slots are data descriptors that store values in a fixed array rather than __dict__

func NewSlotDescriptor added in v0.3.0

func NewSlotDescriptor(name string, index int) *SlotDescriptor

NewSlotDescriptor creates a new slot descriptor

func (*SlotDescriptor) GetAttr added in v0.3.0

func (sd *SlotDescriptor) GetAttr(name string) (Value, bool)

GetAttr implements the descriptor __get__ method

func (*SlotDescriptor) String added in v0.3.0

func (sd *SlotDescriptor) String() string

String returns the string representation

func (*SlotDescriptor) Type added in v0.3.0

func (sd *SlotDescriptor) Type() Type

Type returns the descriptor type

type SourceLocation added in v0.2.0

type SourceLocation struct {
	File   string
	Line   int
	Column int
}

SourceLocation represents a position in source code

func GetLocationForValue added in v0.3.0

func GetLocationForValue(ctx *Context, val Value) *SourceLocation

GetLocationForValue is a helper to extract location for a value from context metadata Returns nil if context, metadata, or location is not available

func GetValueLocation added in v0.2.0

func GetValueLocation(value Value) *SourceLocation

GetValueLocation extracts source location from a value if it has one

func (*SourceLocation) String added in v0.3.0

func (sl *SourceLocation) String() string

String returns a human-readable representation of the source location

type StaticMethodValue added in v0.3.0

type StaticMethodValue struct {
	Function Value
}

StaticMethodValue represents a Python static method

func (*StaticMethodValue) Call added in v0.3.0

func (s *StaticMethodValue) Call(args []Value, ctx *Context) (Value, error)

Call implements Callable.Call

func (*StaticMethodValue) String added in v0.3.0

func (s *StaticMethodValue) String() string

String implements Value.String

func (*StaticMethodValue) Type added in v0.3.0

func (s *StaticMethodValue) Type() Type

Type implements Value.Type

type StopIteration

type StopIteration struct {
	Message string
	Value   Value
}

StopIteration is the error raised when a generator is exhausted

func (*StopIteration) Error

func (e *StopIteration) Error() string

type StringValue

type StringValue string

StringValue represents a string value

func (StringValue) GetAttr

func (s StringValue) GetAttr(name string) (Value, bool)

GetAttr implements basic string methods using TypeDescriptor

func (StringValue) String

func (s StringValue) String() string

String implements Value.String

func (StringValue) Type

func (s StringValue) Type() Type

Type implements Value.Type

type Super

type Super struct {
	BaseObject
	Class       *Class
	Instance    *Instance // For instance methods (self)
	TargetClass *Class    // For class methods/__new__ (cls)
}

Super represents access to parent class methods

func NewSuper

func NewSuper(class *Class, instance *Instance) *Super

NewSuper creates a new super object for instance methods

func NewSuperForClass added in v0.3.0

func NewSuperForClass(class *Class, targetClass *Class) *Super

NewSuperForClass creates a new super object for class methods and __new__

func (*Super) GetAttr

func (s *Super) GetAttr(name string) (Value, bool)

GetAttr gets an attribute from the parent class

func (*Super) String

func (s *Super) String() string

String returns the string representation

func (*Super) Type

func (s *Super) Type() Type

Type returns the super type

type SymbolValue

type SymbolValue string

SymbolValue represents a symbol identifier

func (SymbolValue) String

func (s SymbolValue) String() string

String implements Value.String

func (SymbolValue) Type

func (s SymbolValue) Type() Type

Type implements Value.Type

type SystemExit added in v0.3.0

type SystemExit struct {
	Code     int
	Location *SourceLocation
}

SystemExit represents a request to exit the program

func NewSystemExit added in v0.3.0

func NewSystemExit(code int) *SystemExit

NewSystemExit creates a new SystemExit error

func (*SystemExit) Error added in v0.3.0

func (e *SystemExit) Error() string

type Task

type Task struct {
	BaseObject
	Name     string
	Function Value
	Args     []Value
	Result   Value
	Err      error
	Done     chan bool
	Started  bool
	Finished bool
	Mu       sync.Mutex
	// contains filtered or unexported fields
}

Task represents an async task (goroutine)

func NewTask

func NewTask(name string, function Value, args []Value) *Task

NewTask creates a new async task

func (*Task) GetAttr

func (t *Task) GetAttr(name string) (Value, bool)

GetAttr implements the new simplified GetAttr pattern

func (*Task) GetBaseObject added in v0.3.0

func (t *Task) GetBaseObject() *BaseObject

GetBaseObject implements AttributeProvider

func (*Task) GetRegistry added in v0.3.0

func (t *Task) GetRegistry() *MethodRegistry

GetRegistry implements AttributeProvider

func (*Task) IsFinished

func (t *Task) IsFinished() bool

IsFinished checks if the task has completed

func (*Task) Start

func (t *Task) Start(ctx *Context)

Start begins execution of the task

func (*Task) String

func (t *Task) String() string

String returns the string representation

func (*Task) Type

func (t *Task) Type() Type

Type returns the task type

func (*Task) Wait

func (t *Task) Wait() (Value, error)

Wait waits for the task to complete and returns its result

type TraceConfig added in v0.3.0

type TraceConfig struct {
	Enabled        bool     // Master switch
	FunctionCalls  bool     // Trace function entry/exit
	Variables      bool     // Trace variable assignments
	ModuleFilter   []string // Only trace these modules (empty = all)
	FunctionFilter []string // Only trace these functions (empty = all)
	MaxDepth       int      // Maximum call depth to trace (0 = unlimited)
}

TraceConfig controls what gets traced

func GetTraceConfig added in v0.3.0

func GetTraceConfig() *TraceConfig

GetTraceConfig returns the global trace configuration

func (*TraceConfig) ShouldTraceFunction added in v0.3.0

func (cfg *TraceConfig) ShouldTraceFunction(funcName string) bool

ShouldTraceFunction returns true if this function should be traced

func (*TraceConfig) ShouldTraceModule added in v0.3.0

func (cfg *TraceConfig) ShouldTraceModule(moduleName string) bool

ShouldTraceModule returns true if this module should be traced

type TraceEntry

type TraceEntry struct {
	Function string
	File     string
	Line     int
	Column   int
}

TraceEntry represents a single entry in a stack trace

type TracebackType added in v0.3.0

type TracebackType struct {
	BaseObject
	Frame Value // tb_frame
}

TracebackType represents a Python traceback object

func NewTraceback added in v0.3.0

func NewTraceback() *TracebackType

NewTraceback creates a new traceback object

func (*TracebackType) GetAttr added in v0.3.0

func (t *TracebackType) GetAttr(name string) (Value, bool)

GetAttr implements Object.GetAttr for traceback

func (*TracebackType) String added in v0.3.0

func (t *TracebackType) String() string

type TupleInstance added in v0.3.0

type TupleInstance struct {
	Data  TupleValue // The underlying tuple data
	Class *Class     // The class this tuple is an instance of
}

TupleInstance represents a tuple that is an instance of a class (e.g., namedtuple)

func NewTupleInstance added in v0.3.0

func NewTupleInstance(class *Class, data TupleValue) *TupleInstance

NewTupleInstance creates a new tuple instance of a class

func (*TupleInstance) GetAttr added in v0.3.0

func (t *TupleInstance) GetAttr(name string) (Value, bool)

GetAttr gets an attribute from the tuple's class

func (*TupleInstance) Items added in v0.3.0

func (t *TupleInstance) Items() []Value

Items returns the tuple items

func (*TupleInstance) Iterator added in v0.3.0

func (t *TupleInstance) Iterator() Iterator

Iterator returns an iterator for the tuple

func (*TupleInstance) Len added in v0.3.0

func (t *TupleInstance) Len() int

Len returns the length of the tuple

func (*TupleInstance) String added in v0.3.0

func (t *TupleInstance) String() string

String returns the string representation

func (*TupleInstance) Type added in v0.3.0

func (t *TupleInstance) Type() Type

Type returns the type of the tuple instance

type TupleValue

type TupleValue []Value

TupleValue represents an immutable sequence

func (TupleValue) GetAttr

func (t TupleValue) GetAttr(name string) (Value, bool)

GetAttr implements Object interface using TypeDescriptor

func (TupleValue) GetItem

func (t TupleValue) GetItem(index int) (Value, error)

GetItem gets an item by index

func (TupleValue) Iterator

func (t TupleValue) Iterator() Iterator

Iterator implements Iterable

func (TupleValue) String

func (t TupleValue) String() string

String implements Value.String

func (TupleValue) Type

func (t TupleValue) Type() Type

Type implements Value.Type

type Type

type Type string

Type represents a type in the language

const (
	NumberType    Type = "number"
	BigIntType    Type = "int" // Arbitrary precision integer (Python: int)
	StringType    Type = "string"
	BoolType      Type = "bool"
	NilType       Type = "nil"
	SymbolType    Type = "symbol"
	ListType      Type = "list"
	DictType      Type = "dict"
	TupleType     Type = "tuple"
	SetType       Type = "set"
	FrozenSetType Type = "frozenset"
	FunctionType  Type = "function"
	MethodType    Type = "method"
	ModuleType    Type = "module"
	ClassType     Type = "class"
	ExceptionType Type = "exception"
	SliceType     Type = "slice"
	RangeType     Type = "range"
	BytesType     Type = "bytes"
	ByteArrayType Type = "bytearray"
	DecimalType   Type = "decimal"
	ComplexType   Type = "complex"
)

Predefined type constants

const ErrorType Type = "error"

ErrorType is a special type for errors

type TypeDescriptor

type TypeDescriptor struct {
	Name        string                         // M28 type name
	PythonName  string                         // Python-compatible name
	BaseType    Type                           // Core type constant
	Parent      *TypeDescriptor                // For inheritance (future)
	Methods     map[string]*MethodDescriptor   // Available methods
	Properties  map[string]*PropertyDescriptor // Properties/attributes
	Constructor ConstructorFunc                // How to create instances
	Repr        func(Value) string             // String representation
	Str         func(Value) string             // Human-readable string
	Doc         string                         // Type documentation
	// contains filtered or unexported fields
}

TypeDescriptor holds all metadata about a type

func GetTypeDescriptor

func GetTypeDescriptor(t Type) *TypeDescriptor

GetTypeDescriptor returns the descriptor for a type

func GetTypeDescriptorForValue

func GetTypeDescriptorForValue(v Value) *TypeDescriptor

GetTypeDescriptorForValue returns the descriptor for a value's type

func (*TypeDescriptor) CallMethod

func (td *TypeDescriptor) CallMethod(receiver Value, methodName string, args []Value, ctx *Context) (Value, error)

CallMethod calls a method on a value

func (*TypeDescriptor) GetAttribute

func (td *TypeDescriptor) GetAttribute(receiver Value, name string) (Value, error)

GetAttribute gets an attribute value (method or property)

func (*TypeDescriptor) GetAttributeNames

func (td *TypeDescriptor) GetAttributeNames() []string

GetAttributeNames returns all attribute names (methods and properties)

func (*TypeDescriptor) GetMethod

func (td *TypeDescriptor) GetMethod(name string) (*MethodDescriptor, bool)

GetMethod looks up a method by name

func (*TypeDescriptor) GetProperty

func (td *TypeDescriptor) GetProperty(name string) (*PropertyDescriptor, bool)

GetProperty looks up a property by name

func (*TypeDescriptor) GetTypeObject added in v0.3.0

func (td *TypeDescriptor) GetTypeObject() Value

GetTypeObject returns a type object (callable) for this type This is used for __class__ attribute and pickle support The result is cached to ensure identity equality

func (*TypeDescriptor) SetAttribute

func (td *TypeDescriptor) SetAttribute(receiver Value, name string, value Value) error

SetAttribute sets an attribute value (only for writable properties)

func (*TypeDescriptor) SetTypeObject added in v0.3.0

func (td *TypeDescriptor) SetTypeObject(typeObj Value)

SetTypeObject sets the cached type object for this type descriptor This is used to ensure that the global type (e.g., bool, int) is the same object as the one returned by obj.__class__

type TypeError

type TypeError struct {
	Message  string
	Expected string
	Got      string
	Location *SourceLocation
}

TypeError is raised when a type error occurs

func NewTypeError

func NewTypeError(expected string, got Value, context string) *TypeError

NewTypeError creates a new type error

func (*TypeError) Error

func (e *TypeError) Error() string

type UnionType added in v0.3.0

type UnionType struct {
	BaseObject
	Types []Value // The types in the union
}

UnionType represents a union of types like int | str

func NewUnionType added in v0.3.0

func NewUnionType(types []Value) *UnionType

NewUnionType creates a new union type

func (*UnionType) GetAttr added in v0.3.0

func (ut *UnionType) GetAttr(name string) (Value, bool)

GetAttr implements Object interface for union types

func (*UnionType) String added in v0.3.0

func (ut *UnionType) String() string

String returns the string representation

func (*UnionType) Type added in v0.3.0

func (ut *UnionType) Type() Type

Type returns the union type

type Value

type Value interface {
	// Type returns the value's type
	Type() Type

	// String returns a string representation
	String() string
}

Value is the base interface for all values in the language

func GetAttrWithRegistry added in v0.3.0

func GetAttrWithRegistry(provider AttributeProvider, name string) (Value, bool)

GetAttrWithRegistry provides common GetAttr implementation using a registry

func Select

func Select(cases []SelectCase, defaultCase func() (Value, error)) (Value, error)

Select performs a select operation on multiple channels

func WithLocation added in v0.2.0

func WithLocation(value Value, file string, line, column int) Value

WithLocation wraps a value with source location information

type ValueError added in v0.3.0

type ValueError struct {
	Message  string
	Location *SourceLocation
}

ValueError represents an invalid value error

func NewValueError added in v0.3.0

func NewValueError(msg string) *ValueError

NewValueError creates a new value error

func (*ValueError) Error added in v0.3.0

func (e *ValueError) Error() string

type WithContext

type WithContext struct {
	Manager  ContextManager
	Variable string // Variable name for 'as' clause
	Value    Value  // Value returned by __enter__
}

WithContext represents the context for a with statement

type YieldFromValue added in v0.3.0

type YieldFromValue struct {
	Iterable Value
}

YieldFromValue represents a yield from expression during generator execution

func IsYieldFrom added in v0.3.0

func IsYieldFrom(v Value) (*YieldFromValue, bool)

IsYieldFrom checks if a value is a yield-from marker

func (*YieldFromValue) String added in v0.3.0

func (y *YieldFromValue) String() string

String implements Value.String

func (*YieldFromValue) Type added in v0.3.0

func (y *YieldFromValue) Type() Type

Type implements Value.Type

type YieldValue

type YieldValue struct {
	Value Value
}

YieldValue represents a yielded value during generator execution

func IsYield

func IsYield(v Value) (*YieldValue, bool)

IsYield checks if a value is a yield marker

func (*YieldValue) String

func (y *YieldValue) String() string

String implements Value.String

func (*YieldValue) Type

func (y *YieldValue) Type() Type

Type implements Value.Type

type ZeroDivisionError

type ZeroDivisionError struct {
	Location *SourceLocation
}

ZeroDivisionError represents division by zero

func NewZeroDivisionError added in v0.3.0

func NewZeroDivisionError() *ZeroDivisionError

NewZeroDivisionError creates a new zero division error

func (*ZeroDivisionError) Error

func (e *ZeroDivisionError) Error() string

Directories

Path Synopsis
Package ast provides the abstract syntax tree types for M28.
Package ast provides the abstract syntax tree types for M28.
Package protocols defines standard interfaces for M28 types to implement common operations like arithmetic, indexing, and iteration.
Package protocols defines standard interfaces for M28 types to implement common operations like arithmetic, indexing, and iteration.

Jump to

Keyboard shortcuts

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