mirror of
https://github.com/fluencelabs/interface-types
synced 2024-12-04 15:20:20 +00:00
feat(interface-types) Implement [siu](NN|MM).from_*
instructions.
Basically the `x-to-y` instructions have been renamed `y.from_x`. This patch updates the instruction. The binary representation isn't specified yet, so it's just arbitrary values.
This commit is contained in:
parent
6b5975ea47
commit
9af32b273c
@ -174,9 +174,42 @@ fn instruction<'input, E: ParseError<&'input [u8]>>(
|
||||
)
|
||||
}
|
||||
|
||||
0x03 => (input, Instruction::MemoryToString),
|
||||
0x02 => (input, Instruction::S8FromI32),
|
||||
0x03 => (input, Instruction::S8FromI64),
|
||||
0x04 => (input, Instruction::S16FromI32),
|
||||
0x05 => (input, Instruction::S16FromI64),
|
||||
0x06 => (input, Instruction::S32FromI32),
|
||||
0x07 => (input, Instruction::S32FromI64),
|
||||
0x08 => (input, Instruction::S64FromI32),
|
||||
0x09 => (input, Instruction::S64FromI64),
|
||||
0x0a => (input, Instruction::I32FromS8),
|
||||
0x0b => (input, Instruction::I32FromS16),
|
||||
0x0c => (input, Instruction::I32FromS32),
|
||||
0x0d => (input, Instruction::I32FromS64),
|
||||
0x0e => (input, Instruction::I64FromS8),
|
||||
0x0f => (input, Instruction::I64FromS16),
|
||||
0x10 => (input, Instruction::I64FromS32),
|
||||
0x11 => (input, Instruction::I64FromS64),
|
||||
0x12 => (input, Instruction::U8FromI32),
|
||||
0x13 => (input, Instruction::U8FromI64),
|
||||
0x14 => (input, Instruction::U16FromI32),
|
||||
0x15 => (input, Instruction::U16FromI64),
|
||||
0x16 => (input, Instruction::U32FromI32),
|
||||
0x17 => (input, Instruction::U32FromI64),
|
||||
0x18 => (input, Instruction::U64FromI32),
|
||||
0x19 => (input, Instruction::U64FromI64),
|
||||
0x1a => (input, Instruction::I32FromU8),
|
||||
0x1b => (input, Instruction::I32FromU16),
|
||||
0x1c => (input, Instruction::I32FromU32),
|
||||
0x1d => (input, Instruction::I32FromU64),
|
||||
0x1e => (input, Instruction::I64FromU8),
|
||||
0x1f => (input, Instruction::I64FromU16),
|
||||
0x20 => (input, Instruction::I64FromU32),
|
||||
0x21 => (input, Instruction::I64FromU64),
|
||||
|
||||
0x04 => {
|
||||
0x22 => (input, Instruction::MemoryToString),
|
||||
|
||||
0x23 => {
|
||||
consume!((input, argument_0) = uleb(input)?);
|
||||
(
|
||||
input,
|
||||
@ -186,46 +219,6 @@ fn instruction<'input, E: ParseError<&'input [u8]>>(
|
||||
)
|
||||
}
|
||||
|
||||
0x07 => (input, Instruction::I32ToS8),
|
||||
0x08 => (input, Instruction::I32ToS8X),
|
||||
0x09 => (input, Instruction::I32ToU8),
|
||||
0x0a => (input, Instruction::I32ToS16),
|
||||
0x0b => (input, Instruction::I32ToS16X),
|
||||
0x0c => (input, Instruction::I32ToU16),
|
||||
0x0d => (input, Instruction::I32ToS32),
|
||||
0x0e => (input, Instruction::I32ToU32),
|
||||
0x0f => (input, Instruction::I32ToS64),
|
||||
0x10 => (input, Instruction::I32ToU64),
|
||||
0x11 => (input, Instruction::I64ToS8),
|
||||
0x12 => (input, Instruction::I64ToS8X),
|
||||
0x13 => (input, Instruction::I64ToU8),
|
||||
0x14 => (input, Instruction::I64ToS16),
|
||||
0x15 => (input, Instruction::I64ToS16X),
|
||||
0x16 => (input, Instruction::I64ToU16),
|
||||
0x17 => (input, Instruction::I64ToS32),
|
||||
0x18 => (input, Instruction::I64ToS32X),
|
||||
0x19 => (input, Instruction::I64ToU32),
|
||||
0x1a => (input, Instruction::I64ToS64),
|
||||
0x1b => (input, Instruction::I64ToU64),
|
||||
0x1c => (input, Instruction::S8ToI32),
|
||||
0x1d => (input, Instruction::U8ToI32),
|
||||
0x1e => (input, Instruction::S16ToI32),
|
||||
0x1f => (input, Instruction::U16ToI32),
|
||||
0x20 => (input, Instruction::S32ToI32),
|
||||
0x21 => (input, Instruction::U32ToI32),
|
||||
0x22 => (input, Instruction::S64ToI32),
|
||||
0x23 => (input, Instruction::S64ToI32X),
|
||||
0x24 => (input, Instruction::U64ToI32),
|
||||
0x25 => (input, Instruction::U64ToI32X),
|
||||
0x26 => (input, Instruction::S8ToI64),
|
||||
0x27 => (input, Instruction::U8ToI64),
|
||||
0x28 => (input, Instruction::S16ToI64),
|
||||
0x29 => (input, Instruction::U16ToI64),
|
||||
0x2a => (input, Instruction::S32ToI64),
|
||||
0x2b => (input, Instruction::U32ToI64),
|
||||
0x2c => (input, Instruction::S64ToI64),
|
||||
0x2d => (input, Instruction::U64ToI64),
|
||||
|
||||
_ => return Err(Err::Error(make_error(input, ErrorKind::ParseTo))),
|
||||
})
|
||||
}
|
||||
@ -627,50 +620,43 @@ mod tests {
|
||||
#[test]
|
||||
fn test_instructions() {
|
||||
let input = &[
|
||||
0x2b, // list of 43 items
|
||||
0x24, // list of 36 items
|
||||
0x00, 0x01, // ArgumentGet { index: 1 }
|
||||
0x01, 0x01, // CallCore { function_index: 1 }
|
||||
0x03, // MemoryToString
|
||||
0x04, 0x01, // StringToMemory { allocator_index: 1 }
|
||||
0x07, // I32ToS8
|
||||
0x08, // I32ToS8X
|
||||
0x09, // I32ToU8
|
||||
0x0a, // I32ToS16
|
||||
0x0b, // I32ToS16X
|
||||
0x0c, // I32ToU16
|
||||
0x0d, // I32ToS32
|
||||
0x0e, // I32ToU32
|
||||
0x0f, // I32ToS64
|
||||
0x10, // I32ToU64
|
||||
0x11, // I64ToS8
|
||||
0x12, // I64ToS8X
|
||||
0x13, // I64ToU8
|
||||
0x14, // I64ToS16
|
||||
0x15, // I64ToS16X
|
||||
0x16, // I64ToU16
|
||||
0x17, // I64ToS32
|
||||
0x18, // I64ToS32X
|
||||
0x19, // I64ToU32
|
||||
0x1a, // I64ToS64
|
||||
0x1b, // I64ToU64
|
||||
0x1c, // S8ToI32
|
||||
0x1d, // U8ToI32
|
||||
0x1e, // S16ToI32
|
||||
0x1f, // U16ToI32
|
||||
0x20, // S32ToI32
|
||||
0x21, // U32ToI32
|
||||
0x22, // S64ToI32
|
||||
0x23, // S64ToI32X
|
||||
0x24, // U64ToI32
|
||||
0x25, // U64ToI32X
|
||||
0x26, // S8ToI64
|
||||
0x27, // U8ToI64
|
||||
0x28, // S16ToI64
|
||||
0x29, // U16ToI64
|
||||
0x2a, // S32ToI64
|
||||
0x2b, // U32ToI64
|
||||
0x2c, // S64ToI64
|
||||
0x2d, // U64ToI64
|
||||
0x02, // S8FromI32
|
||||
0x03, // S8FromI64
|
||||
0x04, // S16FromI32
|
||||
0x05, // S16FromI64
|
||||
0x06, // S32FromI32
|
||||
0x07, // S32FromI64
|
||||
0x08, // S64FromI32
|
||||
0x09, // S64FromI64
|
||||
0x0a, // I32FromS8
|
||||
0x0b, // I32FromS16
|
||||
0x0c, // I32FromS32
|
||||
0x0d, // I32FromS64
|
||||
0x0e, // I64FromS8
|
||||
0x0f, // I64FromS16
|
||||
0x10, // I64FromS32
|
||||
0x11, // I64FromS64
|
||||
0x12, // U8FromI32
|
||||
0x13, // U8FromI64
|
||||
0x14, // U16FromI32
|
||||
0x15, // U16FromI64
|
||||
0x16, // U32FromI32
|
||||
0x17, // U32FromI64
|
||||
0x18, // U64FromI32
|
||||
0x19, // U64FromI64
|
||||
0x1a, // I32FromU8
|
||||
0x1b, // I32FromU16
|
||||
0x1c, // I32FromU32
|
||||
0x1d, // I32FromU64
|
||||
0x1e, // I64FromU8
|
||||
0x1f, // I64FromU16
|
||||
0x20, // I64FromU32
|
||||
0x21, // I64FromU64
|
||||
0x22, // MemoryToString
|
||||
0x23, 0x01, // StringToMemory { allocator_index: 1 }
|
||||
0x0a,
|
||||
];
|
||||
let output = Ok((
|
||||
@ -678,47 +664,40 @@ mod tests {
|
||||
vec![
|
||||
Instruction::ArgumentGet { index: 1 },
|
||||
Instruction::CallCore { function_index: 1 },
|
||||
Instruction::S8FromI32,
|
||||
Instruction::S8FromI64,
|
||||
Instruction::S16FromI32,
|
||||
Instruction::S16FromI64,
|
||||
Instruction::S32FromI32,
|
||||
Instruction::S32FromI64,
|
||||
Instruction::S64FromI32,
|
||||
Instruction::S64FromI64,
|
||||
Instruction::I32FromS8,
|
||||
Instruction::I32FromS16,
|
||||
Instruction::I32FromS32,
|
||||
Instruction::I32FromS64,
|
||||
Instruction::I64FromS8,
|
||||
Instruction::I64FromS16,
|
||||
Instruction::I64FromS32,
|
||||
Instruction::I64FromS64,
|
||||
Instruction::U8FromI32,
|
||||
Instruction::U8FromI64,
|
||||
Instruction::U16FromI32,
|
||||
Instruction::U16FromI64,
|
||||
Instruction::U32FromI32,
|
||||
Instruction::U32FromI64,
|
||||
Instruction::U64FromI32,
|
||||
Instruction::U64FromI64,
|
||||
Instruction::I32FromU8,
|
||||
Instruction::I32FromU16,
|
||||
Instruction::I32FromU32,
|
||||
Instruction::I32FromU64,
|
||||
Instruction::I64FromU8,
|
||||
Instruction::I64FromU16,
|
||||
Instruction::I64FromU32,
|
||||
Instruction::I64FromU64,
|
||||
Instruction::MemoryToString,
|
||||
Instruction::StringToMemory { allocator_index: 1 },
|
||||
Instruction::I32ToS8,
|
||||
Instruction::I32ToS8X,
|
||||
Instruction::I32ToU8,
|
||||
Instruction::I32ToS16,
|
||||
Instruction::I32ToS16X,
|
||||
Instruction::I32ToU16,
|
||||
Instruction::I32ToS32,
|
||||
Instruction::I32ToU32,
|
||||
Instruction::I32ToS64,
|
||||
Instruction::I32ToU64,
|
||||
Instruction::I64ToS8,
|
||||
Instruction::I64ToS8X,
|
||||
Instruction::I64ToU8,
|
||||
Instruction::I64ToS16,
|
||||
Instruction::I64ToS16X,
|
||||
Instruction::I64ToU16,
|
||||
Instruction::I64ToS32,
|
||||
Instruction::I64ToS32X,
|
||||
Instruction::I64ToU32,
|
||||
Instruction::I64ToS64,
|
||||
Instruction::I64ToU64,
|
||||
Instruction::S8ToI32,
|
||||
Instruction::U8ToI32,
|
||||
Instruction::S16ToI32,
|
||||
Instruction::U16ToI32,
|
||||
Instruction::S32ToI32,
|
||||
Instruction::U32ToI32,
|
||||
Instruction::S64ToI32,
|
||||
Instruction::S64ToI32X,
|
||||
Instruction::U64ToI32,
|
||||
Instruction::U64ToI32X,
|
||||
Instruction::S8ToI64,
|
||||
Instruction::U8ToI64,
|
||||
Instruction::S16ToI64,
|
||||
Instruction::U16ToI64,
|
||||
Instruction::S32ToI64,
|
||||
Instruction::U32ToI64,
|
||||
Instruction::S64ToI64,
|
||||
Instruction::U64ToI64,
|
||||
],
|
||||
));
|
||||
|
||||
|
@ -28,47 +28,40 @@ mod keyword {
|
||||
// Instructions.
|
||||
custom_keyword!(argument_get = "arg.get");
|
||||
custom_keyword!(call_core = "call-core");
|
||||
custom_keyword!(s8_from_i32 = "s8.from_i32");
|
||||
custom_keyword!(s8_from_i64 = "s8.from_i64");
|
||||
custom_keyword!(s16_from_i32 = "s16.from_i32");
|
||||
custom_keyword!(s16_from_i64 = "s16.from_i64");
|
||||
custom_keyword!(s32_from_i32 = "s32.from_i32");
|
||||
custom_keyword!(s32_from_i64 = "s32.from_i64");
|
||||
custom_keyword!(s64_from_i32 = "s64.from_i32");
|
||||
custom_keyword!(s64_from_i64 = "s64.from_i64");
|
||||
custom_keyword!(i32_from_s8 = "i32.from_s8");
|
||||
custom_keyword!(i32_from_s16 = "i32.from_s16");
|
||||
custom_keyword!(i32_from_s32 = "i32.from_s32");
|
||||
custom_keyword!(i32_from_s64 = "i32.from_s64");
|
||||
custom_keyword!(i64_from_s8 = "i64.from_s8");
|
||||
custom_keyword!(i64_from_s16 = "i64.from_s16");
|
||||
custom_keyword!(i64_from_s32 = "i64.from_s32");
|
||||
custom_keyword!(i64_from_s64 = "i64.from_s64");
|
||||
custom_keyword!(u8_from_i32 = "u8.from_i32");
|
||||
custom_keyword!(u8_from_i64 = "u8.from_i64");
|
||||
custom_keyword!(u16_from_i32 = "u16.from_i32");
|
||||
custom_keyword!(u16_from_i64 = "u16.from_i64");
|
||||
custom_keyword!(u32_from_i32 = "u32.from_i32");
|
||||
custom_keyword!(u32_from_i64 = "u32.from_i64");
|
||||
custom_keyword!(u64_from_i32 = "u64.from_i32");
|
||||
custom_keyword!(u64_from_i64 = "u64.from_i64");
|
||||
custom_keyword!(i32_from_u8 = "i32.from_u8");
|
||||
custom_keyword!(i32_from_u16 = "i32.from_u16");
|
||||
custom_keyword!(i32_from_u32 = "i32.from_u32");
|
||||
custom_keyword!(i32_from_u64 = "i32.from_u64");
|
||||
custom_keyword!(i64_from_u8 = "i64.from_u8");
|
||||
custom_keyword!(i64_from_u16 = "i64.from_u16");
|
||||
custom_keyword!(i64_from_u32 = "i64.from_u32");
|
||||
custom_keyword!(i64_from_u64 = "i64.from_u64");
|
||||
custom_keyword!(memory_to_string = "memory-to-string");
|
||||
custom_keyword!(string_to_memory = "string-to-memory");
|
||||
custom_keyword!(i32_to_s8 = "i32-to-s8");
|
||||
custom_keyword!(i32_to_s8x = "i32-to-s8x");
|
||||
custom_keyword!(i32_to_u8 = "i32-to-u8");
|
||||
custom_keyword!(i32_to_s16 = "i32-to-s16");
|
||||
custom_keyword!(i32_to_s16x = "i32-to-s16x");
|
||||
custom_keyword!(i32_to_u16 = "i32-to-u16");
|
||||
custom_keyword!(i32_to_s32 = "i32-to-s32");
|
||||
custom_keyword!(i32_to_u32 = "i32-to-u32");
|
||||
custom_keyword!(i32_to_s64 = "i32-to-s64");
|
||||
custom_keyword!(i32_to_u64 = "i32-to-u64");
|
||||
custom_keyword!(i64_to_s8 = "i64-to-s8");
|
||||
custom_keyword!(i64_to_s8x = "i64-to-s8x");
|
||||
custom_keyword!(i64_to_u8 = "i64-to-u8");
|
||||
custom_keyword!(i64_to_s16 = "i64-to-s16");
|
||||
custom_keyword!(i64_to_s16x = "i64-to-s16x");
|
||||
custom_keyword!(i64_to_u16 = "i64-to-u16");
|
||||
custom_keyword!(i64_to_s32 = "i64-to-s32");
|
||||
custom_keyword!(i64_to_s32x = "i64-to-s32x");
|
||||
custom_keyword!(i64_to_u32 = "i64-to-u32");
|
||||
custom_keyword!(i64_to_s64 = "i64-to-s64");
|
||||
custom_keyword!(i64_to_u64 = "i64-to-u64");
|
||||
custom_keyword!(s8_to_i32 = "s8-to-i32");
|
||||
custom_keyword!(u8_to_i32 = "u8-to-i32");
|
||||
custom_keyword!(s16_to_i32 = "s16-to-i32");
|
||||
custom_keyword!(u16_to_i32 = "u16-to-i32");
|
||||
custom_keyword!(s32_to_i32 = "s32-to-i32");
|
||||
custom_keyword!(u32_to_i32 = "u32-to-i32");
|
||||
custom_keyword!(s64_to_i32 = "s64-to-i32");
|
||||
custom_keyword!(s64_to_i32x = "s64-to-i32x");
|
||||
custom_keyword!(u64_to_i32 = "u64-to-i32");
|
||||
custom_keyword!(u64_to_i32x = "u64-to-i32x");
|
||||
custom_keyword!(s8_to_i64 = "s8-to-i64");
|
||||
custom_keyword!(u8_to_i64 = "u8-to-i64");
|
||||
custom_keyword!(s16_to_i64 = "s16-to-i64");
|
||||
custom_keyword!(u16_to_i64 = "u16-to-i64");
|
||||
custom_keyword!(s32_to_i64 = "s32-to-i64");
|
||||
custom_keyword!(u32_to_i64 = "u32-to-i64");
|
||||
custom_keyword!(s64_to_i64 = "s64-to-i64");
|
||||
custom_keyword!(u64_to_i64 = "u64-to-i64");
|
||||
}
|
||||
|
||||
impl Parse<'_> for InterfaceType {
|
||||
@ -154,6 +147,134 @@ impl<'a> Parse<'a> for Instruction {
|
||||
Ok(Instruction::CallCore {
|
||||
function_index: parser.parse::<u64>()? as usize,
|
||||
})
|
||||
} else if lookahead.peek::<keyword::s8_from_i32>() {
|
||||
parser.parse::<keyword::s8_from_i32>()?;
|
||||
|
||||
Ok(Instruction::S8FromI32)
|
||||
} else if lookahead.peek::<keyword::s8_from_i64>() {
|
||||
parser.parse::<keyword::s8_from_i64>()?;
|
||||
|
||||
Ok(Instruction::S8FromI64)
|
||||
} else if lookahead.peek::<keyword::s16_from_i32>() {
|
||||
parser.parse::<keyword::s16_from_i32>()?;
|
||||
|
||||
Ok(Instruction::S16FromI32)
|
||||
} else if lookahead.peek::<keyword::s16_from_i64>() {
|
||||
parser.parse::<keyword::s16_from_i64>()?;
|
||||
|
||||
Ok(Instruction::S16FromI64)
|
||||
} else if lookahead.peek::<keyword::s32_from_i32>() {
|
||||
parser.parse::<keyword::s32_from_i32>()?;
|
||||
|
||||
Ok(Instruction::S32FromI32)
|
||||
} else if lookahead.peek::<keyword::s32_from_i64>() {
|
||||
parser.parse::<keyword::s32_from_i64>()?;
|
||||
|
||||
Ok(Instruction::S32FromI64)
|
||||
} else if lookahead.peek::<keyword::s64_from_i32>() {
|
||||
parser.parse::<keyword::s64_from_i32>()?;
|
||||
|
||||
Ok(Instruction::S64FromI32)
|
||||
} else if lookahead.peek::<keyword::s64_from_i64>() {
|
||||
parser.parse::<keyword::s64_from_i64>()?;
|
||||
|
||||
Ok(Instruction::S64FromI64)
|
||||
} else if lookahead.peek::<keyword::i32_from_s8>() {
|
||||
parser.parse::<keyword::i32_from_s8>()?;
|
||||
|
||||
Ok(Instruction::I32FromS8)
|
||||
} else if lookahead.peek::<keyword::i32_from_s16>() {
|
||||
parser.parse::<keyword::i32_from_s16>()?;
|
||||
|
||||
Ok(Instruction::I32FromS16)
|
||||
} else if lookahead.peek::<keyword::i32_from_s32>() {
|
||||
parser.parse::<keyword::i32_from_s32>()?;
|
||||
|
||||
Ok(Instruction::I32FromS32)
|
||||
} else if lookahead.peek::<keyword::i32_from_s64>() {
|
||||
parser.parse::<keyword::i32_from_s64>()?;
|
||||
|
||||
Ok(Instruction::I32FromS64)
|
||||
} else if lookahead.peek::<keyword::i64_from_s8>() {
|
||||
parser.parse::<keyword::i64_from_s8>()?;
|
||||
|
||||
Ok(Instruction::I64FromS8)
|
||||
} else if lookahead.peek::<keyword::i64_from_s16>() {
|
||||
parser.parse::<keyword::i64_from_s16>()?;
|
||||
|
||||
Ok(Instruction::I64FromS16)
|
||||
} else if lookahead.peek::<keyword::i64_from_s32>() {
|
||||
parser.parse::<keyword::i64_from_s32>()?;
|
||||
|
||||
Ok(Instruction::I64FromS32)
|
||||
} else if lookahead.peek::<keyword::i64_from_s64>() {
|
||||
parser.parse::<keyword::i64_from_s64>()?;
|
||||
|
||||
Ok(Instruction::I64FromS64)
|
||||
} else if lookahead.peek::<keyword::u8_from_i32>() {
|
||||
parser.parse::<keyword::u8_from_i32>()?;
|
||||
|
||||
Ok(Instruction::U8FromI32)
|
||||
} else if lookahead.peek::<keyword::u8_from_i64>() {
|
||||
parser.parse::<keyword::u8_from_i64>()?;
|
||||
|
||||
Ok(Instruction::U8FromI64)
|
||||
} else if lookahead.peek::<keyword::u16_from_i32>() {
|
||||
parser.parse::<keyword::u16_from_i32>()?;
|
||||
|
||||
Ok(Instruction::U16FromI32)
|
||||
} else if lookahead.peek::<keyword::u16_from_i64>() {
|
||||
parser.parse::<keyword::u16_from_i64>()?;
|
||||
|
||||
Ok(Instruction::U16FromI64)
|
||||
} else if lookahead.peek::<keyword::u32_from_i32>() {
|
||||
parser.parse::<keyword::u32_from_i32>()?;
|
||||
|
||||
Ok(Instruction::U32FromI32)
|
||||
} else if lookahead.peek::<keyword::u32_from_i64>() {
|
||||
parser.parse::<keyword::u32_from_i64>()?;
|
||||
|
||||
Ok(Instruction::U32FromI64)
|
||||
} else if lookahead.peek::<keyword::u64_from_i32>() {
|
||||
parser.parse::<keyword::u64_from_i32>()?;
|
||||
|
||||
Ok(Instruction::U64FromI32)
|
||||
} else if lookahead.peek::<keyword::u64_from_i64>() {
|
||||
parser.parse::<keyword::u64_from_i64>()?;
|
||||
|
||||
Ok(Instruction::U64FromI64)
|
||||
} else if lookahead.peek::<keyword::i32_from_u8>() {
|
||||
parser.parse::<keyword::i32_from_u8>()?;
|
||||
|
||||
Ok(Instruction::I32FromU8)
|
||||
} else if lookahead.peek::<keyword::i32_from_u16>() {
|
||||
parser.parse::<keyword::i32_from_u16>()?;
|
||||
|
||||
Ok(Instruction::I32FromU16)
|
||||
} else if lookahead.peek::<keyword::i32_from_u32>() {
|
||||
parser.parse::<keyword::i32_from_u32>()?;
|
||||
|
||||
Ok(Instruction::I32FromU32)
|
||||
} else if lookahead.peek::<keyword::i32_from_u64>() {
|
||||
parser.parse::<keyword::i32_from_u64>()?;
|
||||
|
||||
Ok(Instruction::I32FromU64)
|
||||
} else if lookahead.peek::<keyword::i64_from_u8>() {
|
||||
parser.parse::<keyword::i64_from_u8>()?;
|
||||
|
||||
Ok(Instruction::I64FromU8)
|
||||
} else if lookahead.peek::<keyword::i64_from_u16>() {
|
||||
parser.parse::<keyword::i64_from_u16>()?;
|
||||
|
||||
Ok(Instruction::I64FromU16)
|
||||
} else if lookahead.peek::<keyword::i64_from_u32>() {
|
||||
parser.parse::<keyword::i64_from_u32>()?;
|
||||
|
||||
Ok(Instruction::I64FromU32)
|
||||
} else if lookahead.peek::<keyword::i64_from_u64>() {
|
||||
parser.parse::<keyword::i64_from_u64>()?;
|
||||
|
||||
Ok(Instruction::I64FromU64)
|
||||
} else if lookahead.peek::<keyword::memory_to_string>() {
|
||||
parser.parse::<keyword::memory_to_string>()?;
|
||||
|
||||
@ -164,162 +285,6 @@ impl<'a> Parse<'a> for Instruction {
|
||||
Ok(Instruction::StringToMemory {
|
||||
allocator_index: parser.parse()?,
|
||||
})
|
||||
} else if lookahead.peek::<keyword::i32_to_s8>() {
|
||||
parser.parse::<keyword::i32_to_s8>()?;
|
||||
|
||||
Ok(Instruction::I32ToS8)
|
||||
} else if lookahead.peek::<keyword::i32_to_s8x>() {
|
||||
parser.parse::<keyword::i32_to_s8x>()?;
|
||||
|
||||
Ok(Instruction::I32ToS8X)
|
||||
} else if lookahead.peek::<keyword::i32_to_u8>() {
|
||||
parser.parse::<keyword::i32_to_u8>()?;
|
||||
|
||||
Ok(Instruction::I32ToU8)
|
||||
} else if lookahead.peek::<keyword::i32_to_s16>() {
|
||||
parser.parse::<keyword::i32_to_s16>()?;
|
||||
|
||||
Ok(Instruction::I32ToS16)
|
||||
} else if lookahead.peek::<keyword::i32_to_s16x>() {
|
||||
parser.parse::<keyword::i32_to_s16x>()?;
|
||||
|
||||
Ok(Instruction::I32ToS16X)
|
||||
} else if lookahead.peek::<keyword::i32_to_u16>() {
|
||||
parser.parse::<keyword::i32_to_u16>()?;
|
||||
|
||||
Ok(Instruction::I32ToU16)
|
||||
} else if lookahead.peek::<keyword::i32_to_s32>() {
|
||||
parser.parse::<keyword::i32_to_s32>()?;
|
||||
|
||||
Ok(Instruction::I32ToS32)
|
||||
} else if lookahead.peek::<keyword::i32_to_u32>() {
|
||||
parser.parse::<keyword::i32_to_u32>()?;
|
||||
|
||||
Ok(Instruction::I32ToU32)
|
||||
} else if lookahead.peek::<keyword::i32_to_s64>() {
|
||||
parser.parse::<keyword::i32_to_s64>()?;
|
||||
|
||||
Ok(Instruction::I32ToS64)
|
||||
} else if lookahead.peek::<keyword::i32_to_u64>() {
|
||||
parser.parse::<keyword::i32_to_u64>()?;
|
||||
|
||||
Ok(Instruction::I32ToU64)
|
||||
} else if lookahead.peek::<keyword::i64_to_s8>() {
|
||||
parser.parse::<keyword::i64_to_s8>()?;
|
||||
|
||||
Ok(Instruction::I64ToS8)
|
||||
} else if lookahead.peek::<keyword::i64_to_s8x>() {
|
||||
parser.parse::<keyword::i64_to_s8x>()?;
|
||||
|
||||
Ok(Instruction::I64ToS8X)
|
||||
} else if lookahead.peek::<keyword::i64_to_u8>() {
|
||||
parser.parse::<keyword::i64_to_u8>()?;
|
||||
|
||||
Ok(Instruction::I64ToU8)
|
||||
} else if lookahead.peek::<keyword::i64_to_s16>() {
|
||||
parser.parse::<keyword::i64_to_s16>()?;
|
||||
|
||||
Ok(Instruction::I64ToS16)
|
||||
} else if lookahead.peek::<keyword::i64_to_s16x>() {
|
||||
parser.parse::<keyword::i64_to_s16x>()?;
|
||||
|
||||
Ok(Instruction::I64ToS16X)
|
||||
} else if lookahead.peek::<keyword::i64_to_u16>() {
|
||||
parser.parse::<keyword::i64_to_u16>()?;
|
||||
|
||||
Ok(Instruction::I64ToU16)
|
||||
} else if lookahead.peek::<keyword::i64_to_s32>() {
|
||||
parser.parse::<keyword::i64_to_s32>()?;
|
||||
|
||||
Ok(Instruction::I64ToS32)
|
||||
} else if lookahead.peek::<keyword::i64_to_s32x>() {
|
||||
parser.parse::<keyword::i64_to_s32x>()?;
|
||||
|
||||
Ok(Instruction::I64ToS32X)
|
||||
} else if lookahead.peek::<keyword::i64_to_u32>() {
|
||||
parser.parse::<keyword::i64_to_u32>()?;
|
||||
|
||||
Ok(Instruction::I64ToU32)
|
||||
} else if lookahead.peek::<keyword::i64_to_s64>() {
|
||||
parser.parse::<keyword::i64_to_s64>()?;
|
||||
|
||||
Ok(Instruction::I64ToS64)
|
||||
} else if lookahead.peek::<keyword::i64_to_u64>() {
|
||||
parser.parse::<keyword::i64_to_u64>()?;
|
||||
|
||||
Ok(Instruction::I64ToU64)
|
||||
} else if lookahead.peek::<keyword::s8_to_i32>() {
|
||||
parser.parse::<keyword::s8_to_i32>()?;
|
||||
|
||||
Ok(Instruction::S8ToI32)
|
||||
} else if lookahead.peek::<keyword::u8_to_i32>() {
|
||||
parser.parse::<keyword::u8_to_i32>()?;
|
||||
|
||||
Ok(Instruction::U8ToI32)
|
||||
} else if lookahead.peek::<keyword::s16_to_i32>() {
|
||||
parser.parse::<keyword::s16_to_i32>()?;
|
||||
|
||||
Ok(Instruction::S16ToI32)
|
||||
} else if lookahead.peek::<keyword::u16_to_i32>() {
|
||||
parser.parse::<keyword::u16_to_i32>()?;
|
||||
|
||||
Ok(Instruction::U16ToI32)
|
||||
} else if lookahead.peek::<keyword::s32_to_i32>() {
|
||||
parser.parse::<keyword::s32_to_i32>()?;
|
||||
|
||||
Ok(Instruction::S32ToI32)
|
||||
} else if lookahead.peek::<keyword::u32_to_i32>() {
|
||||
parser.parse::<keyword::u32_to_i32>()?;
|
||||
|
||||
Ok(Instruction::U32ToI32)
|
||||
} else if lookahead.peek::<keyword::s64_to_i32>() {
|
||||
parser.parse::<keyword::s64_to_i32>()?;
|
||||
|
||||
Ok(Instruction::S64ToI32)
|
||||
} else if lookahead.peek::<keyword::s64_to_i32x>() {
|
||||
parser.parse::<keyword::s64_to_i32x>()?;
|
||||
|
||||
Ok(Instruction::S64ToI32X)
|
||||
} else if lookahead.peek::<keyword::u64_to_i32>() {
|
||||
parser.parse::<keyword::u64_to_i32>()?;
|
||||
|
||||
Ok(Instruction::U64ToI32)
|
||||
} else if lookahead.peek::<keyword::u64_to_i32x>() {
|
||||
parser.parse::<keyword::u64_to_i32x>()?;
|
||||
|
||||
Ok(Instruction::U64ToI32X)
|
||||
} else if lookahead.peek::<keyword::s8_to_i64>() {
|
||||
parser.parse::<keyword::s8_to_i64>()?;
|
||||
|
||||
Ok(Instruction::S8ToI64)
|
||||
} else if lookahead.peek::<keyword::u8_to_i64>() {
|
||||
parser.parse::<keyword::u8_to_i64>()?;
|
||||
|
||||
Ok(Instruction::U8ToI64)
|
||||
} else if lookahead.peek::<keyword::s16_to_i64>() {
|
||||
parser.parse::<keyword::s16_to_i64>()?;
|
||||
|
||||
Ok(Instruction::S16ToI64)
|
||||
} else if lookahead.peek::<keyword::u16_to_i64>() {
|
||||
parser.parse::<keyword::u16_to_i64>()?;
|
||||
|
||||
Ok(Instruction::U16ToI64)
|
||||
} else if lookahead.peek::<keyword::s32_to_i64>() {
|
||||
parser.parse::<keyword::s32_to_i64>()?;
|
||||
|
||||
Ok(Instruction::S32ToI64)
|
||||
} else if lookahead.peek::<keyword::u32_to_i64>() {
|
||||
parser.parse::<keyword::u32_to_i64>()?;
|
||||
|
||||
Ok(Instruction::U32ToI64)
|
||||
} else if lookahead.peek::<keyword::s64_to_i64>() {
|
||||
parser.parse::<keyword::s64_to_i64>()?;
|
||||
|
||||
Ok(Instruction::S64ToI64)
|
||||
} else if lookahead.peek::<keyword::u64_to_i64>() {
|
||||
parser.parse::<keyword::u64_to_i64>()?;
|
||||
|
||||
Ok(Instruction::U64ToI64)
|
||||
} else {
|
||||
Err(lookahead.error())
|
||||
}
|
||||
@ -667,94 +632,80 @@ mod tests {
|
||||
let inputs = vec![
|
||||
"arg.get 7",
|
||||
"call-core 7",
|
||||
"s8.from_i32",
|
||||
"s8.from_i64",
|
||||
"s16.from_i32",
|
||||
"s16.from_i64",
|
||||
"s32.from_i32",
|
||||
"s32.from_i64",
|
||||
"s64.from_i32",
|
||||
"s64.from_i64",
|
||||
"i32.from_s8",
|
||||
"i32.from_s16",
|
||||
"i32.from_s32",
|
||||
"i32.from_s64",
|
||||
"i64.from_s8",
|
||||
"i64.from_s16",
|
||||
"i64.from_s32",
|
||||
"i64.from_s64",
|
||||
"u8.from_i32",
|
||||
"u8.from_i64",
|
||||
"u16.from_i32",
|
||||
"u16.from_i64",
|
||||
"u32.from_i32",
|
||||
"u32.from_i64",
|
||||
"u64.from_i32",
|
||||
"u64.from_i64",
|
||||
"i32.from_u8",
|
||||
"i32.from_u16",
|
||||
"i32.from_u32",
|
||||
"i32.from_u64",
|
||||
"i64.from_u8",
|
||||
"i64.from_u16",
|
||||
"i64.from_u32",
|
||||
"i64.from_u64",
|
||||
"memory-to-string",
|
||||
"string-to-memory 42",
|
||||
"i32-to-s8",
|
||||
"i32-to-s8x",
|
||||
"i32-to-u8",
|
||||
"i32-to-s16",
|
||||
"i32-to-s16x",
|
||||
"i32-to-u16",
|
||||
"i32-to-s32",
|
||||
"i32-to-u32",
|
||||
"i32-to-s64",
|
||||
"i32-to-u64",
|
||||
"i64-to-s8",
|
||||
"i64-to-s8x",
|
||||
"i64-to-u8",
|
||||
"i64-to-s16",
|
||||
"i64-to-s16x",
|
||||
"i64-to-u16",
|
||||
"i64-to-s32",
|
||||
"i64-to-s32x",
|
||||
"i64-to-u32",
|
||||
"i64-to-s64",
|
||||
"i64-to-u64",
|
||||
"s8-to-i32",
|
||||
"u8-to-i32",
|
||||
"s16-to-i32",
|
||||
"u16-to-i32",
|
||||
"s32-to-i32",
|
||||
"u32-to-i32",
|
||||
"s64-to-i32",
|
||||
"s64-to-i32x",
|
||||
"u64-to-i32",
|
||||
"u64-to-i32x",
|
||||
"s8-to-i64",
|
||||
"u8-to-i64",
|
||||
"s16-to-i64",
|
||||
"u16-to-i64",
|
||||
"s32-to-i64",
|
||||
"u32-to-i64",
|
||||
"s64-to-i64",
|
||||
"u64-to-i64",
|
||||
];
|
||||
let outputs = vec![
|
||||
Instruction::ArgumentGet { index: 7 },
|
||||
Instruction::CallCore { function_index: 7 },
|
||||
Instruction::S8FromI32,
|
||||
Instruction::S8FromI64,
|
||||
Instruction::S16FromI32,
|
||||
Instruction::S16FromI64,
|
||||
Instruction::S32FromI32,
|
||||
Instruction::S32FromI64,
|
||||
Instruction::S64FromI32,
|
||||
Instruction::S64FromI64,
|
||||
Instruction::I32FromS8,
|
||||
Instruction::I32FromS16,
|
||||
Instruction::I32FromS32,
|
||||
Instruction::I32FromS64,
|
||||
Instruction::I64FromS8,
|
||||
Instruction::I64FromS16,
|
||||
Instruction::I64FromS32,
|
||||
Instruction::I64FromS64,
|
||||
Instruction::U8FromI32,
|
||||
Instruction::U8FromI64,
|
||||
Instruction::U16FromI32,
|
||||
Instruction::U16FromI64,
|
||||
Instruction::U32FromI32,
|
||||
Instruction::U32FromI64,
|
||||
Instruction::U64FromI32,
|
||||
Instruction::U64FromI64,
|
||||
Instruction::I32FromU8,
|
||||
Instruction::I32FromU16,
|
||||
Instruction::I32FromU32,
|
||||
Instruction::I32FromU64,
|
||||
Instruction::I64FromU8,
|
||||
Instruction::I64FromU16,
|
||||
Instruction::I64FromU32,
|
||||
Instruction::I64FromU64,
|
||||
Instruction::MemoryToString,
|
||||
Instruction::StringToMemory {
|
||||
allocator_index: 42,
|
||||
},
|
||||
Instruction::I32ToS8,
|
||||
Instruction::I32ToS8X,
|
||||
Instruction::I32ToU8,
|
||||
Instruction::I32ToS16,
|
||||
Instruction::I32ToS16X,
|
||||
Instruction::I32ToU16,
|
||||
Instruction::I32ToS32,
|
||||
Instruction::I32ToU32,
|
||||
Instruction::I32ToS64,
|
||||
Instruction::I32ToU64,
|
||||
Instruction::I64ToS8,
|
||||
Instruction::I64ToS8X,
|
||||
Instruction::I64ToU8,
|
||||
Instruction::I64ToS16,
|
||||
Instruction::I64ToS16X,
|
||||
Instruction::I64ToU16,
|
||||
Instruction::I64ToS32,
|
||||
Instruction::I64ToS32X,
|
||||
Instruction::I64ToU32,
|
||||
Instruction::I64ToS64,
|
||||
Instruction::I64ToU64,
|
||||
Instruction::S8ToI32,
|
||||
Instruction::U8ToI32,
|
||||
Instruction::S16ToI32,
|
||||
Instruction::U16ToI32,
|
||||
Instruction::S32ToI32,
|
||||
Instruction::U32ToI32,
|
||||
Instruction::S64ToI32,
|
||||
Instruction::S64ToI32X,
|
||||
Instruction::U64ToI32,
|
||||
Instruction::U64ToI32X,
|
||||
Instruction::S8ToI64,
|
||||
Instruction::U8ToI64,
|
||||
Instruction::S16ToI64,
|
||||
Instruction::U16ToI64,
|
||||
Instruction::S32ToI64,
|
||||
Instruction::U32ToI64,
|
||||
Instruction::S64ToI64,
|
||||
Instruction::U64ToI64,
|
||||
];
|
||||
|
||||
assert_eq!(inputs.len(), outputs.len());
|
||||
|
@ -260,52 +260,45 @@ where
|
||||
(*function_index as u64).to_bytes(writer)?;
|
||||
}
|
||||
|
||||
Instruction::MemoryToString => 0x03_u8.to_bytes(writer)?,
|
||||
Instruction::S8FromI32 => 0x02_u8.to_bytes(writer)?,
|
||||
Instruction::S8FromI64 => 0x03_u8.to_bytes(writer)?,
|
||||
Instruction::S16FromI32 => 0x04_u8.to_bytes(writer)?,
|
||||
Instruction::S16FromI64 => 0x05_u8.to_bytes(writer)?,
|
||||
Instruction::S32FromI32 => 0x06_u8.to_bytes(writer)?,
|
||||
Instruction::S32FromI64 => 0x07_u8.to_bytes(writer)?,
|
||||
Instruction::S64FromI32 => 0x08_u8.to_bytes(writer)?,
|
||||
Instruction::S64FromI64 => 0x09_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromS8 => 0x0a_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromS16 => 0x0b_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromS32 => 0x0c_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromS64 => 0x0d_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromS8 => 0x0e_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromS16 => 0x0f_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromS32 => 0x10_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromS64 => 0x11_u8.to_bytes(writer)?,
|
||||
Instruction::U8FromI32 => 0x12_u8.to_bytes(writer)?,
|
||||
Instruction::U8FromI64 => 0x13_u8.to_bytes(writer)?,
|
||||
Instruction::U16FromI32 => 0x14_u8.to_bytes(writer)?,
|
||||
Instruction::U16FromI64 => 0x15_u8.to_bytes(writer)?,
|
||||
Instruction::U32FromI32 => 0x16_u8.to_bytes(writer)?,
|
||||
Instruction::U32FromI64 => 0x17_u8.to_bytes(writer)?,
|
||||
Instruction::U64FromI32 => 0x18_u8.to_bytes(writer)?,
|
||||
Instruction::U64FromI64 => 0x19_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromU8 => 0x1a_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromU16 => 0x1b_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromU32 => 0x1c_u8.to_bytes(writer)?,
|
||||
Instruction::I32FromU64 => 0x1d_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromU8 => 0x1e_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromU16 => 0x1f_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromU32 => 0x20_u8.to_bytes(writer)?,
|
||||
Instruction::I64FromU64 => 0x21_u8.to_bytes(writer)?,
|
||||
|
||||
Instruction::MemoryToString => 0x22_u8.to_bytes(writer)?,
|
||||
|
||||
Instruction::StringToMemory { allocator_index } => {
|
||||
0x04_u8.to_bytes(writer)?;
|
||||
0x23_u8.to_bytes(writer)?;
|
||||
(*allocator_index as u64).to_bytes(writer)?;
|
||||
}
|
||||
|
||||
Instruction::I32ToS8 => 0x07_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToS8X => 0x08_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToU8 => 0x09_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToS16 => 0x0a_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToS16X => 0x0b_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToU16 => 0x0c_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToS32 => 0x0d_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToU32 => 0x0e_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToS64 => 0x0f_u8.to_bytes(writer)?,
|
||||
Instruction::I32ToU64 => 0x10_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS8 => 0x11_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS8X => 0x12_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToU8 => 0x13_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS16 => 0x14_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS16X => 0x15_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToU16 => 0x16_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS32 => 0x17_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS32X => 0x18_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToU32 => 0x19_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToS64 => 0x1a_u8.to_bytes(writer)?,
|
||||
Instruction::I64ToU64 => 0x1b_u8.to_bytes(writer)?,
|
||||
Instruction::S8ToI32 => 0x1c_u8.to_bytes(writer)?,
|
||||
Instruction::U8ToI32 => 0x1d_u8.to_bytes(writer)?,
|
||||
Instruction::S16ToI32 => 0x1e_u8.to_bytes(writer)?,
|
||||
Instruction::U16ToI32 => 0x1f_u8.to_bytes(writer)?,
|
||||
Instruction::S32ToI32 => 0x20_u8.to_bytes(writer)?,
|
||||
Instruction::U32ToI32 => 0x21_u8.to_bytes(writer)?,
|
||||
Instruction::S64ToI32 => 0x22_u8.to_bytes(writer)?,
|
||||
Instruction::S64ToI32X => 0x23_u8.to_bytes(writer)?,
|
||||
Instruction::U64ToI32 => 0x24_u8.to_bytes(writer)?,
|
||||
Instruction::U64ToI32X => 0x25_u8.to_bytes(writer)?,
|
||||
Instruction::S8ToI64 => 0x26_u8.to_bytes(writer)?,
|
||||
Instruction::U8ToI64 => 0x27_u8.to_bytes(writer)?,
|
||||
Instruction::S16ToI64 => 0x28_u8.to_bytes(writer)?,
|
||||
Instruction::U16ToI64 => 0x29_u8.to_bytes(writer)?,
|
||||
Instruction::S32ToI64 => 0x2a_u8.to_bytes(writer)?,
|
||||
Instruction::U32ToI64 => 0x2b_u8.to_bytes(writer)?,
|
||||
Instruction::S64ToI64 => 0x2c_u8.to_bytes(writer)?,
|
||||
Instruction::U64ToI64 => 0x2d_u8.to_bytes(writer)?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -550,93 +543,79 @@ mod tests {
|
||||
vec![
|
||||
Instruction::ArgumentGet { index: 1 },
|
||||
Instruction::CallCore { function_index: 1 },
|
||||
Instruction::S8FromI32,
|
||||
Instruction::S8FromI64,
|
||||
Instruction::S16FromI32,
|
||||
Instruction::S16FromI64,
|
||||
Instruction::S32FromI32,
|
||||
Instruction::S32FromI64,
|
||||
Instruction::S64FromI32,
|
||||
Instruction::S64FromI64,
|
||||
Instruction::I32FromS8,
|
||||
Instruction::I32FromS16,
|
||||
Instruction::I32FromS32,
|
||||
Instruction::I32FromS64,
|
||||
Instruction::I64FromS8,
|
||||
Instruction::I64FromS16,
|
||||
Instruction::I64FromS32,
|
||||
Instruction::I64FromS64,
|
||||
Instruction::U8FromI32,
|
||||
Instruction::U8FromI64,
|
||||
Instruction::U16FromI32,
|
||||
Instruction::U16FromI64,
|
||||
Instruction::U32FromI32,
|
||||
Instruction::U32FromI64,
|
||||
Instruction::U64FromI32,
|
||||
Instruction::U64FromI64,
|
||||
Instruction::I32FromU8,
|
||||
Instruction::I32FromU16,
|
||||
Instruction::I32FromU32,
|
||||
Instruction::I32FromU64,
|
||||
Instruction::I64FromU8,
|
||||
Instruction::I64FromU16,
|
||||
Instruction::I64FromU32,
|
||||
Instruction::I64FromU64,
|
||||
Instruction::MemoryToString,
|
||||
Instruction::StringToMemory { allocator_index: 1 },
|
||||
Instruction::I32ToS8,
|
||||
Instruction::I32ToS8X,
|
||||
Instruction::I32ToU8,
|
||||
Instruction::I32ToS16,
|
||||
Instruction::I32ToS16X,
|
||||
Instruction::I32ToU16,
|
||||
Instruction::I32ToS32,
|
||||
Instruction::I32ToU32,
|
||||
Instruction::I32ToS64,
|
||||
Instruction::I32ToU64,
|
||||
Instruction::I64ToS8,
|
||||
Instruction::I64ToS8X,
|
||||
Instruction::I64ToU8,
|
||||
Instruction::I64ToS16,
|
||||
Instruction::I64ToS16X,
|
||||
Instruction::I64ToU16,
|
||||
Instruction::I64ToS32,
|
||||
Instruction::I64ToS32X,
|
||||
Instruction::I64ToU32,
|
||||
Instruction::I64ToS64,
|
||||
Instruction::I64ToU64,
|
||||
Instruction::S8ToI32,
|
||||
Instruction::U8ToI32,
|
||||
Instruction::S16ToI32,
|
||||
Instruction::U16ToI32,
|
||||
Instruction::S32ToI32,
|
||||
Instruction::U32ToI32,
|
||||
Instruction::S64ToI32,
|
||||
Instruction::S64ToI32X,
|
||||
Instruction::U64ToI32,
|
||||
Instruction::U64ToI32X,
|
||||
Instruction::S8ToI64,
|
||||
Instruction::U8ToI64,
|
||||
Instruction::S16ToI64,
|
||||
Instruction::U16ToI64,
|
||||
Instruction::S32ToI64,
|
||||
Instruction::U32ToI64,
|
||||
Instruction::S64ToI64,
|
||||
Instruction::U64ToI64,
|
||||
],
|
||||
&[
|
||||
0x2b, // list of 43 items
|
||||
0x24, // list of 36 items
|
||||
0x00, 0x01, // ArgumentGet { index: 1 }
|
||||
0x01, 0x01, // CallCore { function_index: 1 }
|
||||
0x03, // MemoryToString
|
||||
0x04, 0x01, // StringToMemory { allocator_index: 1 }
|
||||
0x07, // I32ToS8
|
||||
0x08, // I32ToS8X
|
||||
0x09, // I32ToU8
|
||||
0x0a, // I32ToS16
|
||||
0x0b, // I32ToS16X
|
||||
0x0c, // I32ToU16
|
||||
0x0d, // I32ToS32
|
||||
0x0e, // I32ToU32
|
||||
0x0f, // I32ToS64
|
||||
0x10, // I32ToU64
|
||||
0x11, // I64ToS8
|
||||
0x12, // I64ToS8X
|
||||
0x13, // I64ToU8
|
||||
0x14, // I64ToS16
|
||||
0x15, // I64ToS16X
|
||||
0x16, // I64ToU16
|
||||
0x17, // I64ToS32
|
||||
0x18, // I64ToS32X
|
||||
0x19, // I64ToU32
|
||||
0x1a, // I64ToS64
|
||||
0x1b, // I64ToU64
|
||||
0x1c, // S8ToI32
|
||||
0x1d, // U8ToI32
|
||||
0x1e, // S16ToI32
|
||||
0x1f, // U16ToI32
|
||||
0x20, // S32ToI32
|
||||
0x21, // U32ToI32
|
||||
0x22, // S64ToI32
|
||||
0x23, // S64ToI32X
|
||||
0x24, // U64ToI32
|
||||
0x25, // U64ToI32X
|
||||
0x26, // S8ToI64
|
||||
0x27, // U8ToI64
|
||||
0x28, // S16ToI64
|
||||
0x29, // U16ToI64
|
||||
0x2a, // S32ToI64
|
||||
0x2b, // U32ToI64
|
||||
0x2c, // S64ToI64
|
||||
0x2d, // U64ToI64
|
||||
0x02, // S8FromI32
|
||||
0x03, // S8FromI64
|
||||
0x04, // S16FromI32
|
||||
0x05, // S16FromI64
|
||||
0x06, // S32FromI32
|
||||
0x07, // S32FromI64
|
||||
0x08, // S64FromI32
|
||||
0x09, // S64FromI64
|
||||
0x0a, // I32FromS8
|
||||
0x0b, // I32FromS16
|
||||
0x0c, // I32FromS32
|
||||
0x0d, // I32FromS64
|
||||
0x0e, // I64FromS8
|
||||
0x0f, // I64FromS16
|
||||
0x10, // I64FromS32
|
||||
0x11, // I64FromS64
|
||||
0x12, // U8FromI32
|
||||
0x13, // U8FromI64
|
||||
0x14, // U16FromI32
|
||||
0x15, // U16FromI64
|
||||
0x16, // U32FromI32
|
||||
0x17, // U32FromI64
|
||||
0x18, // U64FromI32
|
||||
0x19, // U64FromI64
|
||||
0x1a, // I32FromU8
|
||||
0x1b, // I32FromU16
|
||||
0x1c, // I32FromU32
|
||||
0x1d, // I32FromU64
|
||||
0x1e, // I64FromU8
|
||||
0x1f, // I64FromU16
|
||||
0x20, // I64FromU32
|
||||
0x21, // I64FromU64
|
||||
0x22, // MemoryToString
|
||||
0x23, 0x01, // StringToMemory { allocator_index: 1 }
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -85,49 +85,42 @@ impl ToString for &Instruction {
|
||||
match self {
|
||||
Instruction::ArgumentGet { index } => format!("arg.get {}", index),
|
||||
Instruction::CallCore { function_index } => format!("call-core {}", function_index),
|
||||
Instruction::S8FromI32 => "s8.from_i32".into(),
|
||||
Instruction::S8FromI64 => "s8.from_i64".into(),
|
||||
Instruction::S16FromI32 => "s16.from_i32".into(),
|
||||
Instruction::S16FromI64 => "s16.from_i64".into(),
|
||||
Instruction::S32FromI32 => "s32.from_i32".into(),
|
||||
Instruction::S32FromI64 => "s32.from_i64".into(),
|
||||
Instruction::S64FromI32 => "s64.from_i32".into(),
|
||||
Instruction::S64FromI64 => "s64.from_i64".into(),
|
||||
Instruction::I32FromS8 => "i32.from_s8".into(),
|
||||
Instruction::I32FromS16 => "i32.from_s16".into(),
|
||||
Instruction::I32FromS32 => "i32.from_s32".into(),
|
||||
Instruction::I32FromS64 => "i32.from_s64".into(),
|
||||
Instruction::I64FromS8 => "i64.from_s8".into(),
|
||||
Instruction::I64FromS16 => "i64.from_s16".into(),
|
||||
Instruction::I64FromS32 => "i64.from_s32".into(),
|
||||
Instruction::I64FromS64 => "i64.from_s64".into(),
|
||||
Instruction::U8FromI32 => "u8.from_i32".into(),
|
||||
Instruction::U8FromI64 => "u8.from_i64".into(),
|
||||
Instruction::U16FromI32 => "u16.from_i32".into(),
|
||||
Instruction::U16FromI64 => "u16.from_i64".into(),
|
||||
Instruction::U32FromI32 => "u32.from_i32".into(),
|
||||
Instruction::U32FromI64 => "u32.from_i64".into(),
|
||||
Instruction::U64FromI32 => "u64.from_i32".into(),
|
||||
Instruction::U64FromI64 => "u64.from_i64".into(),
|
||||
Instruction::I32FromU8 => "i32.from_u8".into(),
|
||||
Instruction::I32FromU16 => "i32.from_u16".into(),
|
||||
Instruction::I32FromU32 => "i32.from_u32".into(),
|
||||
Instruction::I32FromU64 => "i32.from_u64".into(),
|
||||
Instruction::I64FromU8 => "i64.from_u8".into(),
|
||||
Instruction::I64FromU16 => "i64.from_u16".into(),
|
||||
Instruction::I64FromU32 => "i64.from_u32".into(),
|
||||
Instruction::I64FromU64 => "i64.from_u64".into(),
|
||||
Instruction::MemoryToString => "memory-to-string".into(),
|
||||
Instruction::StringToMemory { allocator_index } => {
|
||||
format!(r#"string-to-memory {}"#, allocator_index)
|
||||
}
|
||||
Instruction::I32ToS8 => "i32-to-s8".into(),
|
||||
Instruction::I32ToS8X => "i32-to-s8x".into(),
|
||||
Instruction::I32ToU8 => "i32-to-u8".into(),
|
||||
Instruction::I32ToS16 => "i32-to-s16".into(),
|
||||
Instruction::I32ToS16X => "i32-to-s16x".into(),
|
||||
Instruction::I32ToU16 => "i32-to-u16".into(),
|
||||
Instruction::I32ToS32 => "i32-to-s32".into(),
|
||||
Instruction::I32ToU32 => "i32-to-u32".into(),
|
||||
Instruction::I32ToS64 => "i32-to-s64".into(),
|
||||
Instruction::I32ToU64 => "i32-to-u64".into(),
|
||||
Instruction::I64ToS8 => "i64-to-s8".into(),
|
||||
Instruction::I64ToS8X => "i64-to-s8x".into(),
|
||||
Instruction::I64ToU8 => "i64-to-u8".into(),
|
||||
Instruction::I64ToS16 => "i64-to-s16".into(),
|
||||
Instruction::I64ToS16X => "i64-to-s16x".into(),
|
||||
Instruction::I64ToU16 => "i64-to-u16".into(),
|
||||
Instruction::I64ToS32 => "i64-to-s32".into(),
|
||||
Instruction::I64ToS32X => "i64-to-s32x".into(),
|
||||
Instruction::I64ToU32 => "i64-to-u32".into(),
|
||||
Instruction::I64ToS64 => "i64-to-s64".into(),
|
||||
Instruction::I64ToU64 => "i64-to-u64".into(),
|
||||
Instruction::S8ToI32 => "s8-to-i32".into(),
|
||||
Instruction::U8ToI32 => "u8-to-i32".into(),
|
||||
Instruction::S16ToI32 => "s16-to-i32".into(),
|
||||
Instruction::U16ToI32 => "u16-to-i32".into(),
|
||||
Instruction::S32ToI32 => "s32-to-i32".into(),
|
||||
Instruction::U32ToI32 => "u32-to-i32".into(),
|
||||
Instruction::S64ToI32 => "s64-to-i32".into(),
|
||||
Instruction::S64ToI32X => "s64-to-i32x".into(),
|
||||
Instruction::U64ToI32 => "u64-to-i32".into(),
|
||||
Instruction::U64ToI32X => "u64-to-i32x".into(),
|
||||
Instruction::S8ToI64 => "s8-to-i64".into(),
|
||||
Instruction::U8ToI64 => "u8-to-i64".into(),
|
||||
Instruction::S16ToI64 => "s16-to-i64".into(),
|
||||
Instruction::U16ToI64 => "u16-to-i64".into(),
|
||||
Instruction::S32ToI64 => "s32-to-i64".into(),
|
||||
Instruction::U32ToI64 => "u32-to-i64".into(),
|
||||
Instruction::S64ToI64 => "s64-to-i64".into(),
|
||||
Instruction::U64ToI64 => "u64-to-i64".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -361,95 +354,81 @@ mod tests {
|
||||
let inputs: Vec<String> = vec![
|
||||
(&Instruction::ArgumentGet { index: 7 }).to_string(),
|
||||
(&Instruction::CallCore { function_index: 7 }).to_string(),
|
||||
(&Instruction::S8FromI32).to_string(),
|
||||
(&Instruction::S8FromI64).to_string(),
|
||||
(&Instruction::S16FromI32).to_string(),
|
||||
(&Instruction::S16FromI64).to_string(),
|
||||
(&Instruction::S32FromI32).to_string(),
|
||||
(&Instruction::S32FromI64).to_string(),
|
||||
(&Instruction::S64FromI32).to_string(),
|
||||
(&Instruction::S64FromI64).to_string(),
|
||||
(&Instruction::I32FromS8).to_string(),
|
||||
(&Instruction::I32FromS16).to_string(),
|
||||
(&Instruction::I32FromS32).to_string(),
|
||||
(&Instruction::I32FromS64).to_string(),
|
||||
(&Instruction::I64FromS8).to_string(),
|
||||
(&Instruction::I64FromS16).to_string(),
|
||||
(&Instruction::I64FromS32).to_string(),
|
||||
(&Instruction::I64FromS64).to_string(),
|
||||
(&Instruction::U8FromI32).to_string(),
|
||||
(&Instruction::U8FromI64).to_string(),
|
||||
(&Instruction::U16FromI32).to_string(),
|
||||
(&Instruction::U16FromI64).to_string(),
|
||||
(&Instruction::U32FromI32).to_string(),
|
||||
(&Instruction::U32FromI64).to_string(),
|
||||
(&Instruction::U64FromI32).to_string(),
|
||||
(&Instruction::U64FromI64).to_string(),
|
||||
(&Instruction::I32FromU8).to_string(),
|
||||
(&Instruction::I32FromU16).to_string(),
|
||||
(&Instruction::I32FromU32).to_string(),
|
||||
(&Instruction::I32FromU64).to_string(),
|
||||
(&Instruction::I64FromU8).to_string(),
|
||||
(&Instruction::I64FromU16).to_string(),
|
||||
(&Instruction::I64FromU32).to_string(),
|
||||
(&Instruction::I64FromU64).to_string(),
|
||||
(&Instruction::MemoryToString).to_string(),
|
||||
(&Instruction::StringToMemory {
|
||||
allocator_index: 42,
|
||||
})
|
||||
.to_string(),
|
||||
(&Instruction::I32ToS8).to_string(),
|
||||
(&Instruction::I32ToS8X).to_string(),
|
||||
(&Instruction::I32ToU8).to_string(),
|
||||
(&Instruction::I32ToS16).to_string(),
|
||||
(&Instruction::I32ToS16X).to_string(),
|
||||
(&Instruction::I32ToU16).to_string(),
|
||||
(&Instruction::I32ToS32).to_string(),
|
||||
(&Instruction::I32ToU32).to_string(),
|
||||
(&Instruction::I32ToS64).to_string(),
|
||||
(&Instruction::I32ToU64).to_string(),
|
||||
(&Instruction::I64ToS8).to_string(),
|
||||
(&Instruction::I64ToS8X).to_string(),
|
||||
(&Instruction::I64ToU8).to_string(),
|
||||
(&Instruction::I64ToS16).to_string(),
|
||||
(&Instruction::I64ToS16X).to_string(),
|
||||
(&Instruction::I64ToU16).to_string(),
|
||||
(&Instruction::I64ToS32).to_string(),
|
||||
(&Instruction::I64ToS32X).to_string(),
|
||||
(&Instruction::I64ToU32).to_string(),
|
||||
(&Instruction::I64ToS64).to_string(),
|
||||
(&Instruction::I64ToU64).to_string(),
|
||||
(&Instruction::S8ToI32).to_string(),
|
||||
(&Instruction::U8ToI32).to_string(),
|
||||
(&Instruction::S16ToI32).to_string(),
|
||||
(&Instruction::U16ToI32).to_string(),
|
||||
(&Instruction::S32ToI32).to_string(),
|
||||
(&Instruction::U32ToI32).to_string(),
|
||||
(&Instruction::S64ToI32).to_string(),
|
||||
(&Instruction::S64ToI32X).to_string(),
|
||||
(&Instruction::U64ToI32).to_string(),
|
||||
(&Instruction::U64ToI32X).to_string(),
|
||||
(&Instruction::S8ToI64).to_string(),
|
||||
(&Instruction::U8ToI64).to_string(),
|
||||
(&Instruction::S16ToI64).to_string(),
|
||||
(&Instruction::U16ToI64).to_string(),
|
||||
(&Instruction::S32ToI64).to_string(),
|
||||
(&Instruction::U32ToI64).to_string(),
|
||||
(&Instruction::S64ToI64).to_string(),
|
||||
(&Instruction::U64ToI64).to_string(),
|
||||
];
|
||||
let outputs = vec![
|
||||
"arg.get 7",
|
||||
"call-core 7",
|
||||
"s8.from_i32",
|
||||
"s8.from_i64",
|
||||
"s16.from_i32",
|
||||
"s16.from_i64",
|
||||
"s32.from_i32",
|
||||
"s32.from_i64",
|
||||
"s64.from_i32",
|
||||
"s64.from_i64",
|
||||
"i32.from_s8",
|
||||
"i32.from_s16",
|
||||
"i32.from_s32",
|
||||
"i32.from_s64",
|
||||
"i64.from_s8",
|
||||
"i64.from_s16",
|
||||
"i64.from_s32",
|
||||
"i64.from_s64",
|
||||
"u8.from_i32",
|
||||
"u8.from_i64",
|
||||
"u16.from_i32",
|
||||
"u16.from_i64",
|
||||
"u32.from_i32",
|
||||
"u32.from_i64",
|
||||
"u64.from_i32",
|
||||
"u64.from_i64",
|
||||
"i32.from_u8",
|
||||
"i32.from_u16",
|
||||
"i32.from_u32",
|
||||
"i32.from_u64",
|
||||
"i64.from_u8",
|
||||
"i64.from_u16",
|
||||
"i64.from_u32",
|
||||
"i64.from_u64",
|
||||
"memory-to-string",
|
||||
"string-to-memory 42",
|
||||
"i32-to-s8",
|
||||
"i32-to-s8x",
|
||||
"i32-to-u8",
|
||||
"i32-to-s16",
|
||||
"i32-to-s16x",
|
||||
"i32-to-u16",
|
||||
"i32-to-s32",
|
||||
"i32-to-u32",
|
||||
"i32-to-s64",
|
||||
"i32-to-u64",
|
||||
"i64-to-s8",
|
||||
"i64-to-s8x",
|
||||
"i64-to-u8",
|
||||
"i64-to-s16",
|
||||
"i64-to-s16x",
|
||||
"i64-to-u16",
|
||||
"i64-to-s32",
|
||||
"i64-to-s32x",
|
||||
"i64-to-u32",
|
||||
"i64-to-s64",
|
||||
"i64-to-u64",
|
||||
"s8-to-i32",
|
||||
"u8-to-i32",
|
||||
"s16-to-i32",
|
||||
"u16-to-i32",
|
||||
"s32-to-i32",
|
||||
"u32-to-i32",
|
||||
"s64-to-i32",
|
||||
"s64-to-i32x",
|
||||
"u64-to-i32",
|
||||
"u64-to-i32x",
|
||||
"s8-to-i64",
|
||||
"u8-to-i64",
|
||||
"s16-to-i64",
|
||||
"u16-to-i64",
|
||||
"s32-to-i64",
|
||||
"u32-to-i64",
|
||||
"s64-to-i64",
|
||||
"u64-to-i64",
|
||||
];
|
||||
|
||||
assert_eq!(inputs, outputs);
|
||||
|
@ -24,120 +24,99 @@ pub enum Instruction {
|
||||
allocator_index: u32,
|
||||
},
|
||||
|
||||
/// The `i32-to-s8,` instruction.
|
||||
I32ToS8,
|
||||
/// The `s8.from_i32` instruction.
|
||||
S8FromI32,
|
||||
|
||||
/// The `i32-to-s8x,` instruction.
|
||||
I32ToS8X,
|
||||
/// The `s8.from_i64` instruction.
|
||||
S8FromI64,
|
||||
|
||||
/// The `i32-to-u8,` instruction.
|
||||
I32ToU8,
|
||||
/// The `s16.from_i32` instruction.
|
||||
S16FromI32,
|
||||
|
||||
/// The `i32-to-s16,` instruction.
|
||||
I32ToS16,
|
||||
/// The `s16.from_i64` instruction.
|
||||
S16FromI64,
|
||||
|
||||
/// The `i32-to-s16x,` instruction.
|
||||
I32ToS16X,
|
||||
/// The `s32.from_i32` instruction.
|
||||
S32FromI32,
|
||||
|
||||
/// The `i32-to-u16,` instruction.
|
||||
I32ToU16,
|
||||
/// The `s32.from_i64` instruction.
|
||||
S32FromI64,
|
||||
|
||||
/// The `i32-to-s32,` instruction.
|
||||
I32ToS32,
|
||||
/// The `s64.from_i32` instruction.
|
||||
S64FromI32,
|
||||
|
||||
/// The `i32-to-u32,` instruction.
|
||||
I32ToU32,
|
||||
/// The `s64.from_i64` instruction.
|
||||
S64FromI64,
|
||||
|
||||
/// The `i32-to-s64,` instruction.
|
||||
I32ToS64,
|
||||
/// The `i32.from_s8` instruction.
|
||||
I32FromS8,
|
||||
|
||||
/// The `i32-to-u64,` instruction.
|
||||
I32ToU64,
|
||||
/// The `i32.from_s16` instruction.
|
||||
I32FromS16,
|
||||
|
||||
/// The `i64-to-s8,` instruction.
|
||||
I64ToS8,
|
||||
/// The `i32.from_s32` instruction.
|
||||
I32FromS32,
|
||||
|
||||
/// The `i64-to-s8x,` instruction.
|
||||
I64ToS8X,
|
||||
/// The `i32.from_s64` instruction.
|
||||
I32FromS64,
|
||||
|
||||
/// The `i64-to-u8,` instruction.
|
||||
I64ToU8,
|
||||
/// The `i64.from_s8` instruction.
|
||||
I64FromS8,
|
||||
|
||||
/// The `i64-to-s16,` instruction.
|
||||
I64ToS16,
|
||||
/// The `i64.from_s16` instruction.
|
||||
I64FromS16,
|
||||
|
||||
/// The `i64-to-s16x,` instruction.
|
||||
I64ToS16X,
|
||||
/// The `i64.from_s32` instruction.
|
||||
I64FromS32,
|
||||
|
||||
/// The `i64-to-u16,` instruction.
|
||||
I64ToU16,
|
||||
/// The `i64.from_s64` instruction.
|
||||
I64FromS64,
|
||||
|
||||
/// The `i64-to-s32,` instruction.
|
||||
I64ToS32,
|
||||
/// The `u8.from_i32` instruction.
|
||||
U8FromI32,
|
||||
|
||||
/// The `i64-to-s32x,` instruction.
|
||||
I64ToS32X,
|
||||
/// The `u8.from_i64` instruction.
|
||||
U8FromI64,
|
||||
|
||||
/// The `i64-to-u32,` instruction.
|
||||
I64ToU32,
|
||||
/// The `u16.from_i32` instruction.
|
||||
U16FromI32,
|
||||
|
||||
/// The `i64-to-s64,` instruction.
|
||||
I64ToS64,
|
||||
/// The `u16.from_i64` instruction.
|
||||
U16FromI64,
|
||||
|
||||
/// The `i64-to-u64,` instruction.
|
||||
I64ToU64,
|
||||
/// The `u32.from_i32` instruction.
|
||||
U32FromI32,
|
||||
|
||||
/// The `s8-to-i32,` instruction.
|
||||
S8ToI32,
|
||||
/// The `u32.from_i64` instruction.
|
||||
U32FromI64,
|
||||
|
||||
/// The `u8-to-i32,` instruction.
|
||||
U8ToI32,
|
||||
/// The `u64.from_i32` instruction.
|
||||
U64FromI32,
|
||||
|
||||
/// The `s16-to-i32,` instruction.
|
||||
S16ToI32,
|
||||
/// The `u64.from_i64` instruction.
|
||||
U64FromI64,
|
||||
|
||||
/// The `u16-to-i32,` instruction.
|
||||
U16ToI32,
|
||||
/// The `i32.from_u8` instruction.
|
||||
I32FromU8,
|
||||
|
||||
/// The `s32-to-i32,` instruction.
|
||||
S32ToI32,
|
||||
/// The `i32.from_u16` instruction.
|
||||
I32FromU16,
|
||||
|
||||
/// The `u32-to-i32,` instruction.
|
||||
U32ToI32,
|
||||
/// The `i32.from_u32` instruction.
|
||||
I32FromU32,
|
||||
|
||||
/// The `s64-to-i32,` instruction.
|
||||
S64ToI32,
|
||||
/// The `i32.from_u64` instruction.
|
||||
I32FromU64,
|
||||
|
||||
/// The `s64-to-i32x,` instruction.
|
||||
S64ToI32X,
|
||||
/// The `i64.from_u8` instruction.
|
||||
I64FromU8,
|
||||
|
||||
/// The `u64-to-i32,` instruction.
|
||||
U64ToI32,
|
||||
/// The `i64.from_u16` instruction.
|
||||
I64FromU16,
|
||||
|
||||
/// The `u64-to-i32x,` instruction.
|
||||
U64ToI32X,
|
||||
/// The `i64.from_u32` instruction.
|
||||
I64FromU32,
|
||||
|
||||
/// The `s8-to-i64,` instruction.
|
||||
S8ToI64,
|
||||
|
||||
/// The `u8-to-i64,` instruction.
|
||||
U8ToI64,
|
||||
|
||||
/// The `s16-to-i64,` instruction.
|
||||
S16ToI64,
|
||||
|
||||
/// The `u16-to-i64,` instruction.
|
||||
U16ToI64,
|
||||
|
||||
/// The `s32-to-i64,` instruction.
|
||||
S32ToI64,
|
||||
|
||||
/// The `u32-to-i64,` instruction.
|
||||
U32ToI64,
|
||||
|
||||
/// The `s64-to-i64,` instruction.
|
||||
S64ToI64,
|
||||
|
||||
/// The `u64-to-i64,` instruction.
|
||||
U64ToI64,
|
||||
/// The `i64.from_u64` instruction.
|
||||
I64FromU64,
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
use std::convert::TryInto;
|
||||
|
||||
macro_rules! lowering_lifting {
|
||||
($instruction_function_name:ident, $instruction_name:expr, $from_variant:ident, $to_variant:ident) => {
|
||||
($instruction_function_name:ident, $instruction_name:expr, $to_variant:ident, $from_variant:ident) => {
|
||||
executable_instruction!(
|
||||
$instruction_function_name(instruction: Instruction) -> _ {
|
||||
move |runtime| -> _ {
|
||||
@ -52,316 +52,316 @@ macro_rules! lowering_lifting {
|
||||
};
|
||||
}
|
||||
|
||||
lowering_lifting!(i32_to_s8, "i32-to-s8", I32, S8);
|
||||
lowering_lifting!(i32_to_u8, "i32-to-u8", I32, U8);
|
||||
lowering_lifting!(i32_to_s16, "i32-to-s16", I32, S16);
|
||||
lowering_lifting!(i32_to_u16, "i32-to-u16", I32, U16);
|
||||
lowering_lifting!(i32_to_s32, "i32-to-s32", I32, S32);
|
||||
lowering_lifting!(i32_to_u32, "i32-to-u32", I32, U32);
|
||||
lowering_lifting!(i32_to_s64, "i32-to-s64", I32, S64);
|
||||
lowering_lifting!(i32_to_u64, "i32-to-u64", I32, U64);
|
||||
lowering_lifting!(i64_to_s8, "i64-to-s8", I64, S8);
|
||||
lowering_lifting!(i64_to_u8, "i64-to-u8", I64, U8);
|
||||
lowering_lifting!(i64_to_s16, "i64-to-s16", I64, S16);
|
||||
lowering_lifting!(i64_to_u16, "i64-to-u16", I64, U16);
|
||||
lowering_lifting!(i64_to_s32, "i64-to-s32", I64, S32);
|
||||
lowering_lifting!(i64_to_u32, "i64-to-u32", I64, U32);
|
||||
lowering_lifting!(i64_to_s64, "i64-to-s64", I64, S64);
|
||||
lowering_lifting!(i64_to_u64, "i64-to-u64", I64, U64);
|
||||
lowering_lifting!(s8_to_i32, "s8-to-i32", S8, I32);
|
||||
lowering_lifting!(u8_to_i32, "u8-to-i32", U8, I32);
|
||||
lowering_lifting!(s16_to_i32, "s16-to-i32", S16, I32);
|
||||
lowering_lifting!(u16_to_i32, "u16-to-i32", U16, I32);
|
||||
lowering_lifting!(s32_to_i32, "s32-to-i32", S32, I32);
|
||||
lowering_lifting!(u32_to_i32, "u32-to-i32", U32, I32);
|
||||
lowering_lifting!(s64_to_i32, "s64-to-i32", S64, I32);
|
||||
lowering_lifting!(u64_to_i32, "u64-to-i32", U64, I32);
|
||||
lowering_lifting!(s8_to_i64, "s8-to-i64", S8, I64);
|
||||
lowering_lifting!(u8_to_i64, "u8-to-i64", U8, I64);
|
||||
lowering_lifting!(s16_to_i64, "s16-to-i64", S16, I64);
|
||||
lowering_lifting!(u16_to_i64, "u16-to-i64", U16, I64);
|
||||
lowering_lifting!(s32_to_i64, "s32-to-i64", S32, I64);
|
||||
lowering_lifting!(u32_to_i64, "u32-to-i64", U32, I64);
|
||||
lowering_lifting!(s64_to_i64, "s64-to-i64", S64, I64);
|
||||
lowering_lifting!(u64_to_i64, "u64-to-i64", U64, I64);
|
||||
lowering_lifting!(s8_from_i32, "s8.from_i32", S8, I32);
|
||||
lowering_lifting!(s8_from_i64, "s8.from_i64", S8, I64);
|
||||
lowering_lifting!(s16_from_i32, "s16.from_i32", S16, I32);
|
||||
lowering_lifting!(s16_from_i64, "s16.from_i64", S16, I64);
|
||||
lowering_lifting!(s32_from_i32, "s32.from_i32", S32, I32);
|
||||
lowering_lifting!(s32_from_i64, "s32.from_i64", S32, I64);
|
||||
lowering_lifting!(s64_from_i32, "s64.from_i32", S64, I32);
|
||||
lowering_lifting!(s64_from_i64, "s64.from_i64", S64, I64);
|
||||
lowering_lifting!(i32_from_s8, "i32.from_s8", I32, S8);
|
||||
lowering_lifting!(i32_from_s16, "i32.from_s16", I32, S16);
|
||||
lowering_lifting!(i32_from_s32, "i32.from_s32", I32, S32);
|
||||
lowering_lifting!(i32_from_s64, "i32.from_s64", I32, S64);
|
||||
lowering_lifting!(i64_from_s8, "i64.from_s8", I64, S8);
|
||||
lowering_lifting!(i64_from_s16, "i64.from_s16", I64, S16);
|
||||
lowering_lifting!(i64_from_s32, "i64.from_s32", I64, S32);
|
||||
lowering_lifting!(i64_from_s64, "i64.from_s64", I64, S64);
|
||||
lowering_lifting!(u8_from_i32, "u8.from_i32", U8, I32);
|
||||
lowering_lifting!(u8_from_i64, "u8.from_i64", U8, I64);
|
||||
lowering_lifting!(u16_from_i32, "u16.from_i32", U16, I32);
|
||||
lowering_lifting!(u16_from_i64, "u16.from_i64", U16, I64);
|
||||
lowering_lifting!(u32_from_i32, "u32.from_i32", U32, I32);
|
||||
lowering_lifting!(u32_from_i64, "u32.from_i64", U32, I64);
|
||||
lowering_lifting!(u64_from_i32, "u64.from_i32", U64, I32);
|
||||
lowering_lifting!(u64_from_i64, "u64.from_i64", U64, I64);
|
||||
lowering_lifting!(i32_from_u8, "i32.from_u8", I32, U8);
|
||||
lowering_lifting!(i32_from_u16, "i32.from_u16", I32, U16);
|
||||
lowering_lifting!(i32_from_u32, "i32.from_u32", I32, U32);
|
||||
lowering_lifting!(i32_from_u64, "i32.from_u64", I32, U64);
|
||||
lowering_lifting!(i64_from_u8, "i64.from_u8", I64, U8);
|
||||
lowering_lifting!(i64_from_u16, "i64.from_u16", I64, U16);
|
||||
lowering_lifting!(i64_from_u32, "i64.from_u32", I64, U32);
|
||||
lowering_lifting!(i64_from_u64, "i64.from_u64", I64, U64);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
test_executable_instruction!(
|
||||
test_i32_to_s8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToS8],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S8(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_convert_fails =
|
||||
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8],
|
||||
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::S8FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(128)],
|
||||
instance: Instance::new(),
|
||||
error: "`i32-to-s8` failed to cast `I32` to `S8`"
|
||||
error: "`s8.from_i32` failed to cast `I32` to `S8`"
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_type_mismatch =
|
||||
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::I32ToS8],
|
||||
instructions: [Instruction::ArgumentGet { index: 0}, Instruction::S8FromI32],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
error: "`i32-to-s8` read a value of type `I64` from the stack, but the type `I32` was expected"
|
||||
error: "`s8.from_i32` read a value of type `I64` from the stack, but the type `I32` was expected"
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_no_value_on_the_stack =
|
||||
instructions: [Instruction::I32ToS8],
|
||||
instructions: [Instruction::S8FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
error: "`i32-to-s8` needed to read `1` value(s) from the stack, but it doesn't contain enough data"
|
||||
error: "`s8.from_i32` needed to read `1` value(s) from the stack, but it doesn't contain enough data"
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_u8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToU8],
|
||||
test_s8_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S8FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U8(42)],
|
||||
stack: [InterfaceValue::S8(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_s16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToS16],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S16(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_u16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToU16],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U16(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_s32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToS32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_u32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToU32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_s64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToS64],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_to_u64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32ToU64],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_s8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToS8],
|
||||
test_s8_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S8FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S8(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_u8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToU8],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
test_s16_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S16FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U8(42)],
|
||||
stack: [InterfaceValue::S16(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_s16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToS16],
|
||||
test_s16_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S16FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S16(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_u16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToU16],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
test_s32_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S32FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U16(42)],
|
||||
stack: [InterfaceValue::S32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_s32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToS32],
|
||||
test_s32_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S32FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_u32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToU32],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
test_s64_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S64FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U32(42)],
|
||||
stack: [InterfaceValue::S64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_s64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToS64],
|
||||
test_s64_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S64FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::S64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_to_u64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64ToU64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s8_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S8ToI32],
|
||||
test_i32_from_s8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromS8],
|
||||
invocation_inputs: [InterfaceValue::S8(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u8_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U8ToI32],
|
||||
invocation_inputs: [InterfaceValue::U8(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s16_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S16ToI32],
|
||||
test_i32_from_s16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromS16],
|
||||
invocation_inputs: [InterfaceValue::S16(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u16_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U16ToI32],
|
||||
invocation_inputs: [InterfaceValue::U16(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s32_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S32ToI32],
|
||||
test_i32_from_s32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromS32],
|
||||
invocation_inputs: [InterfaceValue::S32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u32_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U32ToI32],
|
||||
invocation_inputs: [InterfaceValue::U32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s64_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S64ToI32],
|
||||
test_i32_from_s64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromS64],
|
||||
invocation_inputs: [InterfaceValue::S64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u64_to_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U64ToI32],
|
||||
test_i64_from_s8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromS8],
|
||||
invocation_inputs: [InterfaceValue::S8(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_from_s16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromS16],
|
||||
invocation_inputs: [InterfaceValue::S16(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_from_s32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromS32],
|
||||
invocation_inputs: [InterfaceValue::S32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i64_from_s64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromS64],
|
||||
invocation_inputs: [InterfaceValue::S64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u8_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U8FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U8(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u8_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U8FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U8(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u16_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U16FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U16(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u16_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U16FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U16(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u32_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U32FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u32_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U32FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u64_from_i32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U64FromI32],
|
||||
invocation_inputs: [InterfaceValue::I32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u64_from_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U64FromI64],
|
||||
invocation_inputs: [InterfaceValue::I64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::U64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_from_u8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromU8],
|
||||
invocation_inputs: [InterfaceValue::U8(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_from_u16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromU16],
|
||||
invocation_inputs: [InterfaceValue::U16(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_from_u32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromU32],
|
||||
invocation_inputs: [InterfaceValue::U32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_i32_from_u64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I32FromU64],
|
||||
invocation_inputs: [InterfaceValue::U64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I32(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s8_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S8ToI64],
|
||||
invocation_inputs: [InterfaceValue::S8(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u8_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U8ToI64],
|
||||
test_i64_from_u8 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromU8],
|
||||
invocation_inputs: [InterfaceValue::U8(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s16_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S16ToI64],
|
||||
invocation_inputs: [InterfaceValue::S16(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u16_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U16ToI64],
|
||||
test_i64_from_u16 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromU16],
|
||||
invocation_inputs: [InterfaceValue::U16(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s32_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S32ToI64],
|
||||
invocation_inputs: [InterfaceValue::S32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u32_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U32ToI64],
|
||||
test_i64_from_u32 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromU32],
|
||||
invocation_inputs: [InterfaceValue::U32(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_s64_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::S64ToI64],
|
||||
invocation_inputs: [InterfaceValue::S64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
);
|
||||
|
||||
test_executable_instruction!(
|
||||
test_u64_to_i64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::U64ToI64],
|
||||
test_i64_from_u64 =
|
||||
instructions: [Instruction::ArgumentGet { index: 0 }, Instruction::I64FromU64],
|
||||
invocation_inputs: [InterfaceValue::U64(42)],
|
||||
instance: Instance::new(),
|
||||
stack: [InterfaceValue::I64(42)],
|
||||
|
@ -188,60 +188,51 @@ where
|
||||
fn try_from(instructions: &Vec<Instruction>) -> Result<Self, Self::Error> {
|
||||
let executable_instructions = instructions
|
||||
.iter()
|
||||
.map(|instruction| {
|
||||
match instruction {
|
||||
Instruction::ArgumentGet { index } => {
|
||||
instructions::argument_get(*index, *instruction)
|
||||
}
|
||||
Instruction::CallCore { function_index } => {
|
||||
instructions::call_core(*function_index, *instruction)
|
||||
}
|
||||
Instruction::MemoryToString => instructions::memory_to_string(*instruction),
|
||||
Instruction::StringToMemory { allocator_index } => {
|
||||
instructions::string_to_memory(*allocator_index, *instruction)
|
||||
}
|
||||
.map(|instruction| match instruction {
|
||||
Instruction::ArgumentGet { index } => {
|
||||
instructions::argument_get(*index, *instruction)
|
||||
}
|
||||
|
||||
Instruction::I32ToS8 => instructions::i32_to_s8(*instruction),
|
||||
//Instruction::I32ToS8X
|
||||
Instruction::I32ToU8 => instructions::i32_to_u8(*instruction),
|
||||
Instruction::I32ToS16 => instructions::i32_to_s16(*instruction),
|
||||
//Instruction::I32ToS16X
|
||||
Instruction::I32ToU16 => instructions::i32_to_u16(*instruction),
|
||||
Instruction::I32ToS32 => instructions::i32_to_s32(*instruction),
|
||||
Instruction::I32ToU32 => instructions::i32_to_u32(*instruction),
|
||||
Instruction::I32ToS64 => instructions::i32_to_s64(*instruction),
|
||||
Instruction::I32ToU64 => instructions::i32_to_u64(*instruction),
|
||||
Instruction::I64ToS8 => instructions::i64_to_s8(*instruction),
|
||||
//Instruction::I64ToS8X
|
||||
Instruction::I64ToU8 => instructions::i64_to_u8(*instruction),
|
||||
Instruction::I64ToS16 => instructions::i64_to_s16(*instruction),
|
||||
//Instruction::I64ToS16X
|
||||
Instruction::I64ToU16 => instructions::i64_to_u16(*instruction),
|
||||
Instruction::I64ToS32 => instructions::i64_to_s32(*instruction),
|
||||
Instruction::I64ToU32 => instructions::i64_to_u32(*instruction),
|
||||
Instruction::I64ToS64 => instructions::i64_to_s64(*instruction),
|
||||
Instruction::I64ToU64 => instructions::i64_to_u64(*instruction),
|
||||
Instruction::S8ToI32 => instructions::s8_to_i32(*instruction),
|
||||
Instruction::U8ToI32 => instructions::u8_to_i32(*instruction),
|
||||
Instruction::S16ToI32 => instructions::s16_to_i32(*instruction),
|
||||
Instruction::U16ToI32 => instructions::u16_to_i32(*instruction),
|
||||
Instruction::S32ToI32 => instructions::s32_to_i32(*instruction),
|
||||
Instruction::U32ToI32 => instructions::u32_to_i32(*instruction),
|
||||
Instruction::S64ToI32 | Instruction::S64ToI32X => {
|
||||
instructions::s64_to_i32(*instruction)
|
||||
}
|
||||
Instruction::U64ToI32 | Instruction::U64ToI32X => {
|
||||
instructions::u64_to_i32(*instruction)
|
||||
}
|
||||
Instruction::S8ToI64 => instructions::s8_to_i64(*instruction),
|
||||
Instruction::U8ToI64 => instructions::u8_to_i64(*instruction),
|
||||
Instruction::S16ToI64 => instructions::s16_to_i64(*instruction),
|
||||
Instruction::U16ToI64 => instructions::u16_to_i64(*instruction),
|
||||
Instruction::S32ToI64 => instructions::s32_to_i64(*instruction),
|
||||
Instruction::U32ToI64 => instructions::u32_to_i64(*instruction),
|
||||
Instruction::S64ToI64 => instructions::s64_to_i64(*instruction),
|
||||
Instruction::U64ToI64 => instructions::u64_to_i64(*instruction),
|
||||
_ => unimplemented!(),
|
||||
Instruction::CallCore { function_index } => {
|
||||
instructions::call_core(*function_index, *instruction)
|
||||
}
|
||||
|
||||
Instruction::S8FromI32 => instructions::s8_from_i32(*instruction),
|
||||
Instruction::S8FromI64 => instructions::s8_from_i64(*instruction),
|
||||
Instruction::S16FromI32 => instructions::s16_from_i32(*instruction),
|
||||
Instruction::S16FromI64 => instructions::s16_from_i64(*instruction),
|
||||
Instruction::S32FromI32 => instructions::s32_from_i32(*instruction),
|
||||
Instruction::S32FromI64 => instructions::s32_from_i64(*instruction),
|
||||
Instruction::S64FromI32 => instructions::s64_from_i32(*instruction),
|
||||
Instruction::S64FromI64 => instructions::s64_from_i64(*instruction),
|
||||
Instruction::I32FromS8 => instructions::i32_from_s8(*instruction),
|
||||
Instruction::I32FromS16 => instructions::i32_from_s16(*instruction),
|
||||
Instruction::I32FromS32 => instructions::i32_from_s32(*instruction),
|
||||
Instruction::I32FromS64 => instructions::i32_from_s64(*instruction),
|
||||
Instruction::I64FromS8 => instructions::i64_from_s8(*instruction),
|
||||
Instruction::I64FromS16 => instructions::i64_from_s16(*instruction),
|
||||
Instruction::I64FromS32 => instructions::i64_from_s32(*instruction),
|
||||
Instruction::I64FromS64 => instructions::i64_from_s64(*instruction),
|
||||
Instruction::U8FromI32 => instructions::u8_from_i32(*instruction),
|
||||
Instruction::U8FromI64 => instructions::u8_from_i64(*instruction),
|
||||
Instruction::U16FromI32 => instructions::u16_from_i32(*instruction),
|
||||
Instruction::U16FromI64 => instructions::u16_from_i64(*instruction),
|
||||
Instruction::U32FromI32 => instructions::u32_from_i32(*instruction),
|
||||
Instruction::U32FromI64 => instructions::u32_from_i64(*instruction),
|
||||
Instruction::U64FromI32 => instructions::u64_from_i32(*instruction),
|
||||
Instruction::U64FromI64 => instructions::u64_from_i64(*instruction),
|
||||
Instruction::I32FromU8 => instructions::i32_from_u8(*instruction),
|
||||
Instruction::I32FromU16 => instructions::i32_from_u16(*instruction),
|
||||
Instruction::I32FromU32 => instructions::i32_from_u32(*instruction),
|
||||
Instruction::I32FromU64 => instructions::i32_from_u64(*instruction),
|
||||
Instruction::I64FromU8 => instructions::i64_from_u8(*instruction),
|
||||
Instruction::I64FromU16 => instructions::i64_from_u16(*instruction),
|
||||
Instruction::I64FromU32 => instructions::i64_from_u32(*instruction),
|
||||
Instruction::I64FromU64 => instructions::i64_from_u64(*instruction),
|
||||
|
||||
Instruction::MemoryToString => instructions::memory_to_string(*instruction),
|
||||
Instruction::StringToMemory { allocator_index } => {
|
||||
instructions::string_to_memory(*allocator_index, *instruction)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
Loading…
Reference in New Issue
Block a user