components: Fix support for 0-sized flags (#4560)

This commit goes through and updates support in the various argument
passing routines to support 0-sized flags. A bit of a degenerate case
but clarified in WebAssembly/component-model#76 as intentional.
This commit is contained in:
Alex Crichton
2022-08-01 11:05:09 -05:00
committed by GitHub
parent 05e6abf2f6
commit 893fadb485
9 changed files with 59 additions and 9 deletions

View File

@@ -700,6 +700,7 @@ impl Compiler<'_, '_> {
assert_eq!(src_ty.names, dst_ty.names);
let cnt = src_ty.names.len();
match FlagsSize::from_count(cnt) {
FlagsSize::Size0 => {}
FlagsSize::Size1 => {
let mask = if cnt == 8 { 0xff } else { (1 << cnt) - 1 };
self.convert_u8_mask(src, dst, mask);