Stream: git-wasmtime

Topic: wasmtime / Issue #1391 Use `Linker` in `*.wast` testing


view this post on Zulip Wasmtime GitHub notifications bot (Mar 24 2020 at 16:47):

github-actions[bot] commented on Issue #1391:

Subscribe to Label Action

This issue or pull request has been labeled: "wasmtime:api"

<details> <summary>Users Subscribed to "wasmtime:api"</summary>

</details>

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 24 2020 at 19:15):

sunfishcode commented on Issue #1391:

Should it be possible to do this with this?

fn interposition() -> Result<()> {
    let store = Store::default();
    let mut linker = Linker::new(&store);
    linker.allow_shadowing(true);
    let mut module = Module::new(&store, r#"(module (func (export "export") (result i32) (i32.const 7)))"#)?;
    for _ in 0..4 {
        let instance = linker.instantiate(&module)?;
        linker.define("red", "green", instance.get_export("export").unwrap().clone())?;
        module = Module::new(&store, r#"(module
            (import "red" "green" (func (result i32)))
            (func (export "export") (result i32) (i32.mul (call 0) (i32.const 2)))
        )"#)?;
    }
    let instance = linker.instantiate(&module)?;
    let func = instance.get_export("export").unwrap().func().unwrap();
    assert_eq!(func.get0::<i32>().unwrap()().unwrap(), 112);
    Ok(())
}

If so, can we add that as a test? If not, can you comment on what it would take to make this work?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 24 2020 at 19:23):

alexcrichton commented on Issue #1391:

@sunfishcode added the test, worked like a charm on the first try!


Last updated: Nov 22 2024 at 16:03 UTC