Browse Source

Assertion in CachedStateFlags

Fabian 3 years ago
parent
commit
b1025783a1
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/rust/state_flags.rs

+ 8 - 1
src/rust/state_flags.rs

@@ -10,7 +10,14 @@ impl CachedStateFlags {
 
     pub const EMPTY: CachedStateFlags = CachedStateFlags(0);
 
-    pub fn of_u32(f: u32) -> CachedStateFlags { CachedStateFlags(f as u8) }
+    pub fn of_u32(f: u32) -> CachedStateFlags {
+        dbg_assert!(
+            f as u8
+                & !(Self::MASK_IS_32 | Self::MASK_SS32 | Self::MASK_CPL3 | Self::MASK_FLAT_SEGS)
+                == 0
+        );
+        CachedStateFlags(f as u8)
+    }
     pub fn to_u32(&self) -> u32 { self.0 as u32 }
 
     pub fn cpl3(&self) -> bool { self.0 & CachedStateFlags::MASK_CPL3 != 0 }