Skip to main content

EelProgram

Struct EelProgram 

Source
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

Source

pub fn empty() -> Self

A program with no instructions and no registers — the identity, and what an absent section in a bundle means.

Source

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.

Source

pub fn code(&self) -> &[Op]

The instructions.

Source

pub fn names(&self) -> &[String]

The register names, positionally.

Source

pub fn register_count(&self) -> usize

How many registers the program declares.

Source

pub fn stack_depth(&self) -> usize

The deepest the operand stack gets. The VM sizes its stack from this.

Source

pub fn written_registers(&self) -> &[u16]

Every register this program can write — see the field.

Source

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.

Source

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

Source

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 0

The inverse of from_assembly, which is asserted rather than intended.

Source

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

Source§

fn clone(&self) -> EelProgram

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EelProgram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for EelProgram

Source§

fn eq(&self, other: &EelProgram) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EelProgram

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,