1 use core::{
2     arch::wasm32::*,
3     ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not},
4 };
5 
6 #[derive(Copy, Clone, Debug)]
7 #[repr(transparent)]
8 pub struct Block(pub(super) v128);
9 
10 impl Block {
11     #[inline]
is_empty(self) -> bool12     pub fn is_empty(self) -> bool {
13         !v128_any_true(self.0)
14     }
15 
16     #[inline]
andnot(self, other: Self) -> Self17     pub fn andnot(self, other: Self) -> Self {
18         Self(v128_andnot(self.0, other.0))
19     }
20 }
21 
22 impl Not for Block {
23     type Output = Block;
24     #[inline]
not(self) -> Self::Output25     fn not(self) -> Self::Output {
26         Self(v128_xor(self.0, Self::ALL.0))
27     }
28 }
29 
30 impl BitAnd for Block {
31     type Output = Block;
32     #[inline]
bitand(self, other: Self) -> Self::Output33     fn bitand(self, other: Self) -> Self::Output {
34         Self(v128_and(self.0, other.0))
35     }
36 }
37 
38 impl BitAndAssign for Block {
39     #[inline]
bitand_assign(&mut self, other: Self)40     fn bitand_assign(&mut self, other: Self) {
41         self.0 = v128_and(self.0, other.0);
42     }
43 }
44 
45 impl BitOr for Block {
46     type Output = Block;
47     #[inline]
bitor(self, other: Self) -> Self::Output48     fn bitor(self, other: Self) -> Self::Output {
49         Self(v128_or(self.0, other.0))
50     }
51 }
52 
53 impl BitOrAssign for Block {
54     #[inline]
bitor_assign(&mut self, other: Self)55     fn bitor_assign(&mut self, other: Self) {
56         self.0 = v128_or(self.0, other.0);
57     }
58 }
59 
60 impl BitXor for Block {
61     type Output = Block;
62     #[inline]
bitxor(self, other: Self) -> Self::Output63     fn bitxor(self, other: Self) -> Self::Output {
64         Self(v128_xor(self.0, other.0))
65     }
66 }
67 
68 impl BitXorAssign for Block {
69     #[inline]
bitxor_assign(&mut self, other: Self)70     fn bitxor_assign(&mut self, other: Self) {
71         self.0 = v128_xor(self.0, other.0)
72     }
73 }
74 
75 impl PartialEq for Block {
76     #[inline]
eq(&self, other: &Self) -> bool77     fn eq(&self, other: &Self) -> bool {
78         !v128_any_true(v128_xor(self.0, other.0))
79     }
80 }
81