mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-30 22:41:03 +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) {
|
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),
|
None => (&[] as &[u8], input),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ fn leb<'input, E: ParseError<&'input [u8]>>(input: &'input [u8]) -> IResult<&'in
|
|||||||
bytes
|
bytes
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.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]>>(
|
fn list<'input, I, E: ParseError<&'input [u8]>>(
|
||||||
input: &'input [u8],
|
input: &'input [u8],
|
||||||
item_parser: fn(&'input [u8]) -> IResult<&'input [u8], I, E>,
|
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() {
|
if input_types.is_empty() {
|
||||||
"".into()
|
"".into()
|
||||||
} else {
|
} 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() {
|
if output_types.is_empty() {
|
||||||
"".into()
|
"".into()
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,12 +7,15 @@ use std::{
|
|||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ExecutableInstruction<Instance, Export> =
|
||||||
|
Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>>;
|
||||||
|
|
||||||
struct Runtime<'invocation, 'instance, Instance, Export>
|
struct Runtime<'invocation, 'instance, Instance, Export>
|
||||||
where
|
where
|
||||||
Export: wasm::Export + 'instance,
|
Export: wasm::Export + 'instance,
|
||||||
Instance: wasm::Instance<Export> + 'instance,
|
Instance: wasm::Instance<Export> + 'instance,
|
||||||
{
|
{
|
||||||
invocation_inputs: &'invocation Vec<u64>,
|
invocation_inputs: &'invocation [u64],
|
||||||
stack: Stack<u64>,
|
stack: Stack<u64>,
|
||||||
wasm_instance: &'instance Instance,
|
wasm_instance: &'instance Instance,
|
||||||
wasm_exports: PhantomData<Export>,
|
wasm_exports: PhantomData<Export>,
|
||||||
@ -23,7 +26,7 @@ where
|
|||||||
Export: wasm::Export,
|
Export: wasm::Export,
|
||||||
Instance: wasm::Instance<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>
|
impl<Instance, Export> Interpreter<Instance, Export>
|
||||||
@ -31,16 +34,13 @@ where
|
|||||||
Export: wasm::Export,
|
Export: wasm::Export,
|
||||||
Instance: wasm::Instance<Export>,
|
Instance: wasm::Instance<Export>,
|
||||||
{
|
{
|
||||||
fn iter(
|
fn iter(&self) -> impl Iterator<Item = &ExecutableInstruction<Instance, Export>> + '_ {
|
||||||
&self,
|
|
||||||
) -> impl Iterator<Item = &Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>>> + '_
|
|
||||||
{
|
|
||||||
self.executable_instructions.iter()
|
self.executable_instructions.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(
|
pub fn run(
|
||||||
&self,
|
&self,
|
||||||
invocation_inputs: &Vec<u64>,
|
invocation_inputs: &[u64],
|
||||||
wasm_instance: &Instance,
|
wasm_instance: &Instance,
|
||||||
) -> Result<Stack<u64>, String> {
|
) -> Result<Stack<u64>, String> {
|
||||||
let mut runtime = Runtime {
|
let mut runtime = Runtime {
|
||||||
@ -73,7 +73,7 @@ where
|
|||||||
let executable_instructions = instructions
|
let executable_instructions = instructions
|
||||||
.iter()
|
.iter()
|
||||||
.map(
|
.map(
|
||||||
|instruction| -> Box<dyn Fn(&mut Runtime<Instance, Export>) -> Result<(), String>> {
|
|instruction| -> ExecutableInstruction<Instance, Export> {
|
||||||
match instruction {
|
match instruction {
|
||||||
Instruction::ArgumentGet(index) => {
|
Instruction::ArgumentGet(index) => {
|
||||||
let index = index.to_owned();
|
let index = index.to_owned();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user