mirror of
https://github.com/fluencelabs/interface-types
synced 2025-06-11 14:01:24 +00:00
chore(interface-types) Simplify the executable_instruction
macro.
This commit is contained in:
@ -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(())
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -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,
|
||||
))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -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,
|
||||
))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -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,
|
||||
))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -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
|
||||
))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -37,7 +37,7 @@ macro_rules! executable_instruction {
|
||||
Memory: wasm::structures::Memory,
|
||||
Instance: wasm::structures::Instance<Export, LocalImport, Memory>,
|
||||
{
|
||||
$implementation
|
||||
Box::new($implementation)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user