Skip to main content

Loadable

Struct Loadable 

Source
pub struct Loadable<I, M: Composite> { /* private fields */ }
Expand description

A program image and the composite that executes its borrowed instructions.

Construct the image explicitly before pairing it with a machine. Only Image is supported; the image remains unchanged throughout an invocation. Ordinary outer structs can own several loadables with different instruction sets. Section selection and image construction remain caller responsibilities.

Implementations§

Source§

impl<Inst, V, Ty, Info, M> Loadable<Image<Inst, V, Ty, Info>, M>

Source

pub fn set_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
where M: Field<F, Child = Debugger<u32, Inst>>, Inst: HasBreakpointInstruction,

Install a gutter breakpoint in the owned image.

Source

pub fn clear_breakpoint<F>(&mut self, pc: u32) -> IsBreakpointToggled
where M: Field<F, Child = Debugger<u32, Inst>>, Inst: HasBreakpointInstruction,

Restore a gutter breakpoint’s instruction in the owned image.

Source

pub fn resume_with_breaks<F>(&mut self, action: DebugAction) -> Result<()>
where M: Field<F, Child = Debugger<u32, Inst>> + Dispatch<LocalModule<Inst, V, Ty, Info>, Instruction = Inst>, Inst: Clone,

Continue or single-step an invocation through the selected debugger.

Source§

impl<Inst, V, Ty, Info, M: Composite> Loadable<Image<Inst, V, Ty, Info>, M>

Source

pub fn image(&self) -> &Image<Inst, V, Ty, Info>

Inspect the paired image without changing an invocation’s program data.

Source

pub fn machine(&self) -> &M

Inspect the execution machine and its devices.

Source

pub fn machine_mut(&mut self) -> &mut M

Configure the execution machine or its devices.

Direct changes to execution state can affect whether an invocation can resume. The caller is responsible for keeping those changes consistent with the paired image.

Source

pub fn parts_mut(&mut self) -> (&Image<Inst, V, Ty, Info>, &mut M)

Borrow the image and mutably borrow the machine for custom runners.

Within execution_state::run, pass &image.module and the machine to execution_state::execute_instruction to drive a step. Keep any direct changes to invocation state consistent with the paired image.

Source

pub fn into_parts(self) -> (Image<Inst, V, Ty, Info>, M)

Consume the owner, returning its image and machine without resetting them.

Source§

impl<Inst, V, Ty, Info, M, S> Loadable<Image<Inst, V, Ty, Info>, M>
where M: Composite + HasProgram<Program = ExecutionState<S>>,

Source

pub fn new(image: Image<Inst, V, Ty, Info>, machine: M) -> Self

Pair an image with a machine, resetting its previous invocation state.

Device state is retained. No parsing, lowering, or image validation is performed here; construction of a valid image is the caller’s job.

When reusing a machine with a different image, call Debugger::forget_breakpoints on each debugger before using it with the new image. Saved instructions belong to the discarded image; retaining them can overwrite new code when a breakpoint is cleared. To keep the old image usable, restore its instructions with Debugger::clear_all before separating it from the machine instead.

Source

pub fn replace_image(&mut self, image: Image<Inst, V, Ty, Info>) -> Result<()>

Install an already constructed image and reset execution state.

Device state is retained. Image construction happens before this call; mutations made by the caller while constructing it are not rolled back.

After replacement succeeds, call Debugger::forget_breakpoints on each debugger before using it again. This discards instructions saved from the old image, which must never be restored into the replacement. Do not forget them before this call: if replacement is rejected, the old image still needs those instructions to clear or resume its breakpoints. Invocation-only Self::reset calls retain the image and its breakpoints. See the debugger Cargo example for the replacement and reuse sequence.

§Errors

Rejects replacement while an invocation is active, including one that could resume after an execution error. Call Self::reset to abandon that invocation first. Rejection leaves the current image and execution state unchanged.

Source

pub fn start(&mut self, arguments: &[Word]) -> Result<()>

Initialize an invocation without executing instructions.

Source

pub fn reset(&mut self)

Abandon the invocation, retaining the image and all device state.

Source§

impl<Inst, V, Ty, Info, M, S> Loadable<Image<Inst, V, Ty, Info>, M>
where M: HasProgram<Program = ExecutionState<S>> + Dispatch<LocalModule<Inst, V, Ty, Info>, Instruction = Inst>,

Source

pub fn execute(&mut self, arguments: &[Word]) -> Result<()>

Start at the program entrypoint with the supplied arguments.

Instructions and metadata borrow the image while dispatch mutates the separate machine. No instruction cloning is required.

§Errors

Returns the runner’s entry or execution errors. Earlier machine mutations are retained; reset or resume according to the invocation’s state.

Source

pub fn resume(&mut self) -> Result<()>

Continue the existing invocation against the same paired image.

§Errors

Returns the runner’s state, instruction-fetch, or dispatch errors without rolling back machine mutations. A halted invocation remains halted. A suspended invocation also remains suspended; use Self::resume_with_breaks to continue from a debugger breakpoint.

Trait Implementations§

Source§

impl<I: Debug, M: Debug + Composite> Debug for Loadable<I, M>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, M> Freeze for Loadable<I, M>
where I: Freeze, M: Freeze,

§

impl<I, M> RefUnwindSafe for Loadable<I, M>

§

impl<I, M> Send for Loadable<I, M>
where I: Send, M: Send,

§

impl<I, M> Sync for Loadable<I, M>
where I: Sync, M: Sync,

§

impl<I, M> Unpin for Loadable<I, M>
where I: Unpin, M: Unpin,

§

impl<I, M> UnsafeUnpin for Loadable<I, M>
where I: UnsafeUnpin, M: UnsafeUnpin,

§

impl<I, M> UnwindSafe for Loadable<I, M>
where I: UnwindSafe, M: UnwindSafe,

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<D> Apply<PushToStack<()>> for D

Source§

fn apply(&mut self, _: PushToStack<()>)

Apply a single effect to this destination.
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.

§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

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.