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
- Variables
- func Compare(a, b Value) int
- func DebugLog(format string, args ...interface{})
- func EqualValues(a, b Value) bool
- func ErrDotMethodCallf(methodName string, err error) error
- func ErrDotMissingInterfacef(objType interface{}) error
- func ErrDotModulePropertyf(moduleName, propName string) error
- func ErrDotNestedAccessf(path, prop string, err error) error
- func ErrDotNoMethodf(name string) error
- func ErrDotNoPropertyf(name string) error
- func ErrDotNotCallablef(propName string, propType interface{}) error
- func ErrTooManyArgumentsf(methodName string, expected, got int) error
- func FindModule(name string) (string, error)
- func FormatDocEntry(entry DocEntry) string
- func FormatDocList(entries []DocEntry, title string) string
- func GetBuiltinRegistrationInfo() map[string]interface{}
- func GetDuplicateBuiltinDetails() map[string][]string
- func GetDuplicateBuiltins() []string
- func GetModulePaths() []string
- func GetSyntaxKindForValue(ctx *Context, val Value) int
- func InitDictMethods()
- func InitListMethods()
- func InitSetMethods()
- func InitStringMethods()
- func InitTraceConfig()
- func InitializeTypeRegistryRefactored()
- func IsClass(v Value) bool
- func IsHashable(v Value) bool
- func IsInSafeRange(f float64) bool
- func IsInstance(v Value) bool
- func IsInstanceOf(instance *Instance, class *Class) bool
- func IsInteger(f float64) bool
- func IsTruthy(v Value) bool
- func ListModules() []string
- func ListTypes() []string
- func ParseFloat(s string) (float64, bool)
- func ParseInt(s string) (int64, bool)
- func PrintErrorValue(err error) string
- func PrintValue(val Value) string
- func PrintValueWithoutQuotes(val Value) string
- func ProcessEscapeSequences(s string) string
- func RegisterDoc(entry DocEntry)
- func RegisterDocStrings(docs map[string]string)
- func RegisterType(desc *TypeDescriptor)
- func Repr(val Value) string
- func SetModuleLoader(loader ModuleLoader)
- func SetModulePaths(paths []string)
- func SetPythonLoader(...)
- func SetupSlots(class *Class, slotsValue Value) error
- func ShouldPromoteToBigInt(f float64) bool
- func Sleep(seconds float64)
- func TraceEnterFunction(funcName string, args []Value)
- func TraceExitFunction(funcName string, result Value, err error)
- func TraceValue(label string, value Value)
- func TraceVariable(varName string, value Value, location string)
- func TypedReceiver[T Value](receiver Value, methodName string) (T, error)
- func ValidateArity(name string, args []Value, expected int) error
- func ValidateArityRange(name string, args []Value, min, max int) error
- func ValueToKey(v Value) string
- type AsyncFunction
- type AttributeError
- type AttributeProvider
- type BaseContextManager
- type BaseObject
- type BigIntValue
- func (b BigIntValue) FitsInFloat64() bool
- func (b BigIntValue) GetAttr(name string) (Value, bool)
- func (b BigIntValue) GetBigInt() *big.Int
- func (b BigIntValue) Sign() int
- func (b BigIntValue) String() string
- func (b BigIntValue) ToFloat64() float64
- func (b BigIntValue) ToInt64() (int64, bool)
- func (b BigIntValue) Type() Type
- type BoolValue
- type BoundClassMethod
- type BoundInstanceMethod
- func (bm *BoundInstanceMethod) Call(args []Value, ctx *Context) (Value, error)
- func (bm *BoundInstanceMethod) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
- func (bm *BoundInstanceMethod) GetAttr(name string) (Value, bool)
- func (bm *BoundInstanceMethod) String() string
- func (bm *BoundInstanceMethod) Type() Type
- type BoundListMethod
- type BoundMethod
- func (bm *BoundMethod) Call(args []Value, ctx *Context) (Value, error)
- func (bm *BoundMethod) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
- func (bm *BoundMethod) GetAttr(name string) (Value, bool)
- func (bm *BoundMethod) String() string
- func (bm *BoundMethod) Type() Type
- type BoundSuperMethod
- type BuiltinFunction
- func (f *BuiltinFunction) Call(args []Value, ctx *Context) (Value, error)
- func (f *BuiltinFunction) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
- func (f *BuiltinFunction) GetAttr(name string) (Value, bool)
- func (f *BuiltinFunction) GetBaseObject() *BaseObject
- func (f *BuiltinFunction) GetRegistry() *MethodRegistry
- func (f *BuiltinFunction) SetAttr(name string, value Value) error
- func (f *BuiltinFunction) String() string
- type BuiltinFunctionWithKwargs
- func (f *BuiltinFunctionWithKwargs) Call(args []Value, ctx *Context) (Value, error)
- func (f *BuiltinFunctionWithKwargs) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
- func (f *BuiltinFunctionWithKwargs) GetAttr(name string) (Value, bool)
- func (f *BuiltinFunctionWithKwargs) SetAttr(name string, value Value)
- func (f *BuiltinFunctionWithKwargs) String() string
- func (f *BuiltinFunctionWithKwargs) Type() Type
- type BuiltinMethod
- type ByteArrayValue
- func (b *ByteArrayValue) GetAttr(name string) (Value, bool)
- func (b *ByteArrayValue) GetData() []byte
- func (b *ByteArrayValue) GetItem(index int) (Value, error)
- func (b *ByteArrayValue) Iterator() Iterator
- func (b *ByteArrayValue) IteratorValue() Value
- func (b *ByteArrayValue) SetItem(index int, value Value) error
- func (b *ByteArrayValue) String() string
- func (b *ByteArrayValue) Type() Type
- type BytesValue
- type Callable
- type Channel
- func (c *Channel) Close() error
- func (c *Channel) GetAttr(name string) (Value, bool)
- func (c *Channel) GetBaseObject() *BaseObject
- func (c *Channel) GetChan() chan Value
- func (c *Channel) GetRegistry() *MethodRegistry
- func (c *Channel) Receive() (Value, error)
- func (c *Channel) Send(value Value) error
- func (c *Channel) String() string
- func (c *Channel) TryReceive() (Value, bool)
- func (c *Channel) Type() Type
- type Class
- func (c *Class) Call(args []Value, ctx *Context) (Value, error)
- func (c *Class) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
- func (c *Class) GetAttr(name string) (Value, bool)
- func (c *Class) GetClassAttr(name string) (Value, bool)
- func (c *Class) GetMethod(name string) (Value, bool)
- func (c *Class) GetMethodWithClass(name string) (Value, *Class, bool)
- func (c *Class) GetSlotIndex(name string) int
- func (c *Class) HasSlots() bool
- func (c *Class) SetAttr(name string, value Value) error
- func (c *Class) SetClassAttr(name string, value Value)
- func (c *Class) SetMethod(name string, method Value)
- func (c *Class) String() string
- func (c *Class) Type() Type
- type ClassMethodValue
- type CodeType
- type ComplexValue
- type ConstructorFunc
- type Context
- func (c *Context) DeclareGlobal(name string)
- func (c *Context) DeclareNonlocal(name string) error
- func (c *Context) Define(name string, value Value)
- func (c *Context) DefineBuiltin(name string, value Value) error
- func (c *Context) Delete(name string) error
- func (c *Context) FormatStackTrace() string
- func (c *Context) GetAllSymbols() []string
- func (c *Context) IsGlobal(name string) bool
- func (c *Context) IsNonlocal(name string) bool
- func (c *Context) Lookup(name string) (Value, error)
- func (c *Context) PopStack()
- func (c *Context) PushStack(function, file string, line, column int)
- func (c *Context) Set(name string, value Value) error
- func (c *Context) WithMetadata(metadata *IRMetadata) *Context
- type ContextManager
- type Coroutine
- type DecimalValue
- type DefaultModuleLoader
- type DictDescriptor
- type DictValue
- func (d *DictValue) Delete(key string)
- func (d *DictValue) DeleteValue(key Value) bool
- func (d *DictValue) Get(key string) (Value, bool)
- func (d *DictValue) GetAttr(name string) (Value, bool)
- func (d *DictValue) GetValue(key Value) (Value, bool)
- func (d *DictValue) Iterator() Iterator
- func (d *DictValue) Keys() []string
- func (d *DictValue) OriginalKeys() []Value
- func (d *DictValue) Set(key string, value Value)
- func (d *DictValue) SetAttr(name string, value Value) error
- func (d *DictValue) SetValue(key Value, value Value) error
- func (d *DictValue) SetWithKey(keyRepr string, origKey Value, value Value)
- func (d *DictValue) Size() int
- func (d *DictValue) String() string
- func (d *DictValue) Type() Type
- type DocEntry
- type DocRegistry
- func (r *DocRegistry) GetDoc(name string) (DocEntry, bool)
- func (r *DocRegistry) ListByModule(moduleName string) []DocEntry
- func (r *DocRegistry) ListByType(typeName string) []DocEntry
- func (r *DocRegistry) ListModules() []string
- func (r *DocRegistry) ListTypes() []string
- func (r *DocRegistry) Register(entry DocEntry)
- type EllipsisValue
- type EnhancedModuleInfo
- type EnhancedModuleRegistry
- type EvalError
- type ExceptionValue
- type File
- func (f *File) Close() error
- func (f *File) Enter() (Value, error)
- func (f *File) Exit(excType, excValue, excTraceback Value) (bool, error)
- func (f *File) GetAttr(name string) (Value, bool)
- func (f *File) GetBaseObject() *BaseObject
- func (f *File) GetRegistry() *MethodRegistry
- func (f *File) Iterator() Iterator
- func (f *File) Read(size int) (Value, error)
- func (f *File) ReadLine() (Value, error)
- func (f *File) ReadLines() (Value, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) String() string
- func (f *File) Tell() (int64, error)
- func (f *File) Type() Type
- func (f *File) Write(data string) error
- type FileContextManager
- func (f *FileContextManager) Enter() (Value, error)
- func (f *FileContextManager) Exit(excType, excValue, excTraceback Value) (bool, error)
- func (f *FileContextManager) GetAttr(name string) (Value, bool)
- func (f *FileContextManager) GetBaseObject() *BaseObject
- func (f *FileContextManager) GetRegistry() *MethodRegistry
- func (f *FileContextManager) String() string
- func (f *FileContextManager) Type() Type
- type FileIterator
- type FileNotFoundError
- type FrameType
- type FrozenSetValue
- func (fs *FrozenSetValue) Add(value Value)
- func (fs *FrozenSetValue) Contains(value Value) bool
- func (fs *FrozenSetValue) GetAttr(name string) (Value, bool)
- func (fs *FrozenSetValue) Hash() uint64
- func (fs *FrozenSetValue) Iterator() Iterator
- func (fs *FrozenSetValue) Size() int
- func (fs *FrozenSetValue) String() string
- func (fs *FrozenSetValue) Type() Type
- type Generator
- func (g *Generator) Close() (Value, error)
- func (g *Generator) GetAttr(name string) (Value, bool)
- func (g *Generator) GetBaseObject() *BaseObject
- func (g *Generator) GetCode() Value
- func (g *Generator) GetRegistry() *MethodRegistry
- func (g *Generator) GetState() GeneratorState
- func (g *Generator) Iterator() Iterator
- func (g *Generator) Next() (Value, error)
- func (g *Generator) Send(value Value) (Value, error)
- func (g *Generator) SetExecState(state GeneratorExecutor)
- func (g *Generator) SetState(state GeneratorState)
- func (g *Generator) String() string
- func (g *Generator) Throw(excType Value, excValue Value, excTb Value) (Value, error)
- func (g *Generator) Type() Type
- type GeneratorExecutor
- type GeneratorFunction
- func (gf *GeneratorFunction) Call(args []Value, ctx *Context) (Value, error)
- func (gf *GeneratorFunction) CallWithKeywords(args []Value, kwargs map[string]Value, ctx *Context) (Value, error)
- func (gf *GeneratorFunction) GetAttr(name string) (Value, bool)
- func (gf *GeneratorFunction) String() string
- func (gf *GeneratorFunction) Type() Type
- type GeneratorIterator
- type GeneratorState
- type GenericAlias
- type IRMetadata
- func (m *IRMetadata) Clear()
- func (m *IRMetadata) GetComments(val Value) []string
- func (m *IRMetadata) GetLocation(val Value) *SourceLocation
- func (m *IRMetadata) GetSyntaxKind(val Value) (int, bool)
- func (m *IRMetadata) GetTypeAnnotation(val Value) interface{}
- func (m *IRMetadata) Merge(other *IRMetadata)
- func (m *IRMetadata) SetComments(val Value, comments []string)
- func (m *IRMetadata) SetLocation(val Value, loc *SourceLocation)
- func (m *IRMetadata) SetSyntaxKind(val Value, kind int)
- func (m *IRMetadata) SetTypeAnnotation(val Value, typeInfo interface{})
- func (m *IRMetadata) Size() int
- type ImportError
- type IndexError
- type Instance
- type Iterable
- type Iterator
- type IteratorWrapper
- type KeyError
- type LispNumber
- type LispString
- type ListInstance
- type ListValue
- func (l *ListValue) Append(value Value)
- func (l *ListValue) CallMethod(name string, args []Value, ctx *Context) (Value, error)
- func (l *ListValue) Extend(values []Value)
- func (l *ListValue) GetAttr(name string) (Value, bool)
- func (l *ListValue) GetItem(index int) (Value, error)
- func (l *ListValue) Items() []Value
- func (l *ListValue) Iterator() Iterator
- func (l *ListValue) Len() int
- func (l *ListValue) SetAttr(name string, value Value) error
- func (l *ListValue) SetItem(index int, value Value) error
- func (l *ListValue) SetSlice(start, end *int, values *ListValue) error
- func (l *ListValue) String() string
- func (l *ListValue) Type() Type
- type LocatedValue
- type MRODescriptor
- type Method
- type MethodDescriptor
- type MethodEntry
- type MethodHandler
- type MethodHandlerWithKwargs
- type MethodRegistry
- func (r *MethodRegistry) GetAttr(receiver Value, name string) (Value, bool)
- func (r *MethodRegistry) RegisterMethod(entry *MethodEntry)
- func (r *MethodRegistry) RegisterMethods(entries ...*MethodEntry)
- func (r *MethodRegistry) RegisterProperties(entries ...*PropertyEntry)
- func (r *MethodRegistry) RegisterProperty(entry *PropertyEntry)
- type Module
- func (m *Module) Export(name string, value Value)
- func (m *Module) GetAllExports() []string
- func (m *Module) GetAttr(name string) (Value, bool)
- func (m *Module) GetExport(name string) (Value, bool)
- func (m *Module) SetAll(names []string)
- func (m *Module) SetAttr(name string, value Value) error
- func (m *Module) String() string
- func (m *Module) Type() Type
- type ModuleInfo
- type ModuleLoader
- type ModuleLoaderEnhanced
- type ModuleRegistry
- func (r *ModuleRegistry) AddSearchPath(path string)
- func (r *ModuleRegistry) ClearAllModules()
- func (r *ModuleRegistry) GetModule(name string) (*DictValue, bool)
- func (r *ModuleRegistry) GetModuleInfo(name string) (ModuleInfo, bool)
- func (r *ModuleRegistry) GetSearchPaths() []string
- func (r *ModuleRegistry) IsLoading(name string) bool
- func (r *ModuleRegistry) ListModules() []string
- func (r *ModuleRegistry) ReloadModule(name string) error
- func (r *ModuleRegistry) ResolveModulePath(name string) (string, error)
- func (r *ModuleRegistry) SetLoading(name string, loading bool)
- func (r *ModuleRegistry) StoreModule(name string, module *DictValue, path string, dependencies []string)
- type NameError
- type NilValue
- type NotImplementedValue
- type NumberValue
- type OSError
- type Object
- type ParamDoc
- type PrintValueProvider
- type PropertyDescriptor
- type PropertyEntry
- type PropertyGetter
- type PropertyValue
- type RangeValue
- func (r *RangeValue) Contains(value Value) bool
- func (r *RangeValue) GetAttr(name string) (Value, bool)
- func (r *RangeValue) GetBaseObject() *BaseObject
- func (r *RangeValue) GetItem(index int) (Value, error)
- func (r *RangeValue) GetRegistry() *MethodRegistry
- func (r *RangeValue) Iterator() Iterator
- func (r *RangeValue) Length() int
- func (r *RangeValue) String() string
- func (r *RangeValue) Type() Type
- type Registry
- func (r *Registry) Clear()
- func (r *Registry) Get(key string) (interface{}, bool)
- func (r *Registry) GetAll() map[string]interface{}
- func (r *Registry) GetDuplicates() map[string][]string
- func (r *Registry) Keys() []string
- func (r *Registry) MustRegister(key string, value interface{})
- func (r *Registry) Register(key string, value interface{}) error
- func (r *Registry) RegisterWithDepth(key string, value interface{}, depth int) error
- type RegistryEntry
- type SelectCase
- type SetValue
- func (s *SetValue) Add(value Value)
- func (s *SetValue) Contains(value Value) bool
- func (s *SetValue) GetAttr(name string) (Value, bool)
- func (s *SetValue) Iterator() Iterator
- func (s *SetValue) IteratorValue() Value
- func (s *SetValue) Remove(value Value) bool
- func (s *SetValue) Size() int
- func (s *SetValue) String() string
- func (s *SetValue) Type() Type
- type SimpleContextManager
- type SliceValue
- type SlotDescriptor
- type SourceLocation
- type StaticMethodValue
- type StopIteration
- type StringValue
- type Super
- type SymbolValue
- type SystemExit
- type Task
- func (t *Task) GetAttr(name string) (Value, bool)
- func (t *Task) GetBaseObject() *BaseObject
- func (t *Task) GetRegistry() *MethodRegistry
- func (t *Task) IsFinished() bool
- func (t *Task) Start(ctx *Context)
- func (t *Task) String() string
- func (t *Task) Type() Type
- func (t *Task) Wait() (Value, error)
- type TraceConfig
- type TraceEntry
- type TracebackType
- type TupleInstance
- type TupleValue
- type Type
- type TypeDescriptor
- func (td *TypeDescriptor) CallMethod(receiver Value, methodName string, args []Value, ctx *Context) (Value, error)
- func (td *TypeDescriptor) GetAttribute(receiver Value, name string) (Value, error)
- func (td *TypeDescriptor) GetAttributeNames() []string
- func (td *TypeDescriptor) GetMethod(name string) (*MethodDescriptor, bool)
- func (td *TypeDescriptor) GetProperty(name string) (*PropertyDescriptor, bool)
- func (td *TypeDescriptor) GetTypeObject() Value
- func (td *TypeDescriptor) SetAttribute(receiver Value, name string, value Value) error
- func (td *TypeDescriptor) SetTypeObject(typeObj Value)
- type TypeError
- type UnionType
- type Value
- type ValueError
- type WithContext
- type YieldFromValue
- type YieldValue
- type ZeroDivisionError
Constants ¶
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
const ( MaxSafeInt float64 = 9007199254740992 // 2^53 MinSafeInt float64 = -9007199254740992 // -2^53 )
Promotion constants for NumberValue -> BigIntValue conversion
Variables ¶
var ( True = BoolValue(true) False = BoolValue(false) )
Pre-defined boolean constants
var ( Nil = NilValue{} None = NilValue{} // Python-style alias )
Predefined nil value
var BuiltinLogging = false
BuiltinLogging controls whether to log duplicate builtin registrations
var DocRegistryInstance = NewDocRegistry()
DocRegistryInstance is the global instance of the documentation registry
var Ellipsis = EllipsisValue{}
Predefined Ellipsis value
var EmptyList = NewList()
EmptyList is a shared empty list value
var (
EmptyTuple = TupleValue{}
)
Predefined empty collections
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
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
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
var NotImplemented = &NotImplementedValue{}
Predefined NotImplemented value This is a singleton - all references should be to the same instance for identity checks
Functions ¶
func DebugLog ¶ added in v0.3.0
func DebugLog(format string, args ...interface{})
DebugLog prints debug messages only if module debug is enabled
func ErrDotMethodCallf ¶
func ErrDotMissingInterfacef ¶
func ErrDotMissingInterfacef(objType interface{}) error
func ErrDotModulePropertyf ¶
func ErrDotNestedAccessf ¶
func ErrDotNoMethodf ¶
func ErrDotNoPropertyf ¶
Helper functions to generate error instances
func ErrDotNotCallablef ¶
func ErrTooManyArgumentsf ¶
func FindModule ¶
FindModule searches for a module file in the module paths
func FormatDocEntry ¶
FormatDocEntry formats a DocEntry for display in the REPL
func FormatDocList ¶
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
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
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 IsHashable ¶
IsHashable determines if a value can be used as a dictionary key
func IsInSafeRange ¶ added in v0.3.0
IsInSafeRange checks if an integer value fits precisely in float64
func IsInstanceOf ¶
Helper function to check instance of class
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
ParseFloat attempts to parse a string as a float
func PrintValue ¶
PrintValue returns a string representation of a value
func PrintValueWithoutQuotes ¶
PrintValueWithoutQuotes returns a string representation without quotes for strings
func ProcessEscapeSequences ¶
ProcessEscapeSequences processes escape sequences in a string
func RegisterDoc ¶
func RegisterDoc(entry DocEntry)
RegisterDoc registers documentation for a symbol
func RegisterDocStrings ¶
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
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
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
ShouldPromoteToBigInt determines if a NumberValue should be promoted to BigIntValue
func TraceEnterFunction ¶ added in v0.3.0
TraceEnterFunction logs function entry
func TraceExitFunction ¶ added in v0.3.0
TraceExitFunction logs function exit
func TraceValue ¶ added in v0.3.0
TraceValue logs an arbitrary value with a label
func TraceVariable ¶ added in v0.3.0
TraceVariable logs a variable assignment
func TypedReceiver ¶ added in v0.3.0
TypedReceiver extracts and type-asserts the receiver
func ValidateArity ¶ added in v0.3.0
ValidateArity checks argument count and returns an error if invalid
func ValidateArityRange ¶ added in v0.3.0
ValidateArityRange checks argument count is within range
func ValueToKey ¶
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
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 ¶
CallMethod implements Object.CallMethod
func (*BaseObject) GetAttr ¶
func (o *BaseObject) GetAttr(name string) (Value, bool)
GetAttr implements Object.GetAttr
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
type BoundClassMethod ¶ added in v0.3.0
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
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
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
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 (*Channel) GetBaseObject ¶ added in v0.3.0
func (c *Channel) GetBaseObject() *BaseObject
GetBaseObject implements AttributeProvider
func (*Channel) GetRegistry ¶ added in v0.3.0
func (c *Channel) GetRegistry() *MethodRegistry
GetRegistry implements AttributeProvider
func (*Channel) TryReceive ¶
TryReceive attempts to receive without blocking
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 NewClassWithParents ¶
NewClassWithParents creates a new class with multiple parents
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) GetClassAttr ¶
GetClassAttr gets a class attribute
func (*Class) GetMethodWithClass ¶ added in v0.3.0
GetMethodWithClass looks up a method and returns the class where it was defined
func (*Class) GetSlotIndex ¶ added in v0.3.0
GetSlotIndex returns the index of a slot by name, or -1 if not found
func (*Class) SetClassAttr ¶
SetClassAttr sets a class attribute
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
NewCodeObject creates a new code object for a function
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 ¶
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 ¶
NewContext creates a new evaluation context
func (*Context) DeclareGlobal ¶ added in v0.3.0
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
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) DefineBuiltin ¶ added in v0.2.0
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
Delete removes a variable from the current scope Returns error if variable doesn't exist in current scope
func (*Context) FormatStackTrace ¶
FormatStackTrace returns a formatted stack trace for error reporting
func (*Context) GetAllSymbols ¶
GetAllSymbols returns all defined symbols in this context and its parents
func (*Context) IsGlobal ¶ added in v0.3.0
IsGlobal checks if a variable is declared as global in this scope
func (*Context) IsNonlocal ¶ added in v0.3.0
IsNonlocal checks if a variable is declared as nonlocal in this scope
func (*Context) PopStack ¶
func (c *Context) PopStack()
PopStack removes the most recent entry from the call stack
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
NewCoroutine creates a new coroutine
func (*Coroutine) Close ¶ added in v0.3.0
Close closes the coroutine (prevents it from being executed)
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
type DecimalValue ¶ added in v0.3.0
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
type DictValue ¶
type DictValue struct {
BaseObject
// contains filtered or unexported fields
}
DictValue represents a dictionary mapping keys to values
func (*DictValue) Delete ¶
Delete removes a key by internal representation INTERNAL: Callers should use ValueToKey() to convert keys first
func (*DictValue) DeleteValue ¶ added in v0.2.0
DeleteValue removes a key by M28 value (handles conversion) This is the preferred public API for deleting dict values
func (*DictValue) Get ¶
Get retrieves a value by internal key representation INTERNAL: Callers should use ValueToKey() to convert keys first
func (*DictValue) GetValue ¶ added in v0.2.0
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
Iterator implements Iterable for dicts (iterates over keys)
func (*DictValue) Keys ¶
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
OriginalKeys returns all original key values (not internal representations) This is what dict.keys() method uses
func (*DictValue) Set ¶
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) SetValue ¶ added in v0.2.0
SetValue sets a value by M28 value key (handles conversion) This is the preferred public API for setting dict values
func (*DictValue) SetWithKey ¶
SetWithKey sets a value with both key representation and original key This is the preferred method for setting dict values
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 ListByModule ¶
ListByModule is a convenience function for accessing the global registry
func ListByType ¶
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 ¶
WrapEvalError wraps an existing error with evaluation context
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 (*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
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
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 ¶
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) GetBaseObject ¶ added in v0.3.0
func (g *Generator) GetBaseObject() *BaseObject
GetBaseObject implements AttributeProvider
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) 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
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 ¶
NewInstance creates a new instance of a class
func (*Instance) DelAttr ¶ added in v0.3.0
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 ¶
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 ¶
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__
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
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 (*ListValue) CallMethod ¶
CallMethod implements Object.CallMethod
func (*ListValue) Items ¶ added in v0.3.0
Items returns a copy of the underlying slice (for safe iteration)
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
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 ¶
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 (*Module) GetAllExports ¶
GetAllExports returns all exported names
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
type NilValue ¶
type NilValue struct{}
NilValue represents a nil/null/None value
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
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
NewOSError creates a new OS error
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
PropertyGetter is the function signature for property getters
type PropertyValue ¶ added in v0.3.0
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
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) GetDuplicates ¶ added in v0.2.0
GetDuplicates returns a map of keys that have been registered multiple times
func (*Registry) MustRegister ¶ added in v0.2.0
MustRegister is like Register but panics on error
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 (*SetValue) IteratorValue ¶ added in v0.3.0
IteratorValue returns the iterator as a Value
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
SliceValue represents a slice object with start, stop, and step
func (*SliceValue) CallMethod ¶ added in v0.2.0
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
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 ¶
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
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 NewSuperForClass ¶ added in v0.3.0
NewSuperForClass creates a new super object for class methods and __new__
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 (*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 ¶
IsFinished checks if the task has completed
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 ¶
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
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 ¶
NewTypeError creates a new type error
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
NewUnionType creates a new 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
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
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
Source Files
¶
- async.go
- class.go
- containers.go
- context.go
- context_manager.go
- context_manager_base.go
- decorators.go
- dict_methods.go
- doc_registry.go
- dot_errors.go
- error.go
- file.go
- generator.go
- lisp_number.go
- lisp_string.go
- list_methods.go
- located_value.go
- metadata.go
- method_registry.go
- module.go
- module_loader.go
- module_loader_enhanced.go
- module_paths.go
- module_registry.go
- primitives.go
- printValueOverride.go
- range.go
- registry.go
- repr.go
- set_methods.go
- slots.go
- string_methods.go
- trace.go
- type_descriptor.go
- type_registry.go
- type_registry_concurrent.go
- type_registry_dict.go
- type_registry_file.go
- type_registry_frozenset.go
- type_registry_list.go
- type_registry_objects.go
- type_registry_primitives.go
- type_registry_refactored.go
- type_registry_set.go
- type_registry_string.go
- type_registry_tuple.go
- utilities.go
- value.go
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. |