pub fn define_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId {
        // Inline `cx.defined(self)` to avoid borrowck errors.
        let info = {
            let mut id = self.id;
            loop {
                match &cx.arena[id] {
                    ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => {
                        id = *alias_of;
                    }
                    ModuleInfo::Defined(d) => break d,
                }
            }
        };

        cx.types.insert(Type::Instance(InstanceType {
            exports: info
                .exports
                .iter()
                .map(|e| {
                    let name = e.field.into();
                    let index = usize::try_from(e.index).unwrap();
                    let entity = match e.kind {
                        wasmparser::ExternalKind::Function => {
                            let func_ty = info.functions[index];
                            EntityType::Function(func_ty)
                        }
                        wasmparser::ExternalKind::Table => {
                            let ty = info.tables[index];
                            EntityType::Table(ty)
                        }
                        wasmparser::ExternalKind::Memory => {
                            let ty = info.memories[index];
                            EntityType::Memory(ty)
                        }
                        wasmparser::ExternalKind::Global => {
                            let ty = info.globals[index];
                            EntityType::Global(ty)
                        }
                        wasmparser::ExternalKind::Instance => {
                            EntityType::Instance(info.instances[index])
                        }
                        wasmparser::ExternalKind::Module
                        | wasmparser::ExternalKind::Type
                        | wasmparser::ExternalKind::Event => unreachable!(),
                    };
                    (name, entity)
                })
                .collect(),
        }))
    }
/// Define an instance type for this module's exports.
///
/// Returns the index of the type and updates the total count of types in
/// `num_types`.
Define an instance type for this module's exports.
Returns the index of the type and updates the total count of types in
`num_types`.
Define an instance type for this module ' s exports . Returns the index of the type and updates the total count of types in ` num_types ` .
pub fn define_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId {
        // Inline `cx.defined(self)` to avoid borrowck errors.
        let info = {
            let mut id = self.id;
            loop {
                match &cx.arena[id] {
                    ModuleInfo::Aliased(AliasedModuleInfo { alias_of, .. }) => {
                        id = *alias_of;
                    }
                    ModuleInfo::Defined(d) => break d,
                }
            }
        };
        cx.types.insert(Type::Instance(InstanceType {
            exports: info
                .exports
                .iter()
                .map(|e| {
                    let name = e.field.into();
                    let index = usize::try_from(e.index).unwrap();
                    let entity = match e.kind {
                        wasmparser::ExternalKind::Function => {
                            let func_ty = info.functions[index];
                            EntityType::Function(func_ty)
                        }
                        wasmparser::ExternalKind::Table => {
                            let ty = info.tables[index];
                            EntityType::Table(ty)
                        }
                        wasmparser::ExternalKind::Memory => {
                            let ty = info.memories[index];
                            EntityType::Memory(ty)
                        }
                        wasmparser::ExternalKind::Global => {
                            let ty = info.globals[index];
                            EntityType::Global(ty)
                        }
                        wasmparser::ExternalKind::Instance => {
                            EntityType::Instance(info.instances[index])
                        }
                        wasmparser::ExternalKind::Module
                        | wasmparser::ExternalKind::Type
                        | wasmparser::ExternalKind::Event => unreachable!(),
                    };
                    (name, entity)
                })
                .collect(),
        }))
    }
pub fn define_instance_type ( self , cx : & mut ModuleContext < ' _ > ) -> TypeId { // Inline `cx.defined(self)` to avoid borrowck errors. let info = { let mut id = self . id ; loop { match & cx . arena [ id ] { ModuleInfo :: Aliased ( AliasedModuleInfo { alias_of , .. } ) => { id = * alias_of ; } ModuleInfo :: Defined ( d ) => break d , } } } ; cx . types . insert ( Type :: Instance ( InstanceType { exports : info . exports . iter ( ) . map ( | e | { let name = e . field . into ( ) ; let index = usize :: try_from ( e . index ) . unwrap ( ) ; let entity = match e . kind { wasmparser :: ExternalKind :: Function => { let func_ty = info . functions [ index ] ; EntityType :: Function ( func_ty ) } wasmparser :: ExternalKind :: Table => { let ty = info . tables [ index ] ; EntityType :: Table ( ty ) } wasmparser :: ExternalKind :: Memory => { let ty = info . memories [ index ] ; EntityType :: Memory ( ty ) } wasmparser :: ExternalKind :: Global => { let ty = info . globals [ index ] ; EntityType :: Global ( ty ) } wasmparser :: ExternalKind :: Instance => { EntityType :: Instance ( info . instances [ index ] ) } wasmparser :: ExternalKind :: Module | wasmparser :: ExternalKind :: Type | wasmparser :: ExternalKind :: Event => unreachable ! ( ) , } ; ( name , entity ) } ) . collect ( ) , } ) ) }
Define an instance type for this module's exports.
Define an instance type for this module ' s exports .
self
cx
&mut ModuleContext<'_>
self
cx
&mut ModuleContext<'_>