Skip to main content

Module behavior

Module behavior 

Source
Expand description

The behavior virtual machine: an authored Behavior compiled to slot-resolved form, and the evaluator that runs it.

compile resolves every authored name to a dense slot once, producing a Program; exec runs a program’s body against a View of what the body may read this tick. Evaluation mutates nothing: it appends Effects the caller applies afterwards, which is what lets bodies run concurrently without observing each other’s writes.

BehaviorSystem is what drives the two over a world each tick: it gathers the view, runs the bodies, and applies their effects. Nothing below reads a clock, a file, or a device, which is why the whole of it sits in the vocabulary rather than in a host. Where persisted state is kept (BehaviorStore) and how a tick’s runs fan out (EvalScheduler) are the host’s to supply; a world with neither runs its behaviors serially and persists nothing.

Structs§

BehaviorState
The behavior state a world carries between runs.
BehaviorSystem
Runs a world’s Behavior components: their firing rules, their bodies, and the effects those produce.
CNode
A slot-resolved node with its compile-assigned identity: id is the node’s pre-order position across the whole body, indexing the program’s paths table so execution tracing can address the node the way the world checker’s faults do.
EvalBucket
One worker’s share of a tick’s evaluation: a contiguous slice of the tick’s job list, its own effect and trace buffers, and its own binding scratch. Opaque to a scheduler, which only hands each bucket to the closure it was given. Everything inside keeps its capacity across ticks.
Program
One compiled behavior.
SpawnEffect
A requested copy of a template.
VarTable
The world’s variables, in slot order: shared across behaviors, so slots are assigned once across the whole set. A name the world’s Variables asset declares carries that declaration’s type and starting value; any other name a behavior mentions is an integer starting at zero.
View
What a behavior may read this tick.

Enums§

Arith
How two numbers combine.
CExpr
A slot-resolved expression.
COp
A slot-resolved node operation.
Cmp
How two values compare.
Effect
One world change a behavior asked for, in body order.
Val
A value flowing through a behavior body.

Traits§

BehaviorStore
Where a host keeps persisted behavior state.
EvalScheduler
Runs a tick’s evaluation buckets, in any order and on any thread.

Functions§

compile
Compile one authored behavior against the world’s shared variable table, interning any variable name it mentions that no Variables asset declared.
def_hash
Content hash of a behavior definition. Asset identity is excluded (its serde skip), so a restored fired flag applies to the behavior it was saved for and to no other.
exec
Run a compiled body against view, appending what it asked for to out.