Struct wasmparser::types::SubtypeCx

source ·
pub struct SubtypeCx<'a> {
    pub a: SubtypeArena<'a>,
    pub b: SubtypeArena<'a>,
}
Expand description

Helper structure used to perform subtyping computations.

This type is used whenever a subtype needs to be tested in one direction or the other. The methods of this type are the various entry points for subtyping.

Internally this contains arenas for two lists of types. The a arena is intended to be used for lookup of the first argument to all of the methods below, and the b arena is used for lookup of the second argument.

Arenas here are used specifically for component-based subtyping queries. In these situations new types must be created based on substitution mappings, but the types all have temporary lifetimes. Everything in these arenas is thrown away once the subtyping computation has finished.

Note that this subtyping context also explicitly supports being created from to different lists a and b originally, for testing subtyping between two different components for example.

Fields§

§a: SubtypeArena<'a>

Lookup arena for first type argument

§b: SubtypeArena<'a>

Lookup arena for second type argument

Implementations§

source§

impl<'a> SubtypeCx<'a>

source

pub fn new_with_refs(a: TypesRef<'a>, b: TypesRef<'a>) -> SubtypeCx<'a>

Create a new instance with the specified type lists

source

pub fn swap(&mut self)

Swap the type lists

source

pub fn component_entity_type( &mut self, a: &ComponentEntityType, b: &ComponentEntityType, offset: usize ) -> Result<()>

Tests whether a is a subtype of b.

Errors are reported at the offset specified.

source

pub fn component_type( &mut self, a: ComponentTypeId, b: ComponentTypeId, offset: usize ) -> Result<()>

Tests whether a is a subtype of b.

Errors are reported at the offset specified.

source

pub fn component_instance_type( &mut self, a_id: ComponentInstanceTypeId, b_id: ComponentInstanceTypeId, offset: usize ) -> Result<()>

Tests whether a is a subtype of b.

Errors are reported at the offset specified.

source

pub fn component_func_type( &mut self, a: ComponentFuncTypeId, b: ComponentFuncTypeId, offset: usize ) -> Result<()>

Tests whether a is a subtype of b.

Errors are reported at the offset specified.

source

pub fn module_type( &mut self, a: ComponentCoreModuleTypeId, b: ComponentCoreModuleTypeId, offset: usize ) -> Result<()>

Tests whether a is a subtype of b.

Errors are reported at the offset specified.

source

pub fn component_any_type_id( &mut self, a: ComponentAnyTypeId, b: ComponentAnyTypeId, offset: usize ) -> Result<()>

Tests whether a is a subtype of b.

Errors are reported at the offset specified.

source

pub fn open_instance_type( &mut self, a: &IndexMap<String, ComponentEntityType>, b: ComponentTypeId, kind: ExternKind, offset: usize ) -> Result<Remapping>

The building block for subtyping checks when components are instantiated and when components are tested if they’re subtypes of each other.

This method takes a number of arguments:

  • a - this is a list of typed items which can be thought of as concrete values to test against b.
  • b - this TypeId must point to Type::Component.
  • kind - indicates whether the imports or exports of b are being tested against for the values in a.
  • offset - the binary offset at which to report errors if one happens.

This will attempt to determine if the items in a satisfy the signature required by the kind items of b. For example component instantiation will have a as the list of arguments provided to instantiation, b is the component being instantiated, and kind is ExternKind::Import.

This function, if successful, will return a mapping of the resources in b to the resources in a provided. This mapping is guaranteed to contain all the resources for b (all imported resources for ExternKind::Import or all defined resources for ExternKind::Export).

Auto Trait Implementations§

§

impl<'a> Freeze for SubtypeCx<'a>

§

impl<'a> RefUnwindSafe for SubtypeCx<'a>

§

impl<'a> Send for SubtypeCx<'a>

§

impl<'a> Sync for SubtypeCx<'a>

§

impl<'a> Unpin for SubtypeCx<'a>

§

impl<'a> UnwindSafe for SubtypeCx<'a>

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>,

§

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>,

§

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.