Merge branch 'fix/emscripten-translate' of github.com:wasmerio/wasmer into fix/emscripten-translate

This commit is contained in:
Lachlan Sneff 2019-02-04 15:08:10 -08:00
commit 563cda7ba2
6 changed files with 8 additions and 9 deletions

View File

@ -238,7 +238,7 @@ impl Instance {
self.call_with_index(func_index, args) self.call_with_index(func_index, args)
} }
/// Returns a immutable reference to the /// Returns an immutable reference to the
/// [`Ctx`] used by this Instance. /// [`Ctx`] used by this Instance.
/// ///
/// [`Ctx`]: struct.Ctx.html /// [`Ctx`]: struct.Ctx.html
@ -254,7 +254,7 @@ impl Instance {
unsafe { &mut *self.inner.vmctx } unsafe { &mut *self.inner.vmctx }
} }
/// Returns a iterator over all of the items /// Returns an iterator over all of the items
/// exported from this instance. /// exported from this instance.
pub fn exports(&mut self) -> ExportIter { pub fn exports(&mut self) -> ExportIter {
ExportIter::new(&self.module, &mut self.inner) ExportIter::new(&self.module, &mut self.inner)

View File

@ -36,7 +36,7 @@ fn main() -> Result<()> {
let import_object = imports! { let import_object = imports! {
"env" => { "env" => {
"print_i32" => func!(print_num), "print_num" => func!(print_num),
"memory" => memory, "memory" => memory,
"global" => global, "global" => global,
"table" => table, "table" => table,
@ -51,7 +51,6 @@ fn main() -> Result<()> {
let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &CraneliftCompiler::new())?; let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &CraneliftCompiler::new())?;
let outer_instance = outer_module.instantiate(&outer_imports)?; let outer_instance = outer_module.instantiate(&outer_imports)?;
let ret = outer_instance.call("main", &[Value::I32(42)])?; let ret = outer_instance.call("main", &[Value::I32(42)])?;
println!("ret: {:?}", ret); println!("ret: {:?}", ret);

View File

@ -47,7 +47,7 @@ pub fn generate_imports() -> ImportObject {
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new()) let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
.expect("WASM can't be compiled"); .expect("WASM can't be compiled");
let instance = module let instance = module
.instantiate(ImportObject::new()) .instantiate(&ImportObject::new())
.expect("WASM can't be instantiated"); .expect("WASM can't be instantiated");
let mut imports = ImportObject::new(); let mut imports = ImportObject::new();
imports.register("spectest", instance); imports.register("spectest", instance);

View File

@ -25,12 +25,12 @@ mod tests {
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new()) let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
.expect("WASM can't be compiled"); .expect("WASM can't be compiled");
let instance = module let instance = module
.instantiate(ImportObject::new()) .instantiate(&ImportObject::new())
.expect("WASM can't be instantiated"); .expect("WASM can't be instantiated");
let result = instance.call("stack-overflow", &[]); let result = instance.call("stack-overflow", &[]);
match result { match result {
Err(err) => match *err { Err(err) => match err {
CallError::Runtime(RuntimeError::Unknown { msg }) => { CallError::Runtime(RuntimeError::Unknown { msg }) => {
assert!(!msg.contains("segmentation violation")); assert!(!msg.contains("segmentation violation"));
assert!(!msg.contains("bus error")); assert!(!msg.contains("bus error"));

View File

@ -85,7 +85,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
}; };
let mut instance = module let mut instance = module
.instantiate(import_object) .instantiate(&import_object)
.map_err(|e| format!("Can't instantiate module: {:?}", e))?; .map_err(|e| format!("Can't instantiate module: {:?}", e))?;
webassembly::run_instance( webassembly::run_instance(

View File

@ -41,7 +41,7 @@ pub fn instantiate(buffer_source: &[u8], import_object: ImportObject) -> Result<
let module = compile(&buffer_source[..])?; let module = compile(&buffer_source[..])?;
debug!("webassembly - instantiating"); debug!("webassembly - instantiating");
let instance = module.instantiate(import_object)?; let instance = module.instantiate(&import_object)?;
debug!("webassembly - instance created"); debug!("webassembly - instance created");
Ok(ResultObject { Ok(ResultObject {