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

source

pub fn new(validator: &Validator) -> Self

Construct a new ComponentTypesBuilder for use with the given validator.

source

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.

source

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.

source

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.

source

pub fn module_types_builder_mut(&mut self) -> &mut ModuleTypesBuilder

Same as module_types_builder, but mut.

source

pub fn num_resource_tables(&self) -> usize

Returns the number of resource tables allocated so far, or the maximum TypeResourceTableIndex.

source

pub fn resources_mut(&mut self) -> &mut ResourcesBuilder

Returns a mutable reference to the underlying ResourcesBuilder.

source

pub fn resources_mut_and_types( &mut self, ) -> (&mut ResourcesBuilder, &ComponentTypes)

Work around the borrow checker to borrow two sub-fields simultaneously externally.

source

pub fn convert_component_func_type( &mut self, types: TypesRef<'_>, id: ComponentFuncTypeId, ) -> Result<TypeFuncIndex>

Converts a wasmparser ComponentFuncType into Wasmtime’s type representation.

source

pub fn convert_component_entity_type( &mut self, types: TypesRef<'_>, ty: ComponentEntityType, ) -> Result<TypeDef>

Converts a wasmparser ComponentEntityType into Wasmtime’s type representation.

source

pub fn convert_type( &mut self, types: TypesRef<'_>, id: ComponentAnyTypeId, ) -> Result<TypeDef>

Converts a wasmparser Type into Wasmtime’s type representation.

source

pub fn resource_id(&mut self, id: ResourceId) -> TypeResourceTableIndex

Converts a wasmparser id, which must point to a resource, to its corresponding TypeResourceTableIndex.

source

pub fn add_func_type(&mut self, ty: TypeFunc) -> TypeFuncIndex

Interns a new function type within this type information.

source

pub fn add_record_type(&mut self, ty: TypeRecord) -> TypeRecordIndex

Interns a new record type within this type information.

source

pub fn add_flags_type(&mut self, ty: TypeFlags) -> TypeFlagsIndex

Interns a new flags type within this type information.

source

pub fn add_tuple_type(&mut self, ty: TypeTuple) -> TypeTupleIndex

Interns a new tuple type within this type information.

source

pub fn add_variant_type(&mut self, ty: TypeVariant) -> TypeVariantIndex

Interns a new variant type within this type information.

source

pub fn add_enum_type(&mut self, ty: TypeEnum) -> TypeEnumIndex

Interns a new enum type within this type information.

source

pub fn add_option_type(&mut self, ty: TypeOption) -> TypeOptionIndex

Interns a new option type within this type information.

source

pub fn add_result_type(&mut self, ty: TypeResult) -> TypeResultIndex

Interns a new result type within this type information.

source

pub fn add_list_type(&mut self, ty: TypeList) -> TypeListIndex

Interns a new type within this type information.

source

pub fn canonical_abi(&self, ty: &InterfaceType) -> &CanonicalAbiInfo

Returns the canonical ABI information about the specified type.

source

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.

source

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 ComponentTypesBuilder
where ModuleTypes: Index<T>,

source§

type Output = <ModuleTypes as Index<T>>::Output

The returned type after indexing.
source§

fn index(&self, idx: T) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeComponentIndex> for ComponentTypesBuilder

source§

type Output = TypeComponent

The returned type after indexing.
source§

fn index(&self, idx: TypeComponentIndex) -> &TypeComponent

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeComponentInstanceIndex> for ComponentTypesBuilder

source§

type Output = TypeComponentInstance

The returned type after indexing.
source§

fn index(&self, idx: TypeComponentInstanceIndex) -> &TypeComponentInstance

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeEnumIndex> for ComponentTypesBuilder

source§

type Output = TypeEnum

The returned type after indexing.
source§

fn index(&self, idx: TypeEnumIndex) -> &TypeEnum

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeFlagsIndex> for ComponentTypesBuilder

source§

type Output = TypeFlags

The returned type after indexing.
source§

fn index(&self, idx: TypeFlagsIndex) -> &TypeFlags

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeFuncIndex> for ComponentTypesBuilder

source§

type Output = TypeFunc

The returned type after indexing.
source§

fn index(&self, idx: TypeFuncIndex) -> &TypeFunc

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeListIndex> for ComponentTypesBuilder

source§

type Output = TypeList

The returned type after indexing.
source§

fn index(&self, idx: TypeListIndex) -> &TypeList

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeModuleIndex> for ComponentTypesBuilder

source§

type Output = TypeModule

The returned type after indexing.
source§

fn index(&self, idx: TypeModuleIndex) -> &TypeModule

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeOptionIndex> for ComponentTypesBuilder

source§

type Output = TypeOption

The returned type after indexing.
source§

fn index(&self, idx: TypeOptionIndex) -> &TypeOption

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeRecordIndex> for ComponentTypesBuilder

source§

type Output = TypeRecord

The returned type after indexing.
source§

fn index(&self, idx: TypeRecordIndex) -> &TypeRecord

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeResourceTableIndex> for ComponentTypesBuilder

source§

type Output = TypeResourceTable

The returned type after indexing.
source§

fn index(&self, idx: TypeResourceTableIndex) -> &TypeResourceTable

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeResultIndex> for ComponentTypesBuilder

source§

type Output = TypeResult

The returned type after indexing.
source§

fn index(&self, idx: TypeResultIndex) -> &TypeResult

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeTupleIndex> for ComponentTypesBuilder

source§

type Output = TypeTuple

The returned type after indexing.
source§

fn index(&self, idx: TypeTupleIndex) -> &TypeTuple

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TypeVariantIndex> for ComponentTypesBuilder

source§

type Output = TypeVariant

The returned type after indexing.
source§

fn index(&self, idx: TypeVariantIndex) -> &TypeVariant

Performs the indexing (container[index]) operation. Read more
source§

impl TypeConvert for ComponentTypesBuilder

source§

fn lookup_heap_type(&self, _index: UnpackedIndex) -> WasmHeapType

Converts the specified type index from a heap type into a canonicalized heap type.
source§

fn lookup_type_index(&self, _index: UnpackedIndex) -> EngineOrModuleTypeIndex

Converts the specified type index from a heap type into a canonicalized heap type.
source§

fn convert_global_type(&self, ty: &GlobalType) -> Global

Converts a wasmparser table type into a wasmtime type
source§

fn convert_table_type(&self, ty: &TableType) -> WasmResult<Table>

Converts a wasmparser table type into a wasmtime type
source§

fn convert_sub_type(&self, ty: &SubType) -> WasmSubType

source§

fn convert_composite_type(&self, ty: &CompositeType) -> WasmCompositeType

source§

fn convert_struct_type(&self, ty: &StructType) -> WasmStructType

source§

fn convert_array_type(&self, ty: &ArrayType) -> WasmArrayType

source§

fn convert_field_type(&self, ty: &FieldType) -> WasmFieldType

source§

fn convert_storage_type(&self, ty: &StorageType) -> WasmStorageType

source§

fn convert_func_type(&self, ty: &FuncType) -> WasmFuncType

Converts a wasmparser function type to a wasmtime type
source§

fn convert_valtype(&self, ty: ValType) -> WasmValType

Converts a wasmparser value type to a wasmtime type
source§

fn convert_ref_type(&self, ty: RefType) -> WasmRefType

Converts a wasmparser reference type to a wasmtime type
source§

fn convert_heap_type(&self, ty: HeapType) -> WasmHeapType

Converts a wasmparser heap type to a wasmtime type

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.