MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / srem

Method srem

cranelift/interpreter/src/value.rs:598–612  ·  view source on GitHub ↗
(self, other: Self)

Source from the content-addressed store, hash-verified

596 }
597
598 fn srem(self, other: Self) -> ValueResult<Self> {
599 let denominator = other.clone().into_int_signed()?;
600
601 // Check if we are dividing INT_MIN / -1. This causes an integer overflow trap.
602 let min = DataValueExt::int(1i128 << (self.ty().bits() - 1), self.ty())?;
603 if self == min && denominator == -1 {
604 return Err(ValueError::IntegerOverflow);
605 }
606
607 if denominator == 0 {
608 return Err(ValueError::IntegerDivisionByZero);
609 }
610
611 binary_match!(%(&self, &other); [I8, I16, I32, I64, I128])
612 }
613
614 fn urem(self, other: Self) -> ValueResult<Self> {
615 let denominator = other.clone().into_int_unsigned()?;

Callers 1

translate_sremMethod · 0.80

Calls 4

into_int_signedMethod · 0.80
cloneMethod · 0.45
bitsMethod · 0.45
tyMethod · 0.45

Tested by

no test coverage detected