[][src]Struct stk::unit::CompilationUnit

pub struct CompilationUnit { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

Declare a new function at the current instruction pointer.

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

impl Debug for CompilationUnit[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,