pub struct Lut {
function_lut: Vec<Vec<(usize, usize)>>,
}
Fields§
§function_lut: Vec<Vec<(usize, usize)>>
function_lut[local_module_idx][function_local_idx] = (foreign_module_idx, function_foreign_idx)
- Module A imports a function “foo”. Inside module A, the function has the index “function_local_idx”. Module A is assigned the index “local_module_idx”.
- Module B exports a function “foo”. Inside module B, the function has the index “function_foreign_idx”. Module B is assigned the index “foreign_module_idx”.
Implementations§
source§impl Lut
impl Lut
sourcepub fn new(
modules: &[ExecutionInfo<'_>],
module_map: &BTreeMap<String, usize>
) -> Option<Self>
pub fn new( modules: &[ExecutionInfo<'_>], module_map: &BTreeMap<String, usize> ) -> Option<Self>
sourcepub fn lookup(
&self,
module_idx: usize,
function_idx: usize
) -> Option<(usize, usize)>
pub fn lookup( &self, module_idx: usize, function_idx: usize ) -> Option<(usize, usize)>
Lookup a function by its module and function index.
§Arguments
module_idx
: The index of the module within themodules
array passed in Lut::new.function_idx
: The index of the function within the module. This index is considered in-bounds only if it is an index of an imported function.
§Returns
None
, if the indicies are out of boundSome(export_module_idx, export_function_idx)
, where the new indicies are the indicies of the module which contains the implementation of the imported function, and the implementation has the returned index within.
sourcepub fn manual_lookup(
modules: &[ExecutionInfo<'_>],
module_map: &BTreeMap<String, usize>,
module_name: &str,
function_name: &str
) -> Option<(usize, usize)>
pub fn manual_lookup( modules: &[ExecutionInfo<'_>], module_map: &BTreeMap<String, usize>, module_name: &str, function_name: &str ) -> Option<(usize, usize)>
Manually lookup a function by its module and function name.
This function is used to resolve import directives before the Lut is created, and can be used to resolve imports even after the Lut is created at the cost of speed.
§Arguments
modules
: The modules to link together.module_map
: A map from module name to module index within themodules
array.module_name
: The name of the module which imports the function.function_name
: The name of the function to import.
§Returns
None
, if the module or function is not found.Some(export_module_idx, export_function_idx)
, where the new indicies are the indicies of the module which contains the implementation of the imported function, and the implementation has the returned index within. Note that this function returns the first matching function, if there are multiple functions with the same name.
Auto Trait Implementations§
impl RefUnwindSafe for Lut
impl Send for Lut
impl Sync for Lut
impl Unpin for Lut
impl UnwindSafe for Lut
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