Expand description
Tree-walking interpreter for LOGOS imperative code.
This module provides runtime execution of parsed LOGOS programs by walking the AST and executing statements/expressions directly. The interpreter is async-capable to support VFS operations.
§Architecture
LOGOS AST
│
▼
┌────────────┐
│ Interpreter│ ──▶ Evaluate expressions
│ │ ──▶ Execute statements
│ │ ──▶ Manage scopes
└────────────┘
│
▼
RuntimeValue results§Runtime Values
The interpreter uses RuntimeValue to represent all values at runtime:
- Primitives:
Int,Float,Bool,Text,Char - Collections:
List,Tuple,Set,Map - User types:
Struct,Inductive(kernel-defined types)
§Async Support
The interpreter is async to support VFS file operations (OPFS on WASM,
tokio::fs on native). All statement execution is async fn.
Structs§
- Closure
Value - First-class closure value (boxed to reduce enum size).
- Function
Def - Stored function definition for user-defined functions.
- Inductive
Value - Kernel inductive value (boxed to reduce enum size).
- Interpreter
- Interpreter
Result - Result from program interpretation.
- Quantity
Value - The payload of a
RuntimeValue::Quantity: the physical quantity (magnitude in SI base + dimension) plus the unit it should be displayed in. Equality/hashing are by physical value (SI magnitude + dimension) — the display unit is presentation only, so2 inchesequals5.08 centimetres. - Struct
Value - Runtime values during LOGOS interpretation.
Enums§
- Closure
Body Ref - Side-table entry storing a closure body AST reference.
The index into the
closure_bodiesVec on the interpreter is stored inClosureValue::body_index. - Control
Flow - Control flow signals returned from statement execution.
- List
Repr - The List payload behind
RuntimeValue::List: homogeneous all-Int and all-Float lists store UNBOXED vectors (cache-dense, and the JIT can pin a raw pointer to them); anything else boxes. The repr lives INSIDE theRc<RefCell<…>>, so promotion re-tags the payload in place and every alias observes it — reference semantics and Rc identity are untouched. An EMPTY list is vacuouslyIntsand re-tags freely on its first push. - Runtime
Value
Functions§
Type Aliases§
- MapStorage
- The Map payload behind
RuntimeValue::Map. INSERTION-ORDERED (IndexMap): iteration, display, and marshaling follow the order keys were first inserted — the LOGOSMapcontract, identical across the tree-walker, the VM, the AOTLogosMap, and the direct-WASM linear map. FxHash instead of the standard library’s SipHash: map-heavy programs hash on every get/insert, and the keys here are small values (ints, short texts) where Fx is several times faster — with no DoS-resistance requirement (a single-program interpreter hashing its own program’s keys). NOTE: removal must go throughshift_remove(order-preserving), neverswap_remove. - Output
Callback - Callback type for streaming output from the interpreter.
Called each time
Showexecutes with the output line.