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

Function wastretcore2tinywasmvalue

crates/cli/src/wast_runner.rs:787–811  ·  view source on GitHub ↗
(ret: wast::core::WastRetCore)

Source from the content-addressed store, hash-verified

785}
786
787fn wastretcore2tinywasmvalue(ret: wast::core::WastRetCore) -> Result<WasmValue> {
788 use wast::core::WastRetCore::{F32, F64, I32, I64, RefExtern, RefFunc, RefNull, V128};
789 Ok(match ret {
790 F32(f) => nanpattern2tinywasmvalue(f)?,
791 F64(f) => nanpattern2tinywasmvalue(f)?,
792 I32(i) => WasmValue::I32(i),
793 I64(i) => WasmValue::I64(i),
794 V128(i) => WasmValue::V128(wast_v128_to_bytes(i)),
795 RefNull(t) => match t {
796 Some(wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Func }) => {
797 WasmValue::RefFunc(FuncRef::null())
798 }
799 Some(wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Extern }) => {
800 WasmValue::RefExtern(ExternRef::null())
801 }
802 _ => bail!("unsupported arg type: refnull: {:?}", t),
803 },
804 RefExtern(v) => WasmValue::RefExtern(ExternRef::new(v)),
805 RefFunc(v) => WasmValue::RefFunc(FuncRef::new(match v {
806 Some(wast::token::Index::Num(n, _)) => Some(n),
807 _ => bail!("unsupported arg type: reffunc: {:?}", v),
808 })),
809 a => bail!("unsupported arg type {:?}", a),
810 })
811}
812
813enum Bits {
814 U32(u32),

Callers

nothing calls this directly

Calls 2

nanpattern2tinywasmvalueFunction · 0.85
wast_v128_to_bytesFunction · 0.85

Tested by

no test coverage detected