feat(std): Expose functions for overflowing/saturating arithmetic in std.int
and std.byte
@@ -387,6 +387,17 @@ pub fn load_byte(vm: &Thread) -> Result<ExternModule> {
to_be => primitive!(1, std::byte::prim::to_be),
to_le => primitive!(1, std::byte::prim::to_le),
pow => primitive!(2, std::byte::prim::pow),
+ saturating_add => primitive!(2, std::byte::prim::saturating_add),
+ saturating_sub => primitive!(2, std::byte::prim::saturating_sub),
+ saturating_mul => primitive!(2, std::byte::prim::saturating_mul),
+ wrapping_add => primitive!(2, std::byte::prim::wrapping_add),
+ wrapping_sub => primitive!(2, std::byte::prim::wrapping_sub),
+ wrapping_mul => primitive!(2, std::byte::prim::wrapping_mul),
+ wrapping_div => primitive!(2, std::byte::prim::wrapping_div),
+ overflowing_add => primitive!(2, std::byte::prim::overflowing_add),
+ overflowing_sub => primitive!(2, std::byte::prim::overflowing_sub),
+ overflowing_mul => primitive!(2, std::byte::prim::overflowing_mul),
+ overflowing_div => primitive!(2, std::byte::prim::overflowing_div),
from_int => primitive!(1, "std.byte.prim.from_int", |i: VmInt| i as u8),
parse => primitive!(1, "std.byte.prim.parse", parse::<u8>)
},
@@ -419,6 +430,21 @@ pub fn load_int(vm: &Thread) -> Result<ExternModule> {
to_le => primitive!(1, std::int::prim::to_le),
pow => primitive!(2, std::int::prim::pow),
abs => primitive!(1, std::int::prim::abs),
+ saturating_add => primitive!(2, std::int::prim::saturating_add),
+ saturating_sub => primitive!(2, std::int::prim::saturating_sub),
+ saturating_mul => primitive!(2, std::int::prim::saturating_mul),
+ wrapping_add => primitive!(2, std::int::prim::wrapping_add),
+ wrapping_sub => primitive!(2, std::int::prim::wrapping_sub),
+ wrapping_mul => primitive!(2, std::int::prim::wrapping_mul),
+ wrapping_div => primitive!(2, std::int::prim::wrapping_div),
+ wrapping_abs => primitive!(1, std::int::prim::wrapping_abs),
+ wrapping_negate => primitive!(1, "std.int.prim.wrapping_negate", std::int::prim::overflowing_neg),
+ overflowing_add => primitive!(2, std::int::prim::overflowing_add),
+ overflowing_sub => primitive!(2, std::int::prim::overflowing_sub),
+ overflowing_mul => primitive!(2, std::int::prim::overflowing_mul),
+ overflowing_div => primitive!(2, std::int::prim::overflowing_div),
+ overflowing_abs => primitive!(1, std::int::prim::overflowing_abs),
+ overflowing_negate => primitive!(1, "std.int.prim.overflowing_negate", std::int::prim::overflowing_neg),
signum => primitive!(1, std::int::prim::signum),
is_positive => primitive!(1, std::int::prim::is_positive),
is_negative => primitive!(1, std::int::prim::is_negative),
