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>
impl<'a> SubtypeCx<'a>
sourcepub fn new_with_refs(a: TypesRef<'a>, b: TypesRef<'a>) -> SubtypeCx<'a>
pub fn new_with_refs(a: TypesRef<'a>, b: TypesRef<'a>) -> SubtypeCx<'a>
Create a new instance with the specified type lists
sourcepub fn component_entity_type(
&mut self,
a: &ComponentEntityType,
b: &ComponentEntityType,
offset: usize,
) -> Result<(), BinaryReaderError>
pub fn component_entity_type( &mut self, a: &ComponentEntityType, b: &ComponentEntityType, offset: usize, ) -> Result<(), BinaryReaderError>
Tests whether a
is a subtype of b
.
Errors are reported at the offset
specified.
sourcepub fn component_type(
&mut self,
a: ComponentTypeId,
b: ComponentTypeId,
offset: usize,
) -> Result<(), BinaryReaderError>
pub fn component_type( &mut self, a: ComponentTypeId, b: ComponentTypeId, offset: usize, ) -> Result<(), BinaryReaderError>
Tests whether a
is a subtype of b
.
Errors are reported at the offset
specified.
sourcepub fn component_instance_type(
&mut self,
a_id: ComponentInstanceTypeId,
b_id: ComponentInstanceTypeId,
offset: usize,
) -> Result<(), BinaryReaderError>
pub fn component_instance_type( &mut self, a_id: ComponentInstanceTypeId, b_id: ComponentInstanceTypeId, offset: usize, ) -> Result<(), BinaryReaderError>
Tests whether a
is a subtype of b
.
Errors are reported at the offset
specified.
sourcepub fn component_func_type(
&mut self,
a: ComponentFuncTypeId,
b: ComponentFuncTypeId,
offset: usize,
) -> Result<(), BinaryReaderError>
pub fn component_func_type( &mut self, a: ComponentFuncTypeId, b: ComponentFuncTypeId, offset: usize, ) -> Result<(), BinaryReaderError>
Tests whether a
is a subtype of b
.
Errors are reported at the offset
specified.
sourcepub fn module_type(
&mut self,
a: ComponentCoreModuleTypeId,
b: ComponentCoreModuleTypeId,
offset: usize,
) -> Result<(), BinaryReaderError>
pub fn module_type( &mut self, a: ComponentCoreModuleTypeId, b: ComponentCoreModuleTypeId, offset: usize, ) -> Result<(), BinaryReaderError>
Tests whether a
is a subtype of b
.
Errors are reported at the offset
specified.
sourcepub fn component_any_type_id(
&mut self,
a: ComponentAnyTypeId,
b: ComponentAnyTypeId,
offset: usize,
) -> Result<(), BinaryReaderError>
pub fn component_any_type_id( &mut self, a: ComponentAnyTypeId, b: ComponentAnyTypeId, offset: usize, ) -> Result<(), BinaryReaderError>
Tests whether a
is a subtype of b
.
Errors are reported at the offset
specified.
sourcepub fn open_instance_type(
&mut self,
a: &IndexMap<String, ComponentEntityType>,
b: ComponentTypeId,
kind: ExternKind,
offset: usize,
) -> Result<Remapping, BinaryReaderError>
pub fn open_instance_type( &mut self, a: &IndexMap<String, ComponentEntityType>, b: ComponentTypeId, kind: ExternKind, offset: usize, ) -> Result<Remapping, BinaryReaderError>
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 againstb
.b
- thisTypeId
must point toType::Component
.kind
- indicates whether theimports
orexports
ofb
are being tested against for the values ina
.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
).