feat(interface-types) Implement the string.(lift|lower)_memory instructions.

The `string.lift_memory` instruction replaces `memory-to-string`, and
`string.lower_memory` replaces `string-to-memory`.
This commit is contained in:
Ivan Enderlin
2020-03-24 13:25:06 +01:00
parent 0506449aa4
commit 7a2db276f3
10 changed files with 371 additions and 381 deletions

View File

@ -293,9 +293,9 @@ where
Instruction::I64FromU32 => 0x20_u8.to_bytes(writer)?,
Instruction::I64FromU64 => 0x21_u8.to_bytes(writer)?,
Instruction::MemoryToString => 0x22_u8.to_bytes(writer)?,
Instruction::StringLiftMemory => 0x22_u8.to_bytes(writer)?,
Instruction::StringToMemory { allocator_index } => {
Instruction::StringLowerMemory { allocator_index } => {
0x23_u8.to_bytes(writer)?;
(*allocator_index as u64).to_bytes(writer)?;
}
@ -575,8 +575,8 @@ mod tests {
Instruction::I64FromU16,
Instruction::I64FromU32,
Instruction::I64FromU64,
Instruction::MemoryToString,
Instruction::StringToMemory { allocator_index: 1 },
Instruction::StringLiftMemory,
Instruction::StringLowerMemory { allocator_index: 1 },
],
&[
0x24, // list of 36 items
@ -614,8 +614,8 @@ mod tests {
0x1f, // I64FromU16
0x20, // I64FromU32
0x21, // I64FromU64
0x22, // MemoryToString
0x23, 0x01, // StringToMemory { allocator_index: 1 }
0x22, // StringLiftMemory
0x23, 0x01, // StringLowerMemory { allocator_index: 1 }
]
);
}