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

Function wastarg2tinywasmvalue

crates/cli/src/wast_runner.rs:738–759  ·  view source on GitHub ↗
(arg: wast::WastArg)

Source from the content-addressed store, hash-verified

736}
737
738fn wastarg2tinywasmvalue(arg: wast::WastArg) -> Result<WasmValue> {
739 let wast::WastArg::Core(arg) = arg else { bail!("unsupported arg type: Component") };
740 use wast::core::WastArgCore::*;
741 Ok(match arg {
742 F32(f) => WasmValue::F32(f32::from_bits(f.bits)),
743 F64(f) => WasmValue::F64(f64::from_bits(f.bits)),
744 I32(i) => WasmValue::I32(i),
745 I64(i) => WasmValue::I64(i),
746 V128(i) => WasmValue::V128(i.to_le_bytes()),
747 RefExtern(v) => WasmValue::RefExtern(ExternRef::new(Some(v))),
748 RefNull(t) => match t {
749 wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Func } => {
750 WasmValue::RefFunc(FuncRef::null())
751 }
752 wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Extern } => {
753 WasmValue::RefExtern(ExternRef::null())
754 }
755 _ => bail!("unsupported arg type: refnull: {:?}", t),
756 },
757 RefHost(_) => bail!("unsupported arg type: RefHost"),
758 })
759}
760
761fn wast_v128_to_bytes(i: wast::core::V128Pattern) -> [u8; 16] {
762 let res: Vec<u8> = match i {

Callers

nothing calls this directly

Calls 1

to_le_bytesMethod · 0.80

Tested by

no test coverage detected