Documentation
¶
Index ¶
- Constants
- func RunFunction(fn *types.Function, args []types.Object, globals map[string]types.Object) error
- func RunFunctionInNewVM(fn *types.Function, args []types.Object, parentVM *VM) error
- type DeferredCall
- type Frame
- type HTTPResponse
- type Module
- type Stack
- func (s *Stack) Clear()
- func (s *Stack) Peek() types.Object
- func (s *Stack) PeekN(n int) types.Object
- func (s *Stack) PeekNSafe(n int) (types.Object, error)
- func (s *Stack) PeekSafe() (types.Object, error)
- func (s *Stack) Pop() types.Object
- func (s *Stack) PopN(n int) []types.Object
- func (s *Stack) PopSafe() (types.Object, error)
- func (s *Stack) Push(o types.Object) error
- func (s *Stack) SetSize(size int)
- func (s *Stack) Size() int
- type StackOverflowError
- type StackUnderflowError
- type TryFrame
- type VM
- func (vm *VM) Constants() []bytecode.Constant
- func (vm *VM) CopyGlobals() map[string]types.Object
- func (vm *VM) GetModuleExport(module *Module, exportName string) (types.Object, bool)
- func (vm *VM) Globals() map[string]types.Object
- func (vm *VM) LoadModule(modulePath string) (*Module, error)
- func (vm *VM) NewVMWithSharedGlobals(parent *VM) *VM
- func (vm *VM) Run() error
- func (vm *VM) RunFunctionShared(fn *types.Function, args []types.Object) error
- func (vm *VM) SetArgs(args []string)
- func (vm *VM) SetGlobals(globals map[string]types.Object)
- func (vm *VM) Stack() *Stack
Constants ¶
const MaxCallStackDepth = 1024 // Maximum depth of call stack (prevents stack overflow from infinite recursion)
const MaxStackSize = 1024 * 1024 // 1MB stack
Variables ¶
This section is empty.
Functions ¶
func RunFunction ¶
RunFunction executes a function with the given arguments in a new VM This is used for thread execution with isolated state
Types ¶
type DeferredCall ¶
type DeferredCall struct {
// contains filtered or unexported fields
}
DeferredCall represents a function call to be executed later
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame represents a call frame (activation record) for a function execution
func NewFrame ¶
func NewFrame(fn *bytecode.FunctionConstant, basePointer int) *Frame
NewFrame creates a new call frame for a function
func NewFrameFromFunction ¶
NewFrameFromFunction creates a new frame from a runtime Function object
func (*Frame) CurrentInstruction ¶
CurrentInstruction returns the opcode at the current IP
func (*Frame) Instructions ¶
Instructions returns the bytecode instructions of the function
func (*Frame) ReadUint8 ¶
ReadUint8 reads an 8-bit operand from the instruction stream and advances IP
func (*Frame) ReadUint16 ¶
ReadUint16 reads a 16-bit operand from the instruction stream and advances IP
type HTTPResponse ¶
HTTPResponse represents an HTTP response
func (*HTTPResponse) ToStr ¶
func (r *HTTPResponse) ToStr() string
func (*HTTPResponse) TypeCode ¶
func (r *HTTPResponse) TypeCode() uint8
func (*HTTPResponse) TypeName ¶
func (r *HTTPResponse) TypeName() string
type Module ¶
type Module struct {
Name string
Path string
Exports map[string]types.Object // Exported symbols from the module
}
Module represents a loaded Nxlang module
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents the operand stack used by the VM
type StackOverflowError ¶
type StackOverflowError struct{}
StackOverflowError is returned when the stack exceeds its maximum size
func (*StackOverflowError) Error ¶
func (e *StackOverflowError) Error() string
type StackUnderflowError ¶
type StackUnderflowError struct{}
StackUnderflowError is returned when trying to pop from an empty stack
func (*StackUnderflowError) Error ¶
func (e *StackUnderflowError) Error() string
type TryFrame ¶
type TryFrame struct {
// contains filtered or unexported fields
}
TryFrame represents an active try/catch/finally block
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM represents the Nxlang virtual machine
func (*VM) CopyGlobals ¶
CopyGlobals returns a copy of the global variables map
func (*VM) GetModuleExport ¶
GetModuleExport gets an exported value from a module
func (*VM) LoadModule ¶
LoadModule loads a module by path
func (*VM) NewVMWithSharedGlobals ¶
NewVMWithSharedGlobals creates a new VM that shares globals with the parent VM Used for shared mode thread execution
func (*VM) RunFunctionShared ¶
RunFunctionShared executes a function with the given arguments sharing the VM's globals This is used for thread execution with shared state
func (*VM) SetGlobals ¶
SetGlobals sets the global variables map