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

Function module_interposition

tests/all/linker.rs:163–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161#[test]
162#[cfg_attr(miri, ignore)]
163fn module_interposition() -> Result<()> {
164 let mut store = Store::<()>::default();
165 let mut linker = Linker::new(store.engine());
166 linker.allow_shadowing(true);
167 let mut module = Module::new(
168 store.engine(),
169 r#"(module (func (export "export") (result i32) (i32.const 7)))"#,
170 )?;
171 for _ in 0..4 {
172 let instance = linker.instantiate(&mut store, &module)?;
173 linker.instance(&mut store, "instance", instance)?;
174 module = Module::new(
175 store.engine(),
176 r#"(module
177 (import "instance" "export" (func (result i32)))
178 (func (export "export") (result i32) (i32.mul (call 0) (i32.const 2)))
179 )"#,
180 )?;
181 }
182 let instance = linker.instantiate(&mut store, &module)?;
183 let func = instance
184 .get_export(&mut store, "export")
185 .unwrap()
186 .into_func()
187 .unwrap();
188 let func = func.typed::<(), i32>(&store)?;
189 assert_eq!(func.call(&mut store, ())?, 112);
190 Ok(())
191}
192
193#[test]
194#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 9

OkFunction · 0.85
newFunction · 0.50
engineMethod · 0.45
allow_shadowingMethod · 0.45
instantiateMethod · 0.45
instanceMethod · 0.45
unwrapMethod · 0.45
into_funcMethod · 0.45
get_exportMethod · 0.45

Tested by

no test coverage detected