compiler: Add FramePointer::ratchet

This commit is contained in:
Jubilee Young 2024-05-04 15:41:52 -07:00
parent acb62737ac
commit 7c0b5cf99f

View File

@ -1413,6 +1413,20 @@ pub enum FramePointer {
MayOmit,
}
impl FramePointer {
/// It is intended that the "force frame pointer" transition is "one way"
/// so this convenience assures such if used
#[inline]
pub fn ratchet(&mut self, rhs: FramePointer) -> FramePointer {
*self = match (*self, rhs) {
(FramePointer::Always, _) | (_, FramePointer::Always) => FramePointer::Always,
(FramePointer::NonLeaf, _) | (_, FramePointer::NonLeaf) => FramePointer::NonLeaf,
_ => FramePointer::MayOmit,
};
*self
}
}
impl FromStr for FramePointer {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {