pub trait UnitStorage: Sealed + Debug + Default {
    type Iter<'this>: Iterator<Item = (usize, Inst)>
       where Self: 'this;

    // Required methods
    fn end(&self) -> usize;
    fn bytes(&self) -> usize;
    fn iter(&self) -> Self::Iter<'_>;
    fn get(&self, ip: usize) -> Result<Option<(Inst, usize)>, BadInstruction>;
    fn translate(&self, jump: usize) -> Result<usize, BadJump>;
}
Expand description

Instruction storage used by a Unit.

Required Associated Types§

source

type Iter<'this>: Iterator<Item = (usize, Inst)> where Self: 'this

Iterator over instructions and their corresponding instruction offsets.

Required Methods§

source

fn end(&self) -> usize

Size of unit storage. This can be seen as the instruction pointer which is just beyond the last instruction.

source

fn bytes(&self) -> usize

Get the number of bytes which is used to store unit bytecode.

source

fn iter(&self) -> Self::Iter<'_>

Iterate over all instructions.

source

fn get(&self, ip: usize) -> Result<Option<(Inst, usize)>, BadInstruction>

Get the instruction at the given instruction pointer.

source

fn translate(&self, jump: usize) -> Result<usize, BadJump>

Translate the given jump offset.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl UnitStorage for ArrayUnit

§

type Iter<'this> = Enumerate<Copied<Iter<'this, Inst>>>

source§

impl UnitStorage for ByteCodeUnit

§

type Iter<'this> = ByteCodeUnitIter<'this>