wasm: store Imports in deserialized form for easier manipulation

This commit is contained in:
Brian Carroll 2022-06-04 08:54:31 +02:00
parent 0900481ec8
commit b4e139a799
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
5 changed files with 144 additions and 66 deletions

View file

@ -47,6 +47,14 @@ impl Parse<()> for u32 {
}
}
impl Parse<()> for u8 {
fn parse(_ctx: (), bytes: &[u8], cursor: &mut usize) -> Result<Self, ParseError> {
let byte = bytes[*cursor];
*cursor += 1;
Ok(byte)
}
}
/// Decode a signed 32-bit integer from the provided buffer in LEB-128 format
/// Return the integer itself and the offset after it ends
fn decode_i32(bytes: &[u8]) -> Result<(i32, usize), ()> {