MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / wast_v128_to_bytes

Function wast_v128_to_bytes

crates/cli/src/wast_runner.rs:761–775  ·  view source on GitHub ↗
(i: wast::core::V128Pattern)

Source from the content-addressed store, hash-verified

759}
760
761fn wast_v128_to_bytes(i: wast::core::V128Pattern) -> [u8; 16] {
762 let res: Vec<u8> = match i {
763 wast::core::V128Pattern::F32x4(f) => {
764 f.iter().flat_map(|v| nanpattern2tinywasmvalue(*v).unwrap().as_f32().unwrap().to_le_bytes()).collect()
765 }
766 wast::core::V128Pattern::F64x2(f) => {
767 f.iter().flat_map(|v| nanpattern2tinywasmvalue(*v).unwrap().as_f64().unwrap().to_le_bytes()).collect()
768 }
769 wast::core::V128Pattern::I16x8(f) => f.iter().flat_map(|v| v.to_le_bytes()).collect(),
770 wast::core::V128Pattern::I32x4(f) => f.iter().flat_map(|v| v.to_le_bytes()).collect(),
771 wast::core::V128Pattern::I64x2(f) => f.iter().flat_map(|v| v.to_le_bytes()).collect(),
772 wast::core::V128Pattern::I8x16(f) => f.iter().flat_map(|v| v.to_le_bytes()).collect(),
773 };
774 res.try_into().unwrap()
775}
776
777fn wastret2tinywasmvalues(ret: wast::WastRet) -> Result<Vec<WasmValue>> {
778 let wast::WastRet::Core(ret) = ret else { bail!("unsupported arg type") };

Callers 1

Calls 4

nanpattern2tinywasmvalueFunction · 0.85
to_le_bytesMethod · 0.80
as_f32Method · 0.80
as_f64Method · 0.80

Tested by

no test coverage detected