Struct cranelift_wasm::wasmparser::types::Types
source · pub struct Types { /* private fields */ }
Expand description
Represents the types known to a crate::Validator
once validation has completed.
The type information is returned via the crate::Validator::end
method.
Implementations§
source§impl Types
impl Types
sourcepub fn get(&self, id: TypeId) -> Option<&Type>
pub fn get(&self, id: TypeId) -> Option<&Type>
Gets a type based on its type id.
Returns None
if the type id is unknown.
sourcepub fn core_type_at(&self, index: u32) -> TypeId
pub fn core_type_at(&self, index: u32) -> TypeId
Gets a core WebAssembly type at the given type index.
Note that this is in contrast to TypesRef::component_type_at
which
gets a component type from its index.
Panics
Panics if index
is not a valid function index.
sourcepub fn component_type_at(&self, index: u32) -> TypeId
pub fn component_type_at(&self, index: u32) -> TypeId
Gets a component type from the given component type index.
Panics
Panics if index
is not a valid function index or if this type
information represents a core module.
sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
Gets the count of core types.
sourcepub fn table_at(&self, index: u32) -> TableType
pub fn table_at(&self, index: u32) -> TableType
Gets the type of a table at the given table index.
Panics
Panics if index
is not a valid function index.
sourcepub fn table_count(&self) -> usize
pub fn table_count(&self) -> usize
Gets the count of imported and defined tables.
sourcepub fn memory_at(&self, index: u32) -> MemoryType
pub fn memory_at(&self, index: u32) -> MemoryType
Gets the type of a memory at the given memory index.
Panics
Panics if index
is not a valid function index.
sourcepub fn memory_count(&self) -> u32
pub fn memory_count(&self) -> u32
Gets the count of imported and defined memories.
sourcepub fn global_at(&self, index: u32) -> GlobalType
pub fn global_at(&self, index: u32) -> GlobalType
Gets the type of a global at the given global index.
Panics
Panics if index
is not a valid function index.
sourcepub fn global_count(&self) -> u32
pub fn global_count(&self) -> u32
Gets the count of imported and defined globals.
sourcepub fn tag_at(&self, index: u32) -> TypeId
pub fn tag_at(&self, index: u32) -> TypeId
Gets the type of a tag at the given tag index.
Panics
Panics if index
is not a valid function index.
sourcepub fn function_at(&self, index: u32) -> TypeId
pub fn function_at(&self, index: u32) -> TypeId
Gets the type of a core function at the given function index.
Panics
Panics if index
is not a valid function index.
sourcepub fn function_count(&self) -> u32
pub fn function_count(&self) -> u32
Gets the count of core functions defined so far.
Note that this includes imported functions, defined functions, and for components lowered/aliased functions.
sourcepub fn element_at(&self, index: u32) -> RefType
pub fn element_at(&self, index: u32) -> RefType
Gets the type of an element segment at the given element segment index.
Panics
This will panic if the index
provided is out of bounds.
sourcepub fn element_count(&self) -> u32
pub fn element_count(&self) -> u32
Gets the count of element segments.
sourcepub fn component_function_at(&self, index: u32) -> TypeId
pub fn component_function_at(&self, index: u32) -> TypeId
Gets the type of a component function at the given function index.
Panics
This will panic if the index
provided is out of bounds or if this type
information represents a core module.
sourcepub fn component_function_count(&self) -> u32
pub fn component_function_count(&self) -> u32
Gets the count of imported, exported, or aliased component functions.
sourcepub fn module_at(&self, index: u32) -> TypeId
pub fn module_at(&self, index: u32) -> TypeId
Gets the type of a module at the given module index.
Panics
This will panic if the index
provided is out of bounds or if this type
information represents a core module.
sourcepub fn module_count(&self) -> usize
pub fn module_count(&self) -> usize
Gets the count of imported, exported, or aliased modules.
sourcepub fn instance_at(&self, index: u32) -> TypeId
pub fn instance_at(&self, index: u32) -> TypeId
Gets the type of a module instance at the given module instance index.
Panics
This will panic if the index
provided is out of bounds or if this type
information represents a core module.
sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
Gets the count of imported, exported, or aliased core module instances.
sourcepub fn component_at(&self, index: u32) -> TypeId
pub fn component_at(&self, index: u32) -> TypeId
Gets the type of a component at the given component index.
Panics
This will panic if the index
provided is out of bounds or if this type
information represents a core module.
sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
Gets the count of imported, exported, or aliased components.
sourcepub fn component_instance_at(&self, index: u32) -> TypeId
pub fn component_instance_at(&self, index: u32) -> TypeId
Gets the type of an component instance at the given component instance index.
Panics
This will panic if the index
provided is out of bounds or if this type
information represents a core module.
sourcepub fn component_instance_count(&self) -> usize
pub fn component_instance_count(&self) -> usize
Gets the count of imported, exported, or aliased component instances.
sourcepub fn value_at(&self, index: u32) -> ComponentValType
pub fn value_at(&self, index: u32) -> ComponentValType
Gets the type of a value at the given value index.
Panics
This will panic if the index
provided is out of bounds or if this type
information represents a core module.
sourcepub fn value_count(&self) -> usize
pub fn value_count(&self) -> usize
Gets the count of imported, exported, or aliased values.
sourcepub fn entity_type_from_import(&self, import: &Import<'_>) -> Option<EntityType>
pub fn entity_type_from_import(&self, import: &Import<'_>) -> Option<EntityType>
Gets the entity type from the given import.
sourcepub fn entity_type_from_export(&self, export: &Export<'_>) -> Option<EntityType>
pub fn entity_type_from_export(&self, export: &Export<'_>) -> Option<EntityType>
Gets the entity type from the given export.
sourcepub fn component_entity_type_of_import(
&self,
name: &str
) -> Option<ComponentEntityType>
pub fn component_entity_type_of_import( &self, name: &str ) -> Option<ComponentEntityType>
Gets the component entity type for the given component import name.
sourcepub fn component_entity_type_of_export(
&self,
name: &str
) -> Option<ComponentEntityType>
pub fn component_entity_type_of_export( &self, name: &str ) -> Option<ComponentEntityType>
Gets the component entity type for the given component export name.
sourcepub fn peel_alias(&self, ty: TypeId) -> Option<TypeId>
pub fn peel_alias(&self, ty: TypeId) -> Option<TypeId>
Attempts to lookup the type id that ty
is an alias of.
Returns None
if ty
wasn’t listed as aliasing a prior type.