Don't require Store in Instance constructor (#810)

* Don't require `Store` in `Instance` constructor

This can be inferred from the `Module` argument. Additionally add a
`store` accessor to an `Instance` in case it's needed to instantiate
another `Module`.

cc #708

* Update more constructors

* Fix a doctest

* Don't ignore store in `wasm_instance_new`

* Run rustfmt
This commit is contained in:
Alex Crichton
2020-01-13 17:50:57 -06:00
committed by GitHub
parent f592811c9a
commit 420dcd76fd
19 changed files with 56 additions and 28 deletions

View File

@@ -55,7 +55,7 @@ fn same_import_names_still_distinct() -> anyhow::Result<()> {
)
.into(),
];
let instance = Instance::new(&store, &module, &imports)?;
let instance = Instance::new(&module, &imports)?;
let func = instance.find_export_by_name("foo").unwrap().func().unwrap();
let results = func.call(&[])?;

View File

@@ -47,7 +47,7 @@ fn test_import_calling_export() {
let imports = vec![callback_func.into()];
let instance =
Instance::new(&store, &module, imports.as_slice()).expect("failed to instantiate module");
Instance::new(&module, imports.as_slice()).expect("failed to instantiate module");
let exports = instance.exports();
assert!(!exports.is_empty());

View File

@@ -29,7 +29,7 @@ fn test_trap_return() -> Result<(), String> {
let hello_func = Func::new(&store, hello_type, Rc::new(HelloCallback));
let imports = vec![hello_func.into()];
let instance = Instance::new(&store, &module, &imports)
let instance = Instance::new(&module, &imports)
.map_err(|e| format!("failed to instantiate module: {:?}", e))?;
let run_func = instance.exports()[0]
.func()