#[repr(u8)]pub enum Overflow {
Error = 0,
Wrap = 1,
Trap = 2,
Promote = 3,
}Expand description
The overflow policy: what integer add, sub, mul, neg, abs, signed
MIN / -1, and int_cast do when the exact result does not fit.
Promote exists for dynamic-value operations only
(OPS §2, added for Mox/PHP): it is valid only where the result
register is dyn. ModuleBuilder refuses it
on a statically typed destination it can see, and the verifier
(v0.5) refuses it everywhere else.
§Examples
use bytecode_lang::Overflow;
assert_eq!(Overflow::default(), Overflow::Error);
assert_eq!(Overflow::Wrap.to_string(), "wrap");
assert_eq!(Overflow::from_code(3), Some(Overflow::Promote));Variants§
Error = 0
Raise ArithOverflow (E0001) through the language’s error model.
Wrap = 1
Two’s-complement wrap-around; never an error.
Trap = 2
Abort the program with ArithOverflow (E0001); not catchable.
Promote = 3
The result is the f64 nearest the exact mathematical result
(ties to even), as PHP does for PHP_INT_MAX + 1. Dynamic
results only.
Implementations§
Trait Implementations§
impl Copy for Overflow
impl Eq for Overflow
Source§impl Ord for Overflow
impl Ord for Overflow
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Overflow
impl PartialOrd for Overflow
impl StructuralPartialEq for Overflow
Auto Trait Implementations§
impl Freeze for Overflow
impl RefUnwindSafe for Overflow
impl Send for Overflow
impl Sync for Overflow
impl Unpin for Overflow
impl UnsafeUnpin for Overflow
impl UnwindSafe for Overflow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more