pub struct Module {
pub name: Ident,
pub functions: IndexVec<FunctionId, Function>,
pub data_segments: Vec<DataSegment>,
pub storage_layout: Vec<StorageSlot>,
pub immutables: Vec<ImmutableSlot>,
pub is_interface: bool,
}Expand description
A MIR module representing a compiled contract.
Fields§
§name: IdentModule/contract name.
functions: IndexVec<FunctionId, Function>All functions in this module.
data_segments: Vec<DataSegment>Data segments (for string literals, etc.).
storage_layout: Vec<StorageSlot>Storage layout.
immutables: Vec<ImmutableSlot>Immutable scratch-area layout (currently one staged word per immutable).
is_interface: boolWhether this is an interface (no bytecode generation).
Implementations§
Source§impl Module
impl Module
Sourcepub fn add_function(&mut self, function: Function) -> FunctionId
pub fn add_function(&mut self, function: Function) -> FunctionId
Adds a function to the module.
Sourcepub fn function(&self, id: FunctionId) -> &Function
pub fn function(&self, id: FunctionId) -> &Function
Returns the function for the given ID.
Sourcepub fn function_mut(&mut self, id: FunctionId) -> &mut Function
pub fn function_mut(&mut self, id: FunctionId) -> &mut Function
Returns a mutable reference to the function.
Sourcepub fn add_data_segment(&mut self, data: Vec<u8>) -> usize
pub fn add_data_segment(&mut self, data: Vec<u8>) -> usize
Adds a data segment.
Sourcepub fn add_storage_slot(&mut self, slot: StorageSlot) -> usize
pub fn add_storage_slot(&mut self, slot: StorageSlot) -> usize
Adds a storage slot.
Sourcepub fn add_immutable_slot(&mut self, slot: ImmutableSlot) -> usize
pub fn add_immutable_slot(&mut self, slot: ImmutableSlot) -> usize
Adds an immutable data slot.
Sourcepub fn immutable_data_len(&self) -> usize
pub fn immutable_data_len(&self) -> usize
Returns the size in bytes of the constructor scratch area that stages immutable words before they are patched into the runtime code.
Sourcepub fn iter_functions(&self) -> impl Iterator<Item = (FunctionId, &Function)>
pub fn iter_functions(&self) -> impl Iterator<Item = (FunctionId, &Function)>
Returns an iterator over all functions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Module
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnsafeUnpin for Module
impl UnwindSafe for Module
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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 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> ⓘ
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