fix(interface-types) arg.get's index is of type u32.

This commit is contained in:
Ivan Enderlin 2020-02-26 15:42:29 +01:00
parent 766312fd90
commit 09498ee286
4 changed files with 10 additions and 5 deletions

View File

@ -156,7 +156,12 @@ fn instruction<'input, E: ParseError<&'input [u8]>>(
Ok(match opcode {
0x00 => {
consume!((input, argument_0) = uleb(input)?);
(input, Instruction::ArgumentGet { index: argument_0 })
(
input,
Instruction::ArgumentGet {
index: argument_0 as u32,
},
)
}
0x01 => {

View File

@ -252,7 +252,7 @@ where
match self {
Instruction::ArgumentGet { index } => {
0x00_u8.to_bytes(writer)?;
index.to_bytes(writer)?;
(*index as u64).to_bytes(writer)?;
}
Instruction::Call { function_index } => {

View File

@ -6,7 +6,7 @@ pub enum Instruction<'input> {
/// The `arg.get` instruction.
ArgumentGet {
/// The argument index.
index: u64,
index: u32,
},
/// The `call` instruction.

View File

@ -1,9 +1,9 @@
executable_instruction!(
argument_get(index: u64, instruction_name: String) -> _ {
argument_get(index: u32, instruction_name: String) -> _ {
move |runtime| -> _ {
let invocation_inputs = runtime.invocation_inputs;
if index >= (invocation_inputs.len() as u64) {
if index >= (invocation_inputs.len() as u32) {
return Err(format!(
"`{}` cannot access argument #{} because it doesn't exist.",
instruction_name, index