chore(interface-types) Simplify the executable_instruction macro.

This commit is contained in:
Ivan Enderlin
2019-09-26 14:17:43 +02:00
parent c042050497
commit 1478ad8b4e
6 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
executable_instruction!(
argument_get(index: u64, instruction_name: String) -> _ {
Box::new(move |runtime| -> _ {
move |runtime| -> _ {
let invocation_inputs = runtime.invocation_inputs;
if index >= (invocation_inputs.len() as u64) {
@ -13,7 +13,7 @@ executable_instruction!(
runtime.stack.push(invocation_inputs[index as usize].clone());
Ok(())
})
}
}
);

View File

@ -5,7 +5,7 @@ use crate::interpreter::wasm::{
executable_instruction!(
call(function_index: usize, instruction_name: String) -> _ {
Box::new(move |runtime| -> _ {
move |runtime| -> _ {
let instance = runtime.wasm_instance;
let index = FunctionIndex::new(function_index);
@ -58,7 +58,7 @@ executable_instruction!(
function_index,
))
}
})
}
}
);

View File

@ -2,7 +2,7 @@ use crate::interpreter::wasm::values::InterfaceType;
executable_instruction!(
call_export(export_name: String, instruction_name: String) -> _ {
Box::new(move |runtime| -> _ {
move |runtime| -> _ {
let instance = runtime.wasm_instance;
match instance.export(&export_name) {
@ -54,7 +54,7 @@ executable_instruction!(
export_name,
))
}
})
}
}
);

View File

@ -3,7 +3,7 @@ use std::{cell::Cell, convert::TryFrom};
executable_instruction!(
read_utf8(instruction_name: String) -> _ {
Box::new(move |runtime| -> _ {
move |runtime| -> _ {
match runtime.stack.pop(2) {
Some(inputs) => match runtime.wasm_instance.memory(0) {
Some(memory) => {
@ -48,7 +48,7 @@ executable_instruction!(
instruction_name,
))
}
})
}
}
);

View File

@ -3,7 +3,7 @@ use std::convert::TryInto;
executable_instruction!(
write_utf8(allocator_name: String, instruction_name: String) -> _ {
Box::new(move |runtime| -> _ {
move |runtime| -> _ {
let instance = runtime.wasm_instance;
match instance.export(&allocator_name) {
@ -67,7 +67,7 @@ executable_instruction!(
allocator_name
))
}
})
}
}
);

View File

@ -37,7 +37,7 @@ macro_rules! executable_instruction {
Memory: wasm::structures::Memory,
Instance: wasm::structures::Instance<Export, LocalImport, Memory>,
{
$implementation
Box::new($implementation)
}
};
}