pub struct EelProgram { /* private fields */ }Expand description
One compiled EEL2 program: flat bytecode over a fixed register file.
Fixed-size at load; nothing here grows per frame.
Implementations§
Source§impl EelProgram
impl EelProgram
Sourcepub fn empty() -> Self
pub fn empty() -> Self
A program with no instructions and no registers — the identity, and what an absent section in a bundle means.
Sourcepub fn new(code: Vec<Op>, names: Vec<String>) -> Result<Self, ProgramError>
pub fn new(code: Vec<Op>, names: Vec<String>) -> Result<Self, ProgramError>
Assemble from code and register names, validating both.
The only constructor, so the invariants validate
establishes hold of every EelProgram that exists.
Sourcepub fn register_count(&self) -> usize
pub fn register_count(&self) -> usize
How many registers the program declares.
Sourcepub fn stack_depth(&self) -> usize
pub fn stack_depth(&self) -> usize
The deepest the operand stack gets. The VM sizes its stack from this.
Sourcepub fn written_registers(&self) -> &[u16]
pub fn written_registers(&self) -> &[u16]
Every register this program can write — see the field.
Sourcepub fn register(&self, name: &str) -> Option<u16>
pub fn register(&self, name: &str) -> Option<u16>
The index of the register called name, or None.
Called at load, never per frame. The host resolves the whole roster it cares about once and then addresses registers by index.
Sourcepub fn uses_random(&self) -> bool
pub fn uses_random(&self) -> bool
Whether the program can draw from the RNG, i.e. whether its output depends on anything but its inputs and its register file.
Read by the capture harness’s determinism argument: a program that says
false here is a pure function of its inputs, and one that says true is
a pure function of its inputs and the VM’s seeded RNG state, which is
itself reset with the preset (ADR-0051).
Source§impl EelProgram
impl EelProgram
Sourcepub fn to_assembly(&self) -> String
pub fn to_assembly(&self) -> String
This program as assembly text — the form a bundle carries.
.regs zoom rot _t0
.code
const 1.5
load 0
mul
store 0The inverse of from_assembly, which is asserted
rather than intended.
Sourcepub fn from_assembly(text: &str) -> Result<Self, ProgramError>
pub fn from_assembly(text: &str) -> Result<Self, ProgramError>
Decode assembly text, validating it into a program the VM may trust.
Blank lines and # comments are ignored, so a bundle stays legible.
Trait Implementations§
Source§impl Clone for EelProgram
impl Clone for EelProgram
Source§fn clone(&self) -> EelProgram
fn clone(&self) -> EelProgram
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EelProgram
impl Debug for EelProgram
Source§impl PartialEq for EelProgram
impl PartialEq for EelProgram
Source§fn eq(&self, other: &EelProgram) -> bool
fn eq(&self, other: &EelProgram) -> bool
self and other values to be equal, and is used by ==.