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