pub struct ComponentTypesBuilder { /* private fields */ }
Expand description
Structured used to build a ComponentTypes
during translation.
This contains tables to intern any component types found as well as
managing building up core wasm ModuleTypes
as well.
Implementations§
source§impl ComponentTypesBuilder
impl ComponentTypesBuilder
sourcepub fn new(validator: &Validator) -> Self
pub fn new(validator: &Validator) -> Self
Construct a new ComponentTypesBuilder
for use with the given validator.
sourcepub fn finish(
self,
component: &Component,
) -> (ComponentTypes, TypeComponentIndex)
pub fn finish( self, component: &Component, ) -> (ComponentTypes, TypeComponentIndex)
Finishes this list of component types and returns the finished
structure and the TypeComponentIndex
corresponding to top-level component
with imports
and exports
specified.
sourcepub fn find_resource_drop_signature(&self) -> Option<ModuleInternedTypeIndex>
pub fn find_resource_drop_signature(&self) -> Option<ModuleInternedTypeIndex>
Smaller helper method to find a ModuleInternedTypeIndex
which
corresponds to the resource.drop
intrinsic in components, namely a
core wasm function type which takes one i32
argument and has no
results.
This is a bit of a hack right now as ideally this find operation
wouldn’t be needed and instead the ModuleInternedTypeIndex
itself
would be threaded through appropriately, but that’s left for a future
refactoring. Try not to lean too hard on this method though.
sourcepub fn module_types_builder(&self) -> &ModuleTypesBuilder
pub fn module_types_builder(&self) -> &ModuleTypesBuilder
Returns the underlying builder used to build up core wasm module types.
Note that this is shared across all modules found within a component to improve the wins from deduplicating function signatures.
sourcepub fn module_types_builder_mut(&mut self) -> &mut ModuleTypesBuilder
pub fn module_types_builder_mut(&mut self) -> &mut ModuleTypesBuilder
Same as module_types_builder
, but mut
.
sourcepub fn num_resource_tables(&self) -> usize
pub fn num_resource_tables(&self) -> usize
Returns the number of resource tables allocated so far, or the maximum
TypeResourceTableIndex
.
sourcepub fn resources_mut(&mut self) -> &mut ResourcesBuilder
pub fn resources_mut(&mut self) -> &mut ResourcesBuilder
Returns a mutable reference to the underlying ResourcesBuilder
.
sourcepub fn resources_mut_and_types(
&mut self,
) -> (&mut ResourcesBuilder, &ComponentTypes)
pub fn resources_mut_and_types( &mut self, ) -> (&mut ResourcesBuilder, &ComponentTypes)
Work around the borrow checker to borrow two sub-fields simultaneously externally.
sourcepub fn convert_component_func_type(
&mut self,
types: TypesRef<'_>,
id: ComponentFuncTypeId,
) -> Result<TypeFuncIndex>
pub fn convert_component_func_type( &mut self, types: TypesRef<'_>, id: ComponentFuncTypeId, ) -> Result<TypeFuncIndex>
Converts a wasmparser ComponentFuncType
into Wasmtime’s type
representation.
sourcepub fn convert_component_entity_type(
&mut self,
types: TypesRef<'_>,
ty: ComponentEntityType,
) -> Result<TypeDef>
pub fn convert_component_entity_type( &mut self, types: TypesRef<'_>, ty: ComponentEntityType, ) -> Result<TypeDef>
Converts a wasmparser ComponentEntityType
into Wasmtime’s type
representation.
sourcepub fn convert_type(
&mut self,
types: TypesRef<'_>,
id: ComponentAnyTypeId,
) -> Result<TypeDef>
pub fn convert_type( &mut self, types: TypesRef<'_>, id: ComponentAnyTypeId, ) -> Result<TypeDef>
Converts a wasmparser Type
into Wasmtime’s type representation.
sourcepub fn resource_id(&mut self, id: ResourceId) -> TypeResourceTableIndex
pub fn resource_id(&mut self, id: ResourceId) -> TypeResourceTableIndex
Converts a wasmparser id
, which must point to a resource, to its
corresponding TypeResourceTableIndex
.
sourcepub fn add_func_type(&mut self, ty: TypeFunc) -> TypeFuncIndex
pub fn add_func_type(&mut self, ty: TypeFunc) -> TypeFuncIndex
Interns a new function type within this type information.
sourcepub fn add_record_type(&mut self, ty: TypeRecord) -> TypeRecordIndex
pub fn add_record_type(&mut self, ty: TypeRecord) -> TypeRecordIndex
Interns a new record type within this type information.
sourcepub fn add_flags_type(&mut self, ty: TypeFlags) -> TypeFlagsIndex
pub fn add_flags_type(&mut self, ty: TypeFlags) -> TypeFlagsIndex
Interns a new flags type within this type information.
sourcepub fn add_tuple_type(&mut self, ty: TypeTuple) -> TypeTupleIndex
pub fn add_tuple_type(&mut self, ty: TypeTuple) -> TypeTupleIndex
Interns a new tuple type within this type information.
sourcepub fn add_variant_type(&mut self, ty: TypeVariant) -> TypeVariantIndex
pub fn add_variant_type(&mut self, ty: TypeVariant) -> TypeVariantIndex
Interns a new variant type within this type information.
sourcepub fn add_enum_type(&mut self, ty: TypeEnum) -> TypeEnumIndex
pub fn add_enum_type(&mut self, ty: TypeEnum) -> TypeEnumIndex
Interns a new enum type within this type information.
sourcepub fn add_option_type(&mut self, ty: TypeOption) -> TypeOptionIndex
pub fn add_option_type(&mut self, ty: TypeOption) -> TypeOptionIndex
Interns a new option type within this type information.
sourcepub fn add_result_type(&mut self, ty: TypeResult) -> TypeResultIndex
pub fn add_result_type(&mut self, ty: TypeResult) -> TypeResultIndex
Interns a new result type within this type information.
sourcepub fn add_list_type(&mut self, ty: TypeList) -> TypeListIndex
pub fn add_list_type(&mut self, ty: TypeList) -> TypeListIndex
Interns a new type within this type information.
sourcepub fn canonical_abi(&self, ty: &InterfaceType) -> &CanonicalAbiInfo
pub fn canonical_abi(&self, ty: &InterfaceType) -> &CanonicalAbiInfo
Returns the canonical ABI information about the specified type.
sourcepub fn flat_types(&self, ty: &InterfaceType) -> Option<FlatTypes<'_>>
pub fn flat_types(&self, ty: &InterfaceType) -> Option<FlatTypes<'_>>
Returns the “flat types” for the given interface type used in the canonical ABI.
Returns None
if the type is too large to be represented via flat types
in the canonical abi.
sourcepub fn ty_contains_borrow_resource(&self, ty: &InterfaceType) -> bool
pub fn ty_contains_borrow_resource(&self, ty: &InterfaceType) -> bool
Returns whether the type specified contains any borrowed resources within it.
Trait Implementations§
source§impl<T> Index<T> for ComponentTypesBuilderwhere
ModuleTypes: Index<T>,
impl<T> Index<T> for ComponentTypesBuilderwhere
ModuleTypes: Index<T>,
source§impl Index<TypeComponentIndex> for ComponentTypesBuilder
impl Index<TypeComponentIndex> for ComponentTypesBuilder
source§type Output = TypeComponent
type Output = TypeComponent
source§fn index(&self, idx: TypeComponentIndex) -> &TypeComponent
fn index(&self, idx: TypeComponentIndex) -> &TypeComponent
container[index]
) operation. Read moresource§impl Index<TypeComponentInstanceIndex> for ComponentTypesBuilder
impl Index<TypeComponentInstanceIndex> for ComponentTypesBuilder
source§type Output = TypeComponentInstance
type Output = TypeComponentInstance
source§fn index(&self, idx: TypeComponentInstanceIndex) -> &TypeComponentInstance
fn index(&self, idx: TypeComponentInstanceIndex) -> &TypeComponentInstance
container[index]
) operation. Read moresource§impl Index<TypeEnumIndex> for ComponentTypesBuilder
impl Index<TypeEnumIndex> for ComponentTypesBuilder
source§impl Index<TypeFlagsIndex> for ComponentTypesBuilder
impl Index<TypeFlagsIndex> for ComponentTypesBuilder
source§impl Index<TypeFuncIndex> for ComponentTypesBuilder
impl Index<TypeFuncIndex> for ComponentTypesBuilder
source§impl Index<TypeListIndex> for ComponentTypesBuilder
impl Index<TypeListIndex> for ComponentTypesBuilder
source§impl Index<TypeModuleIndex> for ComponentTypesBuilder
impl Index<TypeModuleIndex> for ComponentTypesBuilder
source§type Output = TypeModule
type Output = TypeModule
source§fn index(&self, idx: TypeModuleIndex) -> &TypeModule
fn index(&self, idx: TypeModuleIndex) -> &TypeModule
container[index]
) operation. Read moresource§impl Index<TypeOptionIndex> for ComponentTypesBuilder
impl Index<TypeOptionIndex> for ComponentTypesBuilder
source§type Output = TypeOption
type Output = TypeOption
source§fn index(&self, idx: TypeOptionIndex) -> &TypeOption
fn index(&self, idx: TypeOptionIndex) -> &TypeOption
container[index]
) operation. Read moresource§impl Index<TypeRecordIndex> for ComponentTypesBuilder
impl Index<TypeRecordIndex> for ComponentTypesBuilder
source§type Output = TypeRecord
type Output = TypeRecord
source§fn index(&self, idx: TypeRecordIndex) -> &TypeRecord
fn index(&self, idx: TypeRecordIndex) -> &TypeRecord
container[index]
) operation. Read moresource§impl Index<TypeResourceTableIndex> for ComponentTypesBuilder
impl Index<TypeResourceTableIndex> for ComponentTypesBuilder
source§type Output = TypeResourceTable
type Output = TypeResourceTable
source§fn index(&self, idx: TypeResourceTableIndex) -> &TypeResourceTable
fn index(&self, idx: TypeResourceTableIndex) -> &TypeResourceTable
container[index]
) operation. Read moresource§impl Index<TypeResultIndex> for ComponentTypesBuilder
impl Index<TypeResultIndex> for ComponentTypesBuilder
source§type Output = TypeResult
type Output = TypeResult
source§fn index(&self, idx: TypeResultIndex) -> &TypeResult
fn index(&self, idx: TypeResultIndex) -> &TypeResult
container[index]
) operation. Read moresource§impl Index<TypeTupleIndex> for ComponentTypesBuilder
impl Index<TypeTupleIndex> for ComponentTypesBuilder
source§impl Index<TypeVariantIndex> for ComponentTypesBuilder
impl Index<TypeVariantIndex> for ComponentTypesBuilder
source§type Output = TypeVariant
type Output = TypeVariant
source§fn index(&self, idx: TypeVariantIndex) -> &TypeVariant
fn index(&self, idx: TypeVariantIndex) -> &TypeVariant
container[index]
) operation. Read more