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

Function echo_component

crates/c-api/tests/component/values.cc:20–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using wasmtime::Store;
19
20static std::string echo_component(std::string_view type, std::string_view func,
21 std::string_view host_params) {
22 return std::format(
23 R"END(
24(component
25 (type $Foo' {})
26 (import "foo" (type $Foo (eq $Foo')))
27 (import "do" (func $do (param "a" $Foo) (result $Foo)))
28 (core module $libc
29 (memory (export "memory") 1)
30 {}
31 )
32 (core instance $libc (instantiate $libc))
33 (core func $do_lower (canon lower (func $do) (memory $libc "memory") (realloc (func $libc "realloc"))))
34
35 (core module $doer
36 (import "host" "do" (func $do {}))
37 (import "libc" "memory" (memory 1))
38 (import "libc" "realloc" (func $realloc (param i32 i32 i32 i32) (result i32)))
39
40 (func (export "call")
41 {})
42 )
43 (core instance $doer (instantiate $doer
44 (with "host" (instance (export "do" (func $do_lower))))
45 (with "libc" (instance $libc))
46 ))
47
48 (func $call
49 (param "a" $Foo)
50 (result $Foo)
51 (canon lift
52 (core func $doer "call")
53 (memory $libc "memory")
54 (realloc (func $libc "realloc")))
55 )
56
57 (export "call" (func $call))
58)
59 )END",
60 type, REALLOC_AND_FREE, host_params, func);
61}
62
63struct Context {
64 Store store;

Callers 1

createFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected