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§
source§impl<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§
source§impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Clone for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Clone,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Clone for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Clone,
source§impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Debug for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Debug,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Debug for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Debug,
source§impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Hash for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Hash,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Hash for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Hash,
source§impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Ord for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Ord,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> Ord for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + Ord,
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialEq<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + PartialEq,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialEq<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + PartialEq,
source§impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialOrd<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + PartialOrd,
impl<Isa, const RUNTIME_MAX_TOTAL_LIBS: u16> PartialOrd<Program<Isa, RUNTIME_MAX_TOTAL_LIBS>> for Program<Isa, RUNTIME_MAX_TOTAL_LIBS>where
Isa: InstructionSet + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more