wasm_interp: implement call and return instructions

This commit is contained in:
Brian Carroll 2022-11-22 20:54:33 +00:00
parent 57aa3aafd8
commit 972d9dbb19
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
5 changed files with 75 additions and 32 deletions

View file

@ -642,6 +642,22 @@ impl From<u8> for ValueType {
}
}
impl Parse<()> for ValueType {
fn parse(_: (), bytes: &[u8], cursor: &mut usize) -> Result<Self, ParseError> {
let byte = u8::parse((), bytes, cursor)?;
Ok(ValueType::from(byte))
}
}
// A group of local variable declarations
impl Parse<()> for (u32, ValueType) {
fn parse(_: (), bytes: &[u8], cursor: &mut usize) -> Result<Self, ParseError> {
let count = u32::parse((), bytes, cursor)?;
let ty = ValueType::parse((), bytes, cursor)?;
Ok((count, ty))
}
}
/// Wasm memory alignment for load/store instructions.
/// Rust representation matches Wasm encoding.
/// It's an error to specify alignment higher than the "natural" alignment of the instruction