Module

Struct Module 

Source
pub struct Module { /* private fields */ }
Expand description

A module.

This is the root node of an LLHD intermediate representation. Contains Function, Process, and Entity declarations and definitions.

Implementations§

Source§

impl Module

Source

pub fn new() -> Self

Create a new empty module.

Source

pub fn dump(&self) -> ModuleDumper<'_>

Dump the module in human-readable form.

Source

pub fn add_unit(&mut self, data: UnitData) -> UnitId

Add a unit to the module.

Source

pub fn remove_unit(&mut self, unit: UnitId)

Remove a unit from the module.

Source

pub fn declare(&mut self, name: UnitName, sig: Signature) -> DeclId

Declare an external unit.

Source

pub fn add_decl(&mut self, data: DeclData) -> DeclId

Declare an external unit.

Source

pub fn remove_decl(&mut self, decl: DeclId)

Remove a declaration from the module.

Source

pub fn units<'a>(&'a self) -> impl Iterator<Item = Unit<'a>> + 'a

Return an iterator over the units in this module.

Source

pub fn units_mut<'a>(&'a mut self) -> impl Iterator<Item = UnitBuilder<'a>> + 'a

Return a mutable iterator over the units in this module.

Source

pub fn par_units<'a>(&'a self) -> impl ParallelIterator<Item = Unit<'a>> + 'a

Return a parallel iterator over the units in this module.

Source

pub fn par_units_mut<'a>( &'a mut self, ) -> impl ParallelIterator<Item = UnitBuilder<'a>> + 'a

Return a parallel mutable iterator over the units in this module.

Source

pub fn functions<'a>(&'a self) -> impl Iterator<Item = Unit<'a>> + 'a

Return an iterator over the functions in this module.

Source

pub fn processes<'a>(&'a self) -> impl Iterator<Item = Unit<'a>> + 'a

Return an iterator over the processes in this module.

Source

pub fn entities<'a>(&'a self) -> impl Iterator<Item = Unit<'a>> + 'a

Return an iterator over the entities in this module.

Source

pub fn decls<'a>(&'a self) -> impl Iterator<Item = DeclId> + 'a

Return an iterator over the external unit declarations in this module.

Source

pub fn unit(&self, unit: UnitId) -> Unit<'_>

Return an unit in the module.

Source

pub fn unit_mut(&mut self, unit: UnitId) -> UnitBuilder<'_>

Return a mutable unit in the module.

Source

pub fn symbols<'a>( &'a self, ) -> impl Iterator<Item = (&UnitName, LinkedUnit, &Signature)> + 'a

Return an iterator over the symbols in the module.

Source

pub fn local_symbols<'a>( &'a self, ) -> impl Iterator<Item = (&UnitName, LinkedUnit, &Signature)> + 'a

Return an iterator over the local symbols in the module.

Source

pub fn global_symbols<'a>( &'a self, ) -> impl Iterator<Item = (&UnitName, LinkedUnit, &Signature)> + 'a

Return an iterator over the global symbols in the module.

Source

pub fn is_linked(&self) -> bool

Check whether the module is internally linked.

Adding or modifying a unit invalidates the linkage within the module.

Locally link the module.

Source

pub fn verify(&self)

Panic if the module is not well-formed.

Source

pub fn lookup_ext_unit( &self, ext_unit: ExtUnit, within: UnitId, ) -> Option<LinkedUnit>

Lookup what an external unit links to.

The module must be linked for this to work.

Source

pub fn set_location_hint(&mut self, mod_unit: UnitId, loc: usize)

Add a location hint to a unit.

Annotates the byte offset of a unit in the input file.

Source

pub fn location_hint(&self, mod_unit: UnitId) -> Option<usize>

Get the location hint associated with a unit.

Returns the byte offset of the unit in the input file, or None if there is no hint for the value.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for Module

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Index<DeclId> for Module

Source§

type Output = DeclData

The returned type after indexing.
Source§

fn index(&self, idx: DeclId) -> &DeclData

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<UnitId> for Module

Source§

type Output = UnitData

The returned type after indexing.
Source§

fn index(&self, idx: UnitId) -> &UnitData

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<DeclId> for Module

Source§

fn index_mut(&mut self, idx: DeclId) -> &mut DeclData

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<UnitId> for Module

Source§

fn index_mut(&mut self, idx: UnitId) -> &mut UnitData

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Serialize for Module

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,