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

Function function_interposition_renamed

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

Source from the content-addressed store, hash-verified

130#[test]
131#[cfg_attr(miri, ignore)]
132fn function_interposition_renamed() -> Result<()> {
133 let mut store = Store::<()>::default();
134 let mut linker = Linker::new(store.engine());
135 linker.allow_shadowing(true);
136 let mut module = Module::new(
137 store.engine(),
138 r#"(module (func (export "export") (result i32) (i32.const 7)))"#,
139 )?;
140 for _ in 0..4 {
141 let instance = linker.instantiate(&mut store, &module)?;
142 let export = instance.get_export(&mut store, "export").unwrap().clone();
143 linker.define(&mut store, "red", "green", export)?;
144 module = Module::new(
145 store.engine(),
146 r#"(module
147 (import "red" "green" (func (result i32)))
148 (func (export "export") (result i32) (i32.mul (call 0) (i32.const 2)))
149 )"#,
150 )?;
151 }
152 let instance = linker.instantiate(&mut store, &module)?;
153 let func = instance.get_func(&mut store, "export").unwrap();
154 let func = func.typed::<(), i32>(&store)?;
155 assert_eq!(func.call(&mut store, ())?, 112);
156 Ok(())
157}
158
159// Similar to `function_interposition`, but use `Linker::instance` instead of
160// `Linker::define`.

Callers

nothing calls this directly

Calls 10

OkFunction · 0.85
newFunction · 0.50
engineMethod · 0.45
allow_shadowingMethod · 0.45
instantiateMethod · 0.45
cloneMethod · 0.45
unwrapMethod · 0.45
get_exportMethod · 0.45
defineMethod · 0.45
get_funcMethod · 0.45

Tested by

no test coverage detected