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

Function fancy_list

tests/all/component_model/func.rs:2281–2379  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2279
2280#[test]
2281fn fancy_list() -> Result<()> {
2282 let component = format!(
2283 r#"(component
2284 (core module $m
2285 (memory (export "memory") 1)
2286 (func (export "take") (param i32 i32) (result i32)
2287 (local $base i32)
2288 (local.set $base
2289 (call $realloc
2290 (i32.const 0)
2291 (i32.const 0)
2292 (i32.const 4)
2293 (i32.const 16)))
2294
2295 (i32.store offset=0
2296 (local.get $base)
2297 (local.get 0))
2298 (i32.store offset=4
2299 (local.get $base)
2300 (local.get 1))
2301 (i32.store offset=8
2302 (local.get $base)
2303 (i32.const 0))
2304 (i32.store offset=12
2305 (local.get $base)
2306 (i32.mul
2307 (memory.size)
2308 (i32.const 65536)))
2309
2310 (local.get $base)
2311 )
2312
2313 {REALLOC_AND_FREE}
2314 )
2315 (core instance $i (instantiate $m))
2316
2317 (type $a (option u8))
2318 (type $b (result (error string)))
2319 (type $input (list (tuple $a $b)))
2320 (func (export "take")
2321 (param "a" $input)
2322 (result (tuple u32 u32 (list u8)))
2323 (canon lift
2324 (core func $i "take")
2325 (memory $i "memory")
2326 (realloc (func $i "realloc"))
2327 )
2328 )
2329 )"#
2330 );
2331
2332 let engine = super::engine();
2333 let component = Component::new(&engine, component)?;
2334 let mut store = Store::new(&engine, ());
2335 let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
2336
2337 let func = instance
2338 .get_typed_func::<(&[(Option<u8>, Result<(), &str>)],), ((u32, u32, WasmList<u8>),)>(

Callers

nothing calls this directly

Calls 7

OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
instantiateMethod · 0.45
callMethod · 0.45
unwrapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected