wasmtime_environ::component

Struct ComponentTypesBuilder

Source
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) -> Result<Table, WasmError>

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.