pub struct Program<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16 = LIBS_MAX_TOTAL> where
Isa: InstructionSet, { /* private fields */ }
Expand description
An AluVM program executable by a virtual machine.
Generics
RUNTIME_MAX_TOTAL_LIBS
: Maximum total number of libraries supported by a runtime, if it is
less than LIBS_MAX_TOTAL
. If the value set is greater than LIBS_MAX_TOTAL
the
value is ignored and LIBS_MAX_TOTAL
constant is used instead.
Implementations
sourceimpl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourcepub fn new(lib: Lib) -> Self
pub fn new(lib: Lib) -> Self
Constructs new virtual machine runtime using provided single library. Entry point is set to zero offset by default.
sourcepub fn with(
libs: impl IntoIterator<Item = Lib>,
entrypoint: LibSite
) -> Result<Self, LibError>
pub fn with(
libs: impl IntoIterator<Item = Lib>,
entrypoint: LibSite
) -> Result<Self, LibError>
Constructs new virtual machine runtime from a set of libraries with a given entry point.
sourcepub fn lib(&self, id: LibId) -> Option<&Lib>
pub fn lib(&self, id: LibId) -> Option<&Lib>
Returns reference to a specific library, if it is part of the current program.
sourcepub fn add_lib(&mut self, lib: Lib) -> Result<bool, LibError>
pub fn add_lib(&mut self, lib: Lib) -> Result<bool, LibError>
Adds Alu bytecode library to the virtual machine runtime.
Errors
Checks requirement that the total number of libraries must not exceed LIBS_MAX_TOTAL
and RUNTIME_MAX_TOTAL_LIBS
- or returns LibError::TooManyLibs
otherwise.
Checks that the ISA used by the VM supports ISA extensions specified by the library and
returns LibError::IsaNotSupported
otherwise.
Returns
true
if the library was already known and false
otherwise.
sourcepub fn libs_count(&self) -> u16
pub fn libs_count(&self) -> u16
Returns number of libraries used by the program.
sourcepub fn entrypoint(&self) -> LibSite
pub fn entrypoint(&self) -> LibSite
Returns program entry point.
sourcepub fn set_entrypoint(&mut self, entrypoint: LibSite)
pub fn set_entrypoint(&mut self, entrypoint: LibSite)
Sets new entry point value (used when calling crate::Vm::run
)
Trait Implementations
sourceimpl<Isa: Clone, const RUNTIME_MAX_TOTAL_LIBS: u16> Clone for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa: Clone, const RUNTIME_MAX_TOTAL_LIBS: u16> Clone for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourceimpl<Isa: Debug, const RUNTIME_MAX_TOTAL_LIBS: u16> Debug for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa: Debug, const RUNTIME_MAX_TOTAL_LIBS: u16> Debug for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourceimpl<Isa: Hash, const RUNTIME_MAX_TOTAL_LIBS: u16> Hash for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa: Hash, const RUNTIME_MAX_TOTAL_LIBS: u16> Hash for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourceimpl<Isa: Ord, const RUNTIME_MAX_TOTAL_LIBS: u16> Ord for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa: Ord, const RUNTIME_MAX_TOTAL_LIBS: u16> Ord for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourceimpl<Isa: PartialEq, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialEq<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa: PartialEq, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialEq<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourceimpl<Isa: PartialOrd, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialOrd<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa: PartialOrd, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialOrd<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
sourcefn partial_cmp(
&self,
other: &Program<Isa, RUNTIME_MAX_TOTAL_LIBS>
) -> Option<Ordering>
fn partial_cmp(
&self,
other: &Program<Isa, RUNTIME_MAX_TOTAL_LIBS>
) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<Isa: Eq, const RUNTIME_MAX_TOTAL_LIBS: u16> Eq for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> StructuralEq for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> StructuralPartialEq for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: InstructionSet,
Auto Trait Implementations
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> RefUnwindSafe for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: RefUnwindSafe,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Send for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: Send,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Sync for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: Sync,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Unpin for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: Unpin,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> UnwindSafe for Program<Isa, RUNTIME_MAX_TOTAL_LIBS> where
Isa: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more