Rework imports

This commit is contained in:
Lachlan Sneff
2019-01-12 22:02:19 -05:00
parent f5c5f777c0
commit a7ffb44bbc
73 changed files with 477 additions and 496 deletions

View File

@ -1,4 +1,3 @@
use std::rc::Rc;
use wabt::wat2wasm;
use wasmer_clif_backend::CraneliftCompiler;
use wasmer_runtime::{import::Imports, Instance};
@ -9,13 +8,13 @@ fn main() {
println!("result: {:?}", result);
}
fn generate_imports() -> Rc<Imports> {
fn generate_imports() -> Imports {
// let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
// let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
// let instance = module.instantiate(Rc::new(Imports::new())).expect("WASM can't be instantiated");
let imports = Imports::new();
// imports.register("spectest", instance);
Rc::new(imports)
imports
}
fn create_module_1() -> Instance {
@ -34,6 +33,6 @@ fn create_module_1() -> Instance {
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new())
.expect("WASM can't be compiled");
module
.instantiate(generate_imports())
.instantiate(&generate_imports())
.expect("WASM can't be instantiated")
}