Struct ProgramState

Source
pub struct ProgramState<'a> {
    pub bytecode: [&'a [u8]; 3],
    pub initial: Program,
    pub current: Program,
    pub decoder: Decoder<'a>,
    pub call_stack: CallStack,
}
Expand description

State for managing active programs and decoding instructions.

Fields§

§bytecode: [&'a [u8]; 3]

Bytecode for each of the three program types, indexed by Program.

§initial: Program

The initial program when execution begins.

§current: Program

The currently active program.

§decoder: Decoder<'a>

Instruction decoder for the currently active program.

§call_stack: CallStack

Tracks nested function and instruction invocations.

Implementations§

Source§

impl<'a> ProgramState<'a>

Source

pub fn new( font_code: &'a [u8], cv_code: &'a [u8], glyph_code: &'a [u8], initial_program: Program, ) -> Self

Source

pub fn reset(&mut self, program: Program)

Resets the state for execution of the given program.

Source

pub fn enter( &mut self, definition: Definition, count: u32, ) -> Result<(), HintErrorKind>

Jumps to the code in the given definition and sets it up for execution count times.

Source

pub fn leave(&mut self) -> Result<(), HintErrorKind>

Leaves the code from the definition on the top of the stack.

If the top call record has a loop count greater than 1, restarts execution from the beginning of the definition. Otherwise, resumes execution at the previously active definition.

Auto Trait Implementations§

§

impl<'a> Freeze for ProgramState<'a>

§

impl<'a> RefUnwindSafe for ProgramState<'a>

§

impl<'a> Send for ProgramState<'a>

§

impl<'a> Sync for ProgramState<'a>

§

impl<'a> Unpin for ProgramState<'a>

§

impl<'a> UnwindSafe for ProgramState<'a>

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> 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, 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.