Struct EtableInterpreter

Source
pub struct EtableInterpreter<'etable, S, ES> { /* private fields */ }
Expand description

Interpreter that uses Etable.

Implementations§

Source§

impl<'etable, S, ES> EtableInterpreter<'etable, S, ES>

Source

pub const fn position(&self) -> usize

Return a reference of the program counter.

Source

pub fn new(machine: Machine<S>, etable: &'etable ES) -> Self

Create a new interpreter from the machine state and etable.

Source

pub fn deconstruct(self) -> Machine<S>

Deconstruct the interpreter to get the underlying machine state.

Source

pub fn exit(&mut self)

Explicit exit of the machine. Further step will return error.

Source

pub fn inspect(&self) -> Option<(Opcode, &Stack)>

Inspect the machine’s next opcode and current stack.

Source

pub fn perform<R, F: FnOnce(&mut Self) -> Result<R, ExitError>>( &mut self, f: F, ) -> Result<R, ExitError>

Perform any operation. If the operation fails, then set the machine status to already exited.

Source

pub fn peek_opcode(&self) -> Option<Opcode>

Pick the next opcode.

Source

pub fn advance(&mut self)

Advance the PC by one.

Methods from Deref<Target = Machine<S>>§

Source

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

Machine code.

Source

pub fn is_empty(&self) -> bool

Whether the machine has empty code.

Trait Implementations§

Source§

impl<'etable, S, ES> AsMut<Machine<S>> for EtableInterpreter<'etable, S, ES>

Source§

fn as_mut(&mut self) -> &mut Machine<S>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'etable, S, ES> AsRef<Machine<S>> for EtableInterpreter<'etable, S, ES>

Source§

fn as_ref(&self) -> &Machine<S>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'etable, S, ES> Deref for EtableInterpreter<'etable, S, ES>

Source§

type Target = Machine<S>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Machine<S>

Dereferences the value.
Source§

impl<'etable, S, ES> DerefMut for EtableInterpreter<'etable, S, ES>

Source§

fn deref_mut(&mut self) -> &mut Machine<S>

Mutably dereferences the value.
Source§

impl<'etable, S, H, ES: Etable<H, State = S>> FeedbackInterpreter<H, CallFeedback> for EtableInterpreter<'etable, S, ES>

Source§

fn feedback( &mut self, feedback: CallFeedback, _handler: &mut H, ) -> Result<(), ExitError>

Feedback to the interpreter.
Source§

impl<'etable, S, H, ES: Etable<H, State = S>> FeedbackInterpreter<H, CreateFeedback> for EtableInterpreter<'etable, S, ES>

Source§

fn feedback( &mut self, feedback: CreateFeedback, _handler: &mut H, ) -> Result<(), ExitError>

Feedback to the interpreter.
Source§

impl<'etable, S, H, ES: Etable<H, State = S>> Interpreter<H> for EtableInterpreter<'etable, S, ES>

Source§

type State = S

Interpreter state.
Source§

type Trap = <ES as Etable<H>>::Trap

Interpreter trap.
Source§

fn deconstruct(self) -> (ES::State, Vec<u8>)

Deconstruct the interpreter.
Source§

fn state(&self) -> &Self::State

Get a reference to the internal state.
Source§

fn state_mut(&mut self) -> &mut Self::State

Get a mutable reference to the internal state.
Source§

fn run(&mut self, handle: &mut H) -> Capture<ExitResult, Self::Trap>

Run the interpreter.
Source§

impl<'etable, S, H, ES: Etable<H, State = S>> StepInterpreter<H> for EtableInterpreter<'etable, S, ES>

Source§

fn step(&mut self, handle: &mut H) -> Result<(), Capture<ExitResult, ES::Trap>>

Step the interpreter.

Auto Trait Implementations§

§

impl<'etable, S, ES> Freeze for EtableInterpreter<'etable, S, ES>
where S: Freeze,

§

impl<'etable, S, ES> RefUnwindSafe for EtableInterpreter<'etable, S, ES>

§

impl<'etable, S, ES> !Send for EtableInterpreter<'etable, S, ES>

§

impl<'etable, S, ES> !Sync for EtableInterpreter<'etable, S, ES>

§

impl<'etable, S, ES> Unpin for EtableInterpreter<'etable, S, ES>
where S: Unpin,

§

impl<'etable, S, ES> UnwindSafe for EtableInterpreter<'etable, S, ES>
where S: UnwindSafe, ES: RefUnwindSafe,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TrapConsume<T> for T

Source§

type Rest = Infallible

Rest type.
Source§

fn consume(self) -> Result<T, Infallible>

Consume T to get Rest.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V