/// Lookup an export with the given export declaration.
Lookup an export with the given export declaration.
Lookup an export with the given export declaration .
pub fn lookup_by_declaration(&mut self, export: &EntityIndex) -> Export {
        match export {
            EntityIndex::Function(index) => {
                let anyfunc = self.get_caller_checked_anyfunc(*index).unwrap();
                let anyfunc =
                    NonNull::new(anyfunc as *const VMCallerCheckedAnyfunc as *mut _).unwrap();
                ExportFunction { anyfunc }.into()
            }
            EntityIndex::Table(index) => {
                let (definition, vmctx) =
                    if let Some(def_index) = self.module().defined_table_index(*index) {
                        (self.table_ptr(def_index), self.vmctx_ptr())
                    } else {
                        let import = self.imported_table(*index);
                        (import.from, import.vmctx)
                    };
                ExportTable {
                    definition,
                    vmctx,
                    table: self.module().table_plans[*index].clone(),
                }
                .into()
            }
            EntityIndex::Memory(index) => {
                let (definition, vmctx) =
                    if let Some(def_index) = self.module().defined_memory_index(*index) {
                        (self.memory_ptr(def_index), self.vmctx_ptr())
                    } else {
                        let import = self.imported_memory(*index);
                        (import.from, import.vmctx)
                    };
                ExportMemory {
                    definition,
                    vmctx,
                    memory: self.module().memory_plans[*index].clone(),
                }
                .into()
            }
            EntityIndex::Global(index) => ExportGlobal {
                definition: if let Some(def_index) = self.module().defined_global_index(*index) {
                    self.global_ptr(def_index)
                } else {
                    self.imported_global(*index).from
                },
                vmctx: self.vmctx_ptr(),
                global: self.module().globals[*index],
            }
            .into(),
            EntityIndex::Instance(_) | EntityIndex::Module(_) => {
                panic!("can't use this api for modules/instances")
            }
        }
    }
pub fn lookup_by_declaration ( & mut self , export : & EntityIndex ) -> Export { match export { EntityIndex :: Function ( index ) => { let anyfunc = self . get_caller_checked_anyfunc ( * index ) . unwrap ( ) ; let anyfunc = NonNull :: new ( anyfunc as * const VMCallerCheckedAnyfunc as * mut _ ) . unwrap ( ) ; ExportFunction { anyfunc } . into ( ) } EntityIndex :: Table ( index ) => { let ( definition , vmctx ) = if let Some ( def_index ) = self . module ( ) . defined_table_index ( * index ) { ( self . table_ptr ( def_index ) , self . vmctx_ptr ( ) ) } else { let import = self . imported_table ( * index ) ; ( import . from , import . vmctx ) } ; ExportTable { definition , vmctx , table : self . module ( ) . table_plans [ * index ] . clone ( ) , } . into ( ) } EntityIndex :: Memory ( index ) => { let ( definition , vmctx ) = if let Some ( def_index ) = self . module ( ) . defined_memory_index ( * index ) { ( self . memory_ptr ( def_index ) , self . vmctx_ptr ( ) ) } else { let import = self . imported_memory ( * index ) ; ( import . from , import . vmctx ) } ; ExportMemory { definition , vmctx , memory : self . module ( ) . memory_plans [ * index ] . clone ( ) , } . into ( ) } EntityIndex :: Global ( index ) => ExportGlobal { definition : if let Some ( def_index ) = self . module ( ) . defined_global_index ( * index ) { self . global_ptr ( def_index ) } else { self . imported_global ( * index ) . from } , vmctx : self . vmctx_ptr ( ) , global : self . module ( ) . globals [ * index ] , } . into ( ) , EntityIndex :: Instance ( _ ) | EntityIndex :: Module ( _ ) => { panic ! ( " " ) } } }
Lookup an export with the given export declaration.
Lookup an export with the given export declaration .
&mut self
export
&EntityIndex