pub struct Library { /* private fields */ }
Expand description
Represents a set of imports for a single Program or Snippet, and moreover tracks some data used for initializing the memory allocator.
Implementations§
Source§impl Library
impl Library
pub fn kmalloc_memory_region() -> MemoryRegion
pub fn new() -> Self
Sourcepub fn import(&mut self, snippet: Box<dyn BasicSnippet>) -> String
pub fn import(&mut self, snippet: Box<dyn BasicSnippet>) -> String
Import T: Snippet
.
Recursively imports T
’s dependencies.
Does not import the snippets with the same entrypoint twice.
Avoid cyclic dependencies by only calling T::function_code()
which
may call .import()
if .import::<T>()
wasn’t already called once.
Sourcepub fn explicit_import(
&mut self,
name: &str,
body: &[LabelledInstruction],
) -> String
pub fn explicit_import( &mut self, name: &str, body: &[LabelledInstruction], ) -> String
Import code that does not implement the Snippet
trait
If possible, you should use the import
method as
it gives better protections and allows you to test functions in
isolation. This method is intended to add function to the assembly
that you have defined inline and where a function call is needed due to
e.g. a dynamic counter.
Sourcepub fn all_external_dependencies(&self) -> Vec<Vec<LabelledInstruction>>
pub fn all_external_dependencies(&self) -> Vec<Vec<LabelledInstruction>>
Return a list of all external dependencies sorted by name. All snippets are sorted alphabetically to ensure that generated programs are deterministic.
Sourcepub fn get_all_snippet_names(&self) -> Vec<String>
pub fn get_all_snippet_names(&self) -> Vec<String>
Return the name of all imported snippets, sorted alphabetically to ensure that output is deterministic.
Sourcepub fn all_imports(&self) -> Vec<LabelledInstruction>
pub fn all_imports(&self) -> Vec<LabelledInstruction>
Return a list of instructions containing all imported snippets.
Sourcepub fn kmalloc(&mut self, num_words: u32) -> StaticAllocation
pub fn kmalloc(&mut self, num_words: u32) -> StaticAllocation
Statically allocate num_words
words of memory.
§Panics
Panics if
num_words
is zero,- the total number of statically allocated words exceeds
u32::MAX
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Library
impl RefUnwindSafe for Library
impl Send for Library
impl Sync for Library
impl Unpin for Library
impl UnwindSafe for Library
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more