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

Method int

cranelift/interpreter/src/value.rs:258–271  ·  view source on GitHub ↗
(n: i128, ty: Type)

Source from the content-addressed store, hash-verified

256
257impl DataValueExt for DataValue {
258 fn int(n: i128, ty: Type) -> ValueResult<Self> {
259 if ty.is_vector() {
260 // match ensures graceful failure since read_from_slice_ne()
261 // panics on anything other than 8 and 16 bytes
262 match ty.bytes() {
263 8 | 16 => Ok(DataValue::read_from_slice_ne(&n.to_ne_bytes(), ty)),
264 _ => Err(ValueError::InvalidType(ValueTypeClass::Vector, ty)),
265 }
266 } else if ty.is_int() {
267 DataValue::from_integer(n, ty).map_err(|_| ValueError::InvalidValue(ty))
268 } else {
269 Err(ValueError::InvalidType(ValueTypeClass::Integer, ty))
270 }
271 }
272
273 fn into_int_signed(self) -> ValueResult<i128> {
274 match self {

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
is_vectorMethod · 0.45
bytesMethod · 0.45
is_intMethod · 0.45

Tested by

no test coverage detected