mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-18 17:10:52 +00:00
chore(interface-types) Fix clippy warnings.
This commit is contained in:
parent
39a817817b
commit
2237e628ab
@ -52,7 +52,7 @@ fn leb<'input, E: ParseError<&'input [u8]>>(input: &'input [u8]) -> IResult<&'in
|
||||
}
|
||||
|
||||
let (output, bytes) = match input.iter().position(|&byte| byte & 0x80 == 0) {
|
||||
Some(position) => (&input[position + 1..], &input[..position + 1]),
|
||||
Some(position) => (&input[position + 1..], &input[..=position]),
|
||||
None => (&[] as &[u8], input),
|
||||
};
|
||||
|
||||
@ -61,7 +61,7 @@ fn leb<'input, E: ParseError<&'input [u8]>>(input: &'input [u8]) -> IResult<&'in
|
||||
bytes
|
||||
.iter()
|
||||
.rev()
|
||||
.fold(0, |acc, byte| (acc << 7) | (byte & 0x7f) as u64),
|
||||
.fold(0, |acc, byte| (acc << 7) | u64::from(byte & 0x7f)),
|
||||
))
|
||||
}
|
||||
|
||||
@ -84,6 +84,7 @@ fn string<'input, E: ParseError<&'input [u8]>>(
|
||||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn list<'input, I, E: ParseError<&'input [u8]>>(
|
||||
input: &'input [u8],
|
||||
item_parser: fn(&'input [u8]) -> IResult<&'input [u8], I, E>,
|
||||
|
@ -67,7 +67,7 @@ impl<'input> From<&Instruction<'input>> for String {
|
||||
}
|
||||
}
|
||||
|
||||
fn input_types_to_param(input_types: &Vec<InterfaceType>) -> String {
|
||||
fn input_types_to_param(input_types: &[InterfaceType]) -> String {
|
||||
if input_types.is_empty() {
|
||||
"".into()
|
||||
} else {
|
||||
@ -84,7 +84,7 @@ fn input_types_to_param(input_types: &Vec<InterfaceType>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn output_types_to_result(output_types: &Vec<InterfaceType>) -> String {
|
||||
fn output_types_to_result(output_types: &[InterfaceType]) -> String {
|
||||
if output_types.is_empty() {
|
||||
"".into()
|
||||
} else {
|
||||
|
@ -7,12 +7,15 @@ use std::{
|
||||
marker::PhantomData,
|
||||
};
|
||||
|
||||
type ExecutableInstruction<Instance, Export> =
|
||||
Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>>;
|
||||
|
||||
struct Runtime<'invocation, 'instance, Instance, Export>
|
||||
where
|
||||
Export: wasm::Export + 'instance,
|
||||
Instance: wasm::Instance<Export> + 'instance,
|
||||
{
|
||||
invocation_inputs: &'invocation Vec<u64>,
|
||||
invocation_inputs: &'invocation [u64],
|
||||
stack: Stack<u64>,
|
||||
wasm_instance: &'instance Instance,
|
||||
wasm_exports: PhantomData<Export>,
|
||||
@ -23,7 +26,7 @@ where
|
||||
Export: wasm::Export,
|
||||
Instance: wasm::Instance<Export>,
|
||||
{
|
||||
executable_instructions: Vec<Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>>>,
|
||||
executable_instructions: Vec<ExecutableInstruction<Instance, Export>>,
|
||||
}
|
||||
|
||||
impl<Instance, Export> Interpreter<Instance, Export>
|
||||
@ -31,16 +34,13 @@ where
|
||||
Export: wasm::Export,
|
||||
Instance: wasm::Instance<Export>,
|
||||
{
|
||||
fn iter(
|
||||
&self,
|
||||
) -> impl Iterator<Item = &Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>>> + '_
|
||||
{
|
||||
fn iter(&self) -> impl Iterator<Item = &ExecutableInstruction<Instance, Export>> + '_ {
|
||||
self.executable_instructions.iter()
|
||||
}
|
||||
|
||||
pub fn run(
|
||||
&self,
|
||||
invocation_inputs: &Vec<u64>,
|
||||
invocation_inputs: &[u64],
|
||||
wasm_instance: &Instance,
|
||||
) -> Result<Stack<u64>, String> {
|
||||
let mut runtime = Runtime {
|
||||
@ -73,7 +73,7 @@ where
|
||||
let executable_instructions = instructions
|
||||
.iter()
|
||||
.map(
|
||||
|instruction| -> Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>> {
|
||||
|instruction| -> ExecutableInstruction<Instance, Export> {
|
||||
match instruction {
|
||||
Instruction::ArgumentGet(index) => {
|
||||
let index = index.to_owned();
|
||||
|
Loading…
x
Reference in New Issue
Block a user