[−][src]Struct stk::unit::CompilationUnit
Instructions from a single source file.
Implementations
impl CompilationUnit
[src]
pub fn new() -> Self
[src]
Construct a new unit.
pub fn with_default_prelude() -> Self
[src]
Construct a new unit with the default prelude.
pub fn function_at(&self, n: usize) -> Option<(Hash, &UnitFnInfo)>
[src]
Access the function at the given instruction location.
pub fn debug_info_at(&self, n: usize) -> Option<&DebugInfo>
[src]
Access debug information for the given location if it is available.
pub fn instruction_at(&self, ip: usize) -> Option<&Inst>
[src]
Get the instruction at the given instruction pointer.
pub fn iter_static_strings(&self) -> impl Iterator<Item = (Hash, &str)> + '_
[src]
Iterate over all static strings in the unit.
pub fn iter_static_object_keys(
&self
) -> impl Iterator<Item = (Hash, &[String])> + '_
[src]
&self
) -> impl Iterator<Item = (Hash, &[String])> + '_
Iterate over all static object keys in the unit.
pub fn iter_instructions(&self) -> impl Iterator<Item = Inst> + '_
[src]
Iterate over all instructions in order.
pub fn iter_functions(&self) -> impl Iterator<Item = (Hash, &UnitFnInfo)> + '_
[src]
Iterate over known functions.
pub fn iter_imports<'a>(
&'a self
) -> impl Iterator<Item = (&'a str, &'a Item)> + '_
[src]
&'a self
) -> impl Iterator<Item = (&'a str, &'a Item)> + '_
Iterate over known imports.
pub fn lookup_string(&self, slot: usize) -> Option<&str>
[src]
Lookup the static string by slot, if it exists.
pub fn lookup_object_keys(&self, slot: usize) -> Option<&[String]>
[src]
Lookup the static object keys by slot, if it exists.
pub fn new_static_string(
&mut self,
current: &str
) -> Result<usize, CompilationUnitError>
[src]
&mut self,
current: &str
) -> Result<usize, CompilationUnitError>
Insert a static string and return its associated slot that can later be looked up through lookup_string.
Only uses up space if the static string is unique.
pub fn new_static_object_keys(
&mut self,
current: &[String]
) -> Result<usize, CompilationUnitError>
[src]
&mut self,
current: &[String]
) -> Result<usize, CompilationUnitError>
Insert a new collection of static object keys, or return one already existing.
pub fn lookup(&self, hash: Hash) -> Option<&UnitFnInfo>
[src]
Lookup information of a function.
pub fn lookup_offset(&self, hash: Hash) -> Option<usize>
[src]
Lookup the location of a dynamic function.
pub fn lookup_import_by_name(&self, name: &str) -> Option<&Item>
[src]
Look up an use by name.
pub fn new_import<I>(&mut self, path: I) -> Result<(), CompilationUnitError> where
I: Copy + IntoIterator,
I::Item: AsRef<str>,
[src]
I: Copy + IntoIterator,
I::Item: AsRef<str>,
Declare a new use.
pub fn new_assembly(&mut self) -> Assembly
[src]
Construct a new empty assembly associated with the current unit.
pub fn new_function<I>(
&mut self,
path: I,
args: usize,
assembly: Assembly
) -> Result<(), CompilationUnitError> where
I: IntoIterator,
I::Item: AsRef<str>,
[src]
&mut self,
path: I,
args: usize,
assembly: Assembly
) -> Result<(), CompilationUnitError> where
I: IntoIterator,
I::Item: AsRef<str>,
Declare a new function at the current instruction pointer.
pub fn link(&self, context: &Context, errors: &mut LinkerErrors) -> bool
[src]
Try to link the unit with the context, checking that all necessary functions are provided.
This can prevent a number of runtime errors, like missing functions.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CompilationUnit
impl Send for CompilationUnit
impl Sync for CompilationUnit
impl Unpin for CompilationUnit
impl UnwindSafe for CompilationUnit
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,