Struct walrus::ModuleFunctions
source · pub struct ModuleFunctions { /* private fields */ }
Expand description
The set of functions within a module.
Implementations§
source§impl ModuleFunctions
impl ModuleFunctions
sourcepub fn new() -> ModuleFunctions
pub fn new() -> ModuleFunctions
Construct a new, empty set of functions for a module.
sourcepub fn add_import(&mut self, ty: TypeId, import: ImportId) -> FunctionId
pub fn add_import(&mut self, ty: TypeId, import: ImportId) -> FunctionId
Create a new externally defined, imported function.
sourcepub fn add_local(&mut self, func: LocalFunction) -> FunctionId
pub fn add_local(&mut self, func: LocalFunction) -> FunctionId
Create a new internally defined function
sourcepub fn get(&self, id: FunctionId) -> &Function
pub fn get(&self, id: FunctionId) -> &Function
Gets a reference to a function given its id
sourcepub fn get_mut(&mut self, id: FunctionId) -> &mut Function
pub fn get_mut(&mut self, id: FunctionId) -> &mut Function
Gets a reference to a function given its id
sourcepub fn by_name(&self, name: &str) -> Option<FunctionId>
pub fn by_name(&self, name: &str) -> Option<FunctionId>
Get a function ID by its name.
The name used is the “name” custom section name and not the export name, if a function happens to be exported.
Note that function names are not guaranteed to be unique. This will return the first function in the module with the given name.
sourcepub fn delete(&mut self, id: FunctionId)
pub fn delete(&mut self, id: FunctionId)
Removes a function from this module.
It is up to you to ensure that any potential references to the deleted
function are also removed, eg call
expressions, exports, table
elements, etc.
sourcepub fn iter(&self) -> impl Iterator<Item = &Function>
pub fn iter(&self) -> impl Iterator<Item = &Function>
Get a shared reference to this module’s functions.
sourcepub fn iter_local(&self) -> impl Iterator<Item = (FunctionId, &LocalFunction)>
pub fn iter_local(&self) -> impl Iterator<Item = (FunctionId, &LocalFunction)>
Get an iterator of this module’s local functions
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Function>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Function>
Get a mutable reference to this module’s functions.
sourcepub fn iter_local_mut(
&mut self
) -> impl Iterator<Item = (FunctionId, &mut LocalFunction)>
pub fn iter_local_mut( &mut self ) -> impl Iterator<Item = (FunctionId, &mut LocalFunction)>
Get an iterator of this module’s local functions