pub fn define_state_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId {
        // Define instance types for each of the instances that we instantiate
        // locally so that we can refer to these types in the state instance's
        // type.
        let instantiated_modules: Vec<_> =
            self.instantiations(cx).values().map(|(m, _)| *m).collect();
        let instance_types = instantiated_modules
            .into_iter()
            .map(|m| m.define_instance_type(cx))
            .collect::<Vec<_>>();

        // Define the state instance type.
        cx.types.insert(Type::Instance(InstanceType {
            exports: self
                .defined_globals(cx)
                .enumerate()
                .map(|(i, (_, g))| {
                    (
                        format!("__wizer_global_{}", i).into(),
                        EntityType::Global(g),
                    )
                })
                .chain(self.defined_memories(cx).enumerate().map(|(i, (_, m))| {
                    (
                        format!("__wizer_memory_{}", i).into(),
                        EntityType::Memory(m),
                    )
                }))
                .chain(instance_types.iter().enumerate().map(|(i, ty)| {
                    (
                        format!("__wizer_instance_{}", i).into(),
                        EntityType::Instance(*ty),
                    )
                }))
                .collect(),
        }))
    }
/// Define an instance type for this module's state.
Define an instance type for this module's state.
Define an instance type for this module ' s state .
pub fn define_state_instance_type(self, cx: &mut ModuleContext<'_>) -> TypeId {
        // Define instance types for each of the instances that we instantiate
        // locally so that we can refer to these types in the state instance's
        // type.
        let instantiated_modules: Vec<_> =
            self.instantiations(cx).values().map(|(m, _)| *m).collect();
        let instance_types = instantiated_modules
            .into_iter()
            .map(|m| m.define_instance_type(cx))
            .collect::<Vec<_>>();
        // Define the state instance type.
        cx.types.insert(Type::Instance(InstanceType {
            exports: self
                .defined_globals(cx)
                .enumerate()
                .map(|(i, (_, g))| {
                    (
                        format!("__wizer_global_{}", i).into(),
                        EntityType::Global(g),
                    )
                })
                .chain(self.defined_memories(cx).enumerate().map(|(i, (_, m))| {
                    (
                        format!("__wizer_memory_{}", i).into(),
                        EntityType::Memory(m),
                    )
                }))
                .chain(instance_types.iter().enumerate().map(|(i, ty)| {
                    (
                        format!("__wizer_instance_{}", i).into(),
                        EntityType::Instance(*ty),
                    )
                }))
                .collect(),
        }))
    }
pub fn define_state_instance_type ( self , cx : & mut ModuleContext < ' _ > ) -> TypeId { // Define instance types for each of the instances that we instantiate // locally so that we can refer to these types in the state instance's // type. let instantiated_modules : Vec < _ > = self . instantiations ( cx ) . values ( ) . map ( | ( m , _ ) | * m ) . collect ( ) ; let instance_types = instantiated_modules . into_iter ( ) . map ( | m | m . define_instance_type ( cx ) ) . collect :: < Vec < _ > > ( ) ; // Define the state instance type. cx . types . insert ( Type :: Instance ( InstanceType { exports : self . defined_globals ( cx ) . enumerate ( ) . map ( | ( i , ( _ , g ) ) | { ( format ! ( " " i ) . into ( ) , EntityType :: Global ( g ) , ) } ) . chain ( self . defined_memories ( cx ) . enumerate ( ) . map ( | ( i , ( _ , m ) ) | { ( format ! ( " " i ) . into ( ) , EntityType :: Memory ( m ) , ) } ) ) . chain ( instance_types . iter ( ) . enumerate ( ) . map ( | ( i , ty ) | { ( format ! ( " " i ) . into ( ) , EntityType :: Instance ( * ty ) , ) } ) ) . collect ( ) , } ) ) }
Define an instance type for this module's state.
Define an instance type for this module ' s state .
self
cx
&mut ModuleContext<'_>
self
cx
&mut ModuleContext<'_>