diff --git a/src/decoders/binary.rs b/src/decoders/binary.rs index f1f7f77..d8699a6 100644 --- a/src/decoders/binary.rs +++ b/src/decoders/binary.rs @@ -169,7 +169,7 @@ fn instruction<'input, E: ParseError<&'input [u8]>>( ( input, Instruction::CallCore { - function_index: argument_0 as usize, + function_index: argument_0 as u32, }, ) } diff --git a/src/decoders/wat.rs b/src/decoders/wat.rs index 3e41d51..4a77857 100644 --- a/src/decoders/wat.rs +++ b/src/decoders/wat.rs @@ -146,7 +146,7 @@ impl<'a> Parse<'a> for Instruction { parser.parse::()?; Ok(Instruction::CallCore { - function_index: parser.parse::()? as usize, + function_index: parser.parse::()?, }) } else if lookahead.peek::() { parser.parse::()?; diff --git a/src/interpreter/instruction.rs b/src/interpreter/instruction.rs index 712a6ea..37f8162 100644 --- a/src/interpreter/instruction.rs +++ b/src/interpreter/instruction.rs @@ -12,7 +12,7 @@ pub enum Instruction { /// The `call-core` instruction. CallCore { /// The function index. - function_index: usize, + function_index: u32, }, /// The `s8.from_i32` instruction. diff --git a/src/interpreter/instructions/call_core.rs b/src/interpreter/instructions/call_core.rs index 5a3da21..7a8e498 100644 --- a/src/interpreter/instructions/call_core.rs +++ b/src/interpreter/instructions/call_core.rs @@ -8,16 +8,16 @@ use crate::{ }; executable_instruction!( - call_core(function_index: usize, instruction: Instruction) -> _ { + call_core(function_index: u32, instruction: Instruction) -> _ { move |runtime| -> _ { let instance = &mut runtime.wasm_instance; - let index = FunctionIndex::new(function_index); + let index = FunctionIndex::new(function_index as usize); let local_or_import = instance.local_or_import(index).ok_or_else(|| { InstructionError::new( instruction, InstructionErrorKind::LocalOrImportIsMissing { - function_index: function_index as u32, + function_index: function_index, }, ) })?; @@ -40,7 +40,7 @@ executable_instruction!( return Err(InstructionError::new( instruction, InstructionErrorKind::LocalOrImportSignatureMismatch { - function_index: function_index as u32, + function_index: function_index, expected: (local_or_import.inputs().to_vec(), vec![]), received: (input_types, vec![]), }, @@ -51,7 +51,7 @@ executable_instruction!( InstructionError::new( instruction, InstructionErrorKind::LocalOrImportCall { - function_index: function_index as u32, + function_index: function_index, }, ) })?;