Implement flags in fused adapters (#4549)

This implements the `flags` type for fused adapters and converting
between modules. The main logic here is handling the variable size of
flags in addition to the masking which happens to ignore unrelated bits
when the values pass through the canonical ABI.
This commit is contained in:
Alex Crichton
2022-07-28 14:56:32 -05:00
committed by GitHub
parent fb7d51033c
commit 32979b2714
4 changed files with 280 additions and 19 deletions

View File

@@ -660,7 +660,7 @@ impl ComponentTypesBuilder {
let flags = TypeFlags {
names: flags.iter().map(|s| s.to_string()).collect(),
};
intern(&mut self.flags, &mut self.component_types.flags, flags)
self.add_flags_type(flags)
}
fn enum_type(&mut self, variants: &[&str]) -> TypeEnumIndex {
@@ -699,6 +699,11 @@ impl ComponentTypesBuilder {
intern(&mut self.records, &mut self.component_types.records, ty)
}
/// Interns a new flags type within this type information.
pub fn add_flags_type(&mut self, ty: TypeFlags) -> TypeFlagsIndex {
intern(&mut self.flags, &mut self.component_types.flags, ty)
}
/// Interns a new tuple type within this type information.
pub fn add_tuple_type(&mut self, ty: TypeTuple) -> TypeTupleIndex {
intern(&mut self.tuples, &mut self.component_types.tuples, ty)