Documentation
¶
Overview ¶
Package evm implements a register VM for compiled Go programs. Its bytecode is trusted input, not a sandbox boundary or a persisted compatibility format.
Code generated by go generate. DO NOT EDIT.
Immutable KVO records travel as cells and borrow storage until the compiler inserts an ownership copy. Mutable editors remain bound to a RecordScope.
Index ¶
- Constants
- Variables
- func RecordScalarType(t kvo.AnyType) *values.Type
- func RecordWordType(p kvo.PropImpl) *values.Type
- func StandardLibraryPaths() []string
- func StandardLibrarySource(path string) (string, bool)
- func ValidateDirectBindings(packages []Package) error
- func ValidateShape(s *values.Shape) error
- type BorrowSource
- type Budget
- type BudgetScope
- type Call
- func (c *Call) AllocCells(n uint64) (unsafe.Pointer, error)
- func (c *Call) Argument(i int) values.Value
- func (c *Call) ChargeAllocation(bytes uint64) error
- func (c *Call) EncodeJSON(v values.Value, limit int) (json.RawMessage, error)
- func (c *Call) EncodeJSONObject(v values.Value, limit int) (json.RawMessage, error)
- func (c *Call) FlushRecord(editor *kvo.Editor) error
- func (c *Call) IncreaseCPUBudget(ms uint64) error
- func (c *Call) IncreaseMemBudget(bytes, allocs uint64) error
- func (c *Call) Interface(slot int) (*values.Type, values.Value, error)
- func (c *Call) JSONValue(v values.Value, limit int) (any, error)
- func (c *Call) NarrowBudget(steps uint64, duration time.Duration) *BudgetScope
- func (c *Call) NarrowCPUBudget(soft, hard time.Duration) *BudgetScope
- func (c *Call) Program() *Program
- func (c *Call) RecordValue(model *kvo.Model, m kvo.Record) (values.Value, error)
- func (c *Call) RunCallback(v values.Value) (err error)
- func (c *Call) SetEditRecordResult(model *kvo.Model, e *kvo.Editor) error
- func (c *Call) SetInterface(slot int, t *values.Type, v values.Value) (err error)
- func (c *Call) SetReadRecordResult(model *kvo.Model, m row2.View) error
- func (c *Call) SetRecordResult(model *kvo.Model, m kvo.Record) error
- func (c *Call) SetResult(i int, v values.Value)
- func (c *Call) SetValue(slot int, v values.Value)
- func (c *Call) Value(slot int) values.Value
- type CaptureSlot
- type Closure
- type Conversion
- type DeferKind
- type DeferOp
- type DirectBinding
- type DirectFunc
- type DynamicMethod
- type DynamicType
- type ExecutionError
- type ExtendedKind
- type ExtendedOp
- type ExternalConstant
- type ExternalFunction
- type ExternalMethod
- type Function
- type FunctionRef
- type Import
- type Instruction
- type Invoke
- type JSONTypes
- type Layout
- type Limits
- type Module
- type NamedFunction
- type Native
- type NumericKind
- type NumericType
- type Opcode
- type Operand
- type OwnershipEffects
- type OwnershipSite
- type Package
- type PanicError
- type Program
- func (p *Program) DisassembleFloatLoops() string
- func (p *Program) EncodeJSON(ctx context.Context, v values.Value, limit int) (json.RawMessage, error)
- func (p *Program) InterfaceType(v values.Value) *values.Type
- func (p *Program) JSONValue(ctx context.Context, v values.Value, limit int) (any, error)
- func (p *Program) NamedFunction(v values.Value) (*NamedFunction, error)
- func (p *Program) PackInterface(t *values.Type, v values.Value) (values.Value, error)
- func (p *Program) PointerInterface(t *values.Type, ptr unsafe.Pointer) (values.Value, error)
- func (p *Program) Shape(t *values.Type) *values.Shape
- func (p *Program) UnpackInterface(v values.Value) (*values.Shape, values.Value, error)
- type RecordScope
- func (s *RecordScope) Close()
- func (s *RecordScope) Edit(model *kvo.Model, m *row2.Editor) values.Value
- func (s *RecordScope) EditRecord(model *kvo.Model, m *kvo.Editor) values.Value
- func (s *RecordScope) Mutable(v values.Value, model *kvo.Model) (*row2.Editor, error)
- func (s *RecordScope) MutableRecord(v values.Value, model *kvo.Model) (*kvo.Editor, error)
- func (s *RecordScope) Read(model *kvo.Model, m row2.View) values.Value
- func (s *RecordScope) ReadRecord(model *kvo.Model, m kvo.Record) values.Value
- type RecordType
- type ScopeEnd
- type ScopedCallback
- type SharedType
- type Signature
- type SourcePosition
- type TypeDecl
- type VM
Constants ¶
const RecordListDirect uint8 = 1
RecordListDirect fuses a single adjacent len/index consumer with its property read. No list value escapes the instruction, so no VM temporary is needed.
const VMFieldBase = kvo.RuntimePropBase
VMFieldBase separates VM layout fields from persistent KVO property codes.
Variables ¶
var ( ErrSteps = errors.New("instruction limit exceeded") ErrDepth = errors.New("call depth limit exceeded") ErrRegisters = errors.New("register limit exceeded") ErrDivideByZero = errors.New("integer division by zero") ErrAllocations = errors.New("allocation count limit exceeded") ErrAllocation = errors.New("allocation budget exceeded") ErrNegativeShift = errors.New("negative shift amount") ErrInvalidState = errors.New("VM session failed; call Reset before reuse") ErrNilFunction = errors.New("call of nil function") ErrFunction = errors.New("invalid function value") ErrReentry = errors.New("VM is already running") )
var ( ErrNil = errors.New("nil pointer dereference") ErrBounds = errors.New("index or slice bounds out of range") ErrNilMap = errors.New("assignment to nil map") )
var ErrDeferStack = errors.New("defer stack is no longer active")
var ErrOutput = errors.New("output limit exceeded")
var ErrTypeAssertion = errors.New("interface conversion failed")
var JSONObjectType = values.NewType("map[string]interface{}", values.Pointer)
JSONObjectType is shared by native packages that exchange JSON objects.
Functions ¶
func RecordScalarType ¶
RecordScalarType supplies the VM type for KVO leaves.
func RecordWordType ¶
RecordWordType maps a scalar KVO property to its script type.
func StandardLibraryPaths ¶
func StandardLibraryPaths() []string
StandardLibrarySource supplies a virtual package to the compiler. Libraries have no globals; only reachable functions become part of a linked Program.
func StandardLibrarySource ¶
func ValidateDirectBindings ¶
ValidateDirectBindings checks register conventions against the declared packages. A compiler schema may omit implementations until Link binds it to a host.
func ValidateShape ¶
ValidateShape checks native declaration storage before the compiler builds Go types. It accepts recursive pointer graphs and rejects recursive value storage.
Types ¶
type BorrowSource ¶
BorrowSource declares a result whose storage is valid within a scope. ScopeParameter is zero for the enclosing scope, or the one-based argument index identifying it (including the receiver for methods). Domain names are binding-defined identities, e.g. "edb.transaction".
type Budget ¶
type Budget struct {
Steps, Allocations, AllocationBytes uint64
Duration time.Duration // soft wall-clock limit for the invocation
HardDuration time.Duration
HardAllocations, HardAllocationBytes uint64
UnlimitedSteps bool
}
Budget applies to one RunWithBudget call, including first-use initialization. Zero fields inherit VM defaults. Allocation limits also obey the remaining session allowance configured by VM.Limits.
type BudgetScope ¶
type BudgetScope struct {
// contains filtered or unexported fields
}
BudgetScope temporarily restricts the running invocation. A scope may span several external calls. Only the innermost scope can be closed.
func (*BudgetScope) BorrowRecords ¶
func (s *BudgetScope) BorrowRecords(c *Call) *RecordScope
BorrowRecords opens a transaction-local record scope inside this budget.
func (*BudgetScope) End ¶
func (s *BudgetScope) End(c *Call) error
End checks the section before restoring the parent limits. Call it before committing external effects. An exhausted scope also fails the invocation.
type Call ¶
type Call struct {
Context context.Context
Position SourcePosition
R []uint64
P []unsafe.Pointer
// contains filtered or unexported fields
}
Call borrows an in-place argument/result window for this native call. Read parameters before overwriting result slots. Do not retain Call or its slices, and do not reenter this VM. Independent VMs may run concurrently.
func (*Call) ChargeAllocation ¶
ChargeAllocation accounts for native result payloads retained by the VM.
func (*Call) EncodeJSON ¶
EncodeJSON encodes an any argument from this invocation.
func (*Call) EncodeJSONObject ¶
EncodeJSONObject encodes a statically typed map[string]any argument.
func (*Call) FlushRecord ¶
FlushRecord applies edits made through Go map and slice aliases before the external database saves this one row. Repeated saves see subsequent edits.
func (*Call) IncreaseCPUBudget ¶
IncreaseCPUBudget adds wall time to the current scope, capped by the host.
func (*Call) IncreaseMemBudget ¶
IncreaseMemBudget raises the invocation allowance without resetting usage.
func (*Call) Interface ¶
Interface reads a native argument by ABI slot, preserving nil versus typed nil. Returned values and type identities belong to this Program.
func (*Call) JSONValue ¶
JSONValue also meters the materialized tree against this invocation's budget.
func (*Call) NarrowBudget ¶
func (c *Call) NarrowBudget(steps uint64, duration time.Duration) *BudgetScope
NarrowBudget starts a scope at the current external call. Zero leaves that limit alone. All work still counts against the enclosing budgets.
func (*Call) NarrowCPUBudget ¶
func (c *Call) NarrowCPUBudget(soft, hard time.Duration) *BudgetScope
NarrowCPUBudget starts an adjustable time scope. Enclosing limits still apply. Memory is charged to the invocation, including across transaction scopes.
func (*Call) RecordValue ¶
RecordValue returns the immutable row cell without allocating a handle.
func (*Call) RunCallback ¶
RunCallback runs a borrowed func() on the native call's goroutine. Its registers are separate so Go can keep using the original Call window. Globals, captured cells, transaction scopes and all budgets stay shared.
func (*Call) SetEditRecordResult ¶
SetEditRecordResult returns a transaction-bound editor and meters its handle.
func (*Call) SetInterface ¶
SetInterface writes an interface result by ABI slot. Dynamic types must be declared in the wrapper's DynamicTypes (or used by source) before linking. Boxing and value copies are charged to this execution's allocation budget.
func (*Call) SetReadRecordResult ¶
SetReadRecordResult returns one immutable KVO row from a host function. The compiler owns the payload when it escapes its borrowing boundary.
type CaptureSlot ¶
type Conversion ¶
type Conversion struct{ From, To NumericType }
type DeferOp ¶
type DeferOp struct {
Kind DeferKind
Target FunctionRef
Function Operand
Signature uint32
Invoke uint32
Receiver uint16 // Pair register captured by DeferInvoke.
Args []Operand
ExternalStack bool
}
DeferOp describes values to capture now, then invoke when its owner exits. ExternalStack selects the Raw stack handle in the instruction's A operand.
type DirectBinding ¶
type DirectBinding struct {
Op Opcode
Call DirectFunc
// Window also exposes the ordinary R/P argument window through Call.
// Generated package functions use it for their leading *evm.Call.
Window bool
// contains filtered or unexported fields
}
DirectBinding binds a small external operation with zero or one result. Call receives arguments in declaration order, receiver first. Missing arguments are zero. Its value result is ignored for a void operation. Its error result reports VM or conversion failures. Fallible APIs use Native. Op alone is sufficient in the package supplied to the compiler. Methods may use a function opcode with their receiver as argument zero; this supports pair-valued receivers such as immutable KVO records.
func DirectUnary ¶
func DirectUnary(fn func(uint64) uint64) DirectBinding
DirectUnary binds an infallible word-to-word operation through DirectBinding. Direct calls use a specialized instruction; indirect and deferred calls use the same declaration and ordinary ABI. The returned binding is immutable registration metadata. Use DirectBinding directly for Call/context access.
type DynamicMethod ¶
type DynamicMethod struct {
ID string
Signature Signature
Variadic bool
Function FunctionRef
}
type DynamicType ¶
type DynamicType struct {
Shape *values.Shape
Methods []DynamicMethod
}
DynamicType defines a concrete interface payload. Indexes belong to a Program.
type ExecutionError ¶
type ExecutionError struct {
Function string
PC int
Position SourcePosition
Err error
}
ExecutionError retains the source location and wrapped host/VM error.
func (*ExecutionError) Error ¶
func (e *ExecutionError) Error() string
func (*ExecutionError) Unwrap ¶
func (e *ExecutionError) Unwrap() error
type ExtendedKind ¶
type ExtendedKind uint8
const ( ExtendedMakeInterface ExtendedKind = iota + 1 ExtendedTypeAssert ExtendedFieldAddr ExtendedField ExtendedIndexAddr ExtendedIndex ExtendedSlice ExtendedMakeSlice ExtendedSliceToArray ExtendedMakeMap ExtendedLookup ExtendedMapUpdate ExtendedDelete ExtendedClear ExtendedLen ExtendedCap ExtendedAppend ExtendedCopy ExtendedRange ExtendedNext ExtendedConvert ExtendedEqual ExtendedComplex ExtendedReal ExtendedImag ExtendedComplexBinary ExtendedComplexNegate ExtendedMinMax ExtendedGetKey ExtendedSetKey ExtendedGetChildKey ExtendedPackedArray ExtendedPackedLoad ExtendedPackedStore ExtendedAddressLoad ExtendedAddressStore ExtendedFieldStore ExtendedNativeAlloc ExtendedOwn ExtendedRecordCopy ExtendedRecordList ExtendedRecordListLen ExtendedRecordListIndex )
type ExtendedOp ¶
type ExtendedOp struct {
Record *RecordType
Kind ExtendedKind
Shape *values.Shape
Source *values.Shape
In, Out []Operand
Index uint64
ChildKey uint64 // leaf property for ExtendedGetChildKey
Flags uint8
Packed bool // Local slice/array backing uses the element's scalar bank.
// contains filtered or unexported fields
}
ExtendedOp is an immutable bytecode operand descriptor, not an executable callback. BC selects it for operations needing more than three operands.
type ExternalConstant ¶
type ExternalFunction ¶
type ExternalFunction struct {
Ownership *OwnershipEffects
// ParamNames preserves declaration names for source frontends such as GoX.
ParamNames []string
Direct DirectBinding
// On exposes a receiver-free operation as pkg.Record.Operation(args).
On *RecordType
Variadic bool
// DynamicTypes declares concrete interface results produced by this wrapper.
DynamicTypes []*values.Type
Name string
Signature Signature
Call Native
// contains filtered or unexported fields
}
func BindStandardFunction ¶
func BindStandardFunction(path, name string, signature Signature) (*ExternalFunction, bool)
BindStandardFunction binds a compiler-checked virtual library primitive. Signatures come from the virtual package, never from reflected Go functions.
func (*ExternalFunction) LinkName ¶
func (f *ExternalFunction) LinkName() string
LinkName identifies the function in imports and disassembly.
type ExternalMethod ¶
type ExternalMethod struct {
Ownership *OwnershipEffects
Direct DirectBinding
Name string
Receiver *values.Type
Signature Signature
Variadic bool
Call Native
DynamicTypes []*values.Type
}
ExternalMethod has a receiver-free source signature. Its native ABI prepends Receiver to the argument list, reserving incoming V0 via ParameterLayout.
type Function ¶
type Function struct {
// OwnershipSites describes compiler-emitted clone locations before linking.
OwnershipSites []OwnershipSite
// LocalRecordReads marks instructions whose result cannot outlive its next execution in this frame.
LocalRecordReads map[int]bool
Method bool // The first parameter is the receiver.
// RecoverPC is a bytecode PC plus one; zero means no recovery continuation.
RecoverPC uint32
// RecoverTransparent marks compiler-generated receiver forwarding wrappers.
RecoverTransparent bool
Captures []CaptureSlot
Internal bool // Generated functions are callable by bytecode only.
Name string
Position SourcePosition
Signature Signature
// RCount/PCount cover this function's parameters, results and locals.
// Outgoing arguments/results follow them and are sized by the linker.
RCount, PCount int
Code []Instruction
// Lines is optional; when present it has one source line per instruction.
Lines []int
Positions []SourcePosition
}
type FunctionRef ¶
FunctionRef selects a linked code or host function. Function values store its module-local index plus one in R, with zero reserved for nil.
type Import ¶
type Import struct {
Ownership *OwnershipEffects
Receiver *values.Type
Package, Name string
Signature Signature
}
type Instruction ¶
type Instruction uint64
Instruction is one 64-bit word with its opcode in the low 16 bits. Most opcodes have three 16-bit operands. ABCD12 uses four 12-bit operands. WithBC combines B and C into 32 bits. Branches use a signed displacement from the following instruction. Constants live in separate pools.
func ABC ¶
func ABC(op Opcode, a, b, c uint16) Instruction
func ABCD12 ¶
func ABCD12(op Opcode, a, b, c, d uint16) Instruction
ABCD12 packs four 12-bit operands above the ordinary opcode.
func (Instruction) A ¶
func (i Instruction) A() uint16
func (Instruction) ABCD12 ¶
func (i Instruction) ABCD12() (a, b, c, d uint16)
func (Instruction) B ¶
func (i Instruction) B() uint16
func (Instruction) BC ¶
func (i Instruction) BC() uint32
func (Instruction) C ¶
func (i Instruction) C() uint16
func (Instruction) Op ¶
func (i Instruction) Op() Opcode
func (Instruction) SignedD12 ¶
func (i Instruction) SignedD12() int
type JSONTypes ¶
type JSONTypes struct{ Boolean, Integer, Unsigned, Float, String, Array, Object uint32 }
JSONTypes identifies the concrete types a KVO JSON value can produce.
type Layout ¶
Layout allocates V pairs first, then independent R and P slots. Slots retains source order, so a wrapper can derive its ABI once during registration.
type Module ¶
type Module struct {
JSONTypes JSONTypes
// NoOptimization disables optional linker rewrites. The compiler sets this for debug modules.
NoOptimization bool
// StrictCallWindows promises that callers only observe declared results after a script call.
StrictCallWindows bool
// Sources holds original text keyed by source-position filename for optional disassembly comments.
Sources map[string]string
Defers []DeferOp
Types []DynamicType // concrete interface types indexed by R; slot zero, if present, must be empty
Invokes []Invoke
FunctionRefs []FunctionRef
Closures []Closure
Signatures []Signature
Functions []Function
Imports []Import
Words []uint64
Strings []string
Conversions []Conversion
Shapes []*values.Shape
ExtendedOps []ExtendedOp
Globals []*values.Shape
Init string
}
func (*Module) Disassemble ¶
Disassemble lists all functions in compiled module order, with source lines and decoded operands.
func (*Module) DisassembleFunction ¶
DisassembleFunction lists the function at the given module index.
type NamedFunction ¶
NamedFunction identifies a public, noncapturing guest function. It contains no VM state and may be retained by a host registration after the call returns.
type NumericKind ¶
type NumericKind uint8
const ( NumericSigned NumericKind = iota + 1 NumericUnsigned NumericFloat )
type NumericType ¶
type NumericType struct {
Kind NumericKind
Bits uint8
}
type Opcode ¶
type Opcode uint16
const ( OpConst Opcode = iota + 1 OpString OpMoveR OpMoveP OpMoveV OpClearP OpAddI64 OpSubI64 OpMulI64 OpDivI64 OpDivU64 OpRemI64 OpRemU64 OpAddF64 OpSubF64 OpMulF64 OpDivF64 OpAnd OpOr OpXor OpShl OpShrI64 OpShrU64 OpEqR OpEqP OpLtI64 OpLtU64 OpEqF64 OpLtF64 OpJump OpJz OpJnz OpCallFunc OpCallHost OpReturn OpConvert OpCheckShift OpAddF32 OpSubF32 OpMulF32 OpDivF32 OpEqF32 OpLtF32 OpConcatStr OpEqStr OpLtStr OpAlloc OpLoad OpStore OpExtended OpGlobal OpFunction OpClosure OpCallVirt OpCallIndirect OpCheckNil OpDeferStack OpDefer OpRunDefers OpPanic OpRecover OpLoopLtI64 OpCallHostRR OpCallHostRP OpJNil OpJNotNil OpLoadIndexR OpStoreIndexR OpLeI64 OpLeU64 OpMulAddF64 OpAddMulF64 OpSubAddF64 OpLoopAddLtI64 OpLoopAddLeI64 OpAddImmI64 OpLoopLeI64 // Direct external calls. Each suffix names its explicit arguments, then its result. OpCallHostU OpCallHostS OpCallHostP OpCallHostUU OpCallHostUS OpCallHostUP OpCallHostSU OpCallHostSS OpCallHostSP OpCallHostPU OpCallHostPS OpCallHostPP OpCallHostUUU OpCallHostUUS OpCallHostUUP OpCallHostUSU OpCallHostUSS OpCallHostUSP OpCallHostUPU OpCallHostUPS OpCallHostUPP OpCallHostSUU OpCallHostSUS OpCallHostSUP OpCallHostSSU OpCallHostSSS OpCallHostSSP OpCallHostSPU OpCallHostSPS OpCallHostSPP OpCallHostPUU OpCallHostPUS OpCallHostPUP OpCallHostPSU OpCallHostPSS OpCallHostPSP OpCallHostPPU OpCallHostPPS OpCallHostPPP OpCallHostMethodU OpCallHostMethodS OpCallHostMethodP OpCallHostMethodUU OpCallHostMethodUS OpCallHostMethodUP OpCallHostMethodSU OpCallHostMethodSS OpCallHostMethodSP OpCallHostMethodPU OpCallHostMethodPS OpCallHostMethodPP OpLoadIndexByte OpStoreIndexByte OpLoadIndexWord OpStoreIndexWord OpLoadIndexPtr OpStoreIndexPtr // Side-effecting direct calls; V means no result. A and B are read-only. OpCallHostV OpCallHostUV OpCallHostSV OpCallHostPV OpCallHostUUV OpCallHostUSV OpCallHostUPV OpCallHostSUV OpCallHostSSV OpCallHostSPV OpCallHostPUV OpCallHostPSV OpCallHostPPV OpCallHostMethodV OpCallHostMethodUV OpCallHostMethodSV OpCallHostMethodPV )
func HostCallOpcode ¶
HostCallOpcode selects a direct instruction from its explicit argument and result banks. Pair means string; Pointer means a true pointer or a record token. A zero result selects a void operation.
func UnaryHostOpcode ¶
UnaryHostOpcode selects the fused argument move, external call and result move.
func (Opcode) HostRegisters ¶
HostRegisters supplies the disassembly and assembler prefixes. When a tied operand crosses R/P, print the result bank, except that a string always prints V.
func (Opcode) TiedHostArgument ¶
TiedHostArgument returns the source argument that must occupy A, counting the receiver as argument zero. Void calls read A without overwriting it.
type OwnershipEffects ¶
type OwnershipEffects struct {
NoRetain bool
NoInvalidate bool
Borrowed []BorrowSource
Ends []ScopeEnd
Callbacks []ScopedCallback
}
OwnershipEffects describes host behavior for compiler ownership analysis. A nil declaration is conservative: the call may retain arguments and end scopes. Ends lists specific invalidations; NoInvalidate forbids all of them. Borrowed results must support ownership copying. Unknown aliasing may cause acquisition-time copying, reported in Function.OwnershipSites.
func (*OwnershipEffects) Clone ¶
func (e *OwnershipEffects) Clone() *OwnershipEffects
func (*OwnershipEffects) Equal ¶
func (e *OwnershipEffects) Equal(other *OwnershipEffects) bool
func (*OwnershipEffects) Validate ¶
func (e *OwnershipEffects) Validate(sig Signature) error
type OwnershipSite ¶
type Package ¶
type Package struct {
Source string
Records []*RecordType
// EntryTypes are native concrete types that may enter in interface arguments to Run.
EntryTypes []*values.Type
Types []TypeDecl
Methods []ExternalMethod
Path string
Functions []ExternalFunction
Constants []ExternalConstant
}
func ModelPackage ¶
ModelPackage declares read and edit handles for every entity in a completed KVO schema. Register once and share its type identities across compilations. Database operations are supplied separately by the host.
func TimePackage ¶
func TimePackage() Package
TimePackage exposes the database's timestamp cell as time.Time. It is linked automatically, so record fields and host methods share the same nominal type.
func (*Package) OwnsMethodReceiver ¶
OwnsMethodReceiver reports whether t is a named concrete type declared by p, or an explicitly declared pointer to one.
type PanicError ¶
type PanicError struct {
Type *values.Type
Value values.Value
// contains filtered or unexported fields
}
PanicError exposes the concrete value of an uncaught explicit Go panic. Type is external metadata; Value is the unboxed payload belonging to this Program.
func (*PanicError) Error ¶
func (e *PanicError) Error() string
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is an immutable linked snapshot. Registration and symbol lookup stay outside the execution loop. Independent VMs may share a Program if its native wrappers support concurrent use.
func (*Program) DisassembleFloatLoops ¶
DisassembleFloatLoops lists the private execution plans chosen by Link. The module's source listing and instruction PCs remain valid.
func (*Program) EncodeJSON ¶
func (p *Program) EncodeJSON(ctx context.Context, v values.Value, limit int) (json.RawMessage, error)
EncodeJSON encodes a script's any value. Objects have string keys. Arrays and slices are JSON arrays. The byte limit also bounds expansion of shared subtrees. Unsupported types and cycles fail without exposing VM pointers.
func (*Program) JSONValue ¶
JSONValue projects a script's any value directly into an owned Go JSON tree. Numbers are json.Number, preserving the encoder's exact spelling and precision. The limit is the equivalent JSON byte length, including escaped strings.
func (*Program) NamedFunction ¶
func (p *Program) NamedFunction(v values.Value) (*NamedFunction, error)
NamedFunction resolves a function passed through an interface. Captures, methods and native functions cannot become independently callable entries.
func (*Program) PackInterface ¶
PackInterface prepares a host input. The caller owns allocation limits and snapshots aggregate values before passing them here. Native results should use Call.SetInterface, which charges the active VM budget.
func (*Program) PointerInterface ¶
PointerInterface packs a trusted native pointer for an interface argument to Run. The type must be registered by the host and linked into this particular program.
type RecordScope ¶
type RecordScope struct {
// contains filtered or unexported fields
}
func WithRecords ¶
func WithRecords(ctx context.Context) (context.Context, *RecordScope)
WithRecords binds mutable editors to one transaction. Close the scope before ending the transaction. Immutable reads do not need a scope.
func (*RecordScope) Close ¶
func (s *RecordScope) Close()
func (*RecordScope) EditRecord ¶
func (*RecordScope) MutableRecord ¶
func (*RecordScope) ReadRecord ¶
type RecordType ¶
type RecordType struct {
// SchemaView exposes the properties supported by the current KVO codec.
SchemaView bool
Name string
Model *kvo.Model
Mutable bool
Pointer *values.Type // guest *Model: Pair for immutable cells, Pointer for editors
}
func NewRecordType ¶
func NewRecordType(name string, model *kvo.Model, mutable bool) *RecordType
type ScopedCallback ¶
ScopedCallback is invoked synchronously inside a newly established scope; the host closes that scope after the callback returns or unwinds.
type SharedType ¶
type SharedType struct {
}
SharedType maps a host scalar to a type declared in Package.Source. Its methods are compiled from that same source.
type SourcePosition ¶
type TypeDecl ¶
type TypeDecl struct {
// ScalarBase distinguishes Go int from int64 when their storage shapes match.
ScalarBase *values.Type
Name string
Shape *values.Shape
}
TypeDecl exposes a named type, or an unnamed support type when Name is empty. Shape is declarative storage; native wrappers use the same cells as VM code.
type VM ¶
type VM struct {
// Output receives fmt/log/debug output. Nil uses the normal Go logger.
Output func(string) error
Limits Limits
// contains filtered or unexported fields
}
VM owns reusable execution storage. It is neither concurrent nor reentrant. Zero limit fields select defaults; positive fields override them.
func (*VM) Reset ¶
Reset discards session globals and initialization state, and releases retained pointers. A failed or interrupted session must be reset before it can run again.
Source Files
¶
- budget_scope.go
- callback.go
- defer.go
- defer_run.go
- disassemble.go
- entry_function.go
- environment.go
- evm.go
- extended.go
- extended_run.go
- floatloop.go
- floatloop_run.go
- function.go
- hostcall.go
- instruction.go
- interface.go
- json.go
- native_binding.go
- native_fields.go
- native_interface.go
- ownership.go
- panic.go
- position.go
- program.go
- rawinit.go
- record_json.go
- record_values.go
- records.go
- scalar.go
- slicestorage.go
- stdlib.go
- stdlib_format.go
- stdlib_math.go
- stdlib_signatures.go
- stdlib_strconv.go
- stdlib_strings.go
- time.go
Directories
¶
| Path | Synopsis |
|---|---|
|
bench
|
|
|
internal/mathwork
Package mathwork holds the independent numeric workloads.
|
Package mathwork holds the independent numeric workloads. |
|
internal/optwork
Package optwork holds workloads compiled by both Go and EVM.
|
Package optwork holds workloads compiled by both Go and EVM. |
|
internal/workload
Package workload contains shared fixtures for the EVM and Lua benchmarks.
|
Package workload contains shared fixtures for the EVM and Lua benchmarks. |
|
Package evmasm assembles textual EVM code without a Go compiler.
|
Package evmasm assembles textual EVM code without a Go compiler. |
|
Package evmbind builds a reusable EVM host schema from Go declarations.
|
Package evmbind builds a reusable EVM host schema from Go declarations. |
|
cmd/evmbind
command
Command evmbind generates a package of native wrappers for an EVM API.
|
Command evmbind generates a package of native wrappers for an EVM API. |
|
internal/methodfixture
Code generated by kvo.
|
Code generated by kvo. |
|
internal/methodfixture/gen
command
|
|
|
Package evmcompiler compiles sequential Go 1.23 to EVM bytecode.
|
Package evmcompiler compiles sequential Go 1.23 to EVM bytecode. |
|
internal
|
|
|
genstdlib
command
|