pub struct ModuleTypesBuilder { /* private fields */ }
Expand description
A builder for ModuleTypes
.
Implementations§
Source§impl ModuleTypesBuilder
impl ModuleTypesBuilder
Sourcepub fn new(validator: &Validator) -> Self
pub fn new(validator: &Validator) -> Self
Construct a new ModuleTypesBuilder
using the given validator.
Sourcepub fn reserve_wasm_signatures(&mut self, amt: usize)
pub fn reserve_wasm_signatures(&mut self, amt: usize)
Reserves space for amt
more type signatures.
Sourcepub fn validator_id(&self) -> ValidatorId
pub fn validator_id(&self) -> ValidatorId
Get the id of the validator that this builder is configured for.
Sourcepub fn intern_rec_group(
&mut self,
validator_types: TypesRef<'_>,
rec_group_id: RecGroupId,
) -> WasmResult<ModuleInternedRecGroupIndex>
pub fn intern_rec_group( &mut self, validator_types: TypesRef<'_>, rec_group_id: RecGroupId, ) -> WasmResult<ModuleInternedRecGroupIndex>
Intern a recursion group and all of its types into this builder.
If the recursion group has already been interned, then it is reused.
Panics if given types from a different validator than the one that this builder is associated with.
Sourcepub fn intern_type(
&mut self,
validator_types: TypesRef<'_>,
id: CoreTypeId,
) -> WasmResult<ModuleInternedTypeIndex>
pub fn intern_type( &mut self, validator_types: TypesRef<'_>, id: CoreTypeId, ) -> WasmResult<ModuleInternedTypeIndex>
Intern a type into this builder and get its Wasmtime index.
This will intern not only the single given type, but the type’s entire rec group. This helper method is provided as a convenience so that callers don’t have to get the type’s rec group, intern the rec group, and then look up the Wasmtime index for the original type themselves.
Sourcepub fn define_exception_type_for_tag(
&mut self,
for_func_ty: ModuleInternedTypeIndex,
) -> ModuleInternedTypeIndex
pub fn define_exception_type_for_tag( &mut self, for_func_ty: ModuleInternedTypeIndex, ) -> ModuleInternedTypeIndex
Define a new exception type when we see a function type used in a tag.
The returned ModuleInternedTypeIndex
gives us a Wasmtime
type which corresponds to the exception object layout, but
note that these types do not exist in the Wasm spec: at the
Wasm level, only function types exist (and tags and exception
instructions reference them). For implementation reasons, we
need a separate type to describe the exception object layout,
and this registers and provides that type.
Sourcepub fn finish(self) -> ModuleTypes
pub fn finish(self) -> ModuleTypes
Returns the result ModuleTypes
of this builder.
Sourcepub fn rec_group_elements(
&self,
rec_group: ModuleInternedRecGroupIndex,
) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex> + use<>
pub fn rec_group_elements( &self, rec_group: ModuleInternedRecGroupIndex, ) -> impl ExactSizeIterator<Item = ModuleInternedTypeIndex> + use<>
Get the elements within an already-defined rec group.
Sourcepub fn wasm_types(
&self,
) -> impl Iterator<Item = (ModuleInternedTypeIndex, &WasmSubType)>
pub fn wasm_types( &self, ) -> impl Iterator<Item = (ModuleInternedTypeIndex, &WasmSubType)>
Returns an iterator over all the unique wasm types defined thus far within this builder.
Sourcepub fn trampoline_types(
&self,
) -> impl Iterator<Item = (ModuleInternedTypeIndex, ModuleInternedTypeIndex)> + '_
pub fn trampoline_types( &self, ) -> impl Iterator<Item = (ModuleInternedTypeIndex, ModuleInternedTypeIndex)> + '_
Get an iterator over all function types and their associated trampoline type.
Sourcepub fn trampoline_type(
&self,
ty: ModuleInternedTypeIndex,
) -> ModuleInternedTypeIndex
pub fn trampoline_type( &self, ty: ModuleInternedTypeIndex, ) -> ModuleInternedTypeIndex
Get the associated trampoline type for the given function type.
Sourcepub fn unwrap_struct(
&self,
ty: ModuleInternedTypeIndex,
) -> WasmResult<&WasmStructType>
pub fn unwrap_struct( &self, ty: ModuleInternedTypeIndex, ) -> WasmResult<&WasmStructType>
Get and unwrap a WasmStructType
for the given struct index.
§Panics
Panics if the unwrapped type is not a struct.
§Errors
For now, fails with an unsupported error if the type is shared.
Sourcepub fn unwrap_array(
&self,
interned_ty: ModuleInternedTypeIndex,
) -> WasmResult<&WasmArrayType>
pub fn unwrap_array( &self, interned_ty: ModuleInternedTypeIndex, ) -> WasmResult<&WasmArrayType>
Get and unwrap a WasmArrayType
for the given array index.
§Panics
Panics if the unwrapped type is not an array.
§Errors
For now, fails with an unsupported error if the type is shared.
Sourcepub fn unwrap_exn(
&self,
interned_ty: ModuleInternedTypeIndex,
) -> WasmResult<&WasmExnType>
pub fn unwrap_exn( &self, interned_ty: ModuleInternedTypeIndex, ) -> WasmResult<&WasmExnType>
Get and unwrap a WasmExnType
for the given exception-type index.
§Panics
Panics if the unwrapped type is not an exception type.
§Errors
For now, fails with an unsupported error if the type is shared.
Sourcepub fn unwrap_func(
&self,
interned_ty: ModuleInternedTypeIndex,
) -> WasmResult<&WasmFuncType>
pub fn unwrap_func( &self, interned_ty: ModuleInternedTypeIndex, ) -> WasmResult<&WasmFuncType>
Get and unwrap a WasmFuncType
for the given function-type index.
§Panics
Panics if the unwrapped type is not a function type.
§Errors
For now, fails with an unsupported error if the type is shared.