wasm_interp: create execute module

This commit is contained in:
Brian Carroll 2022-11-21 08:28:39 +00:00
parent d038094a51
commit 2ca74e5070
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
4 changed files with 557 additions and 2 deletions

View file

@ -183,6 +183,12 @@ pub enum OpCode {
F64REINTERPRETI64 = 0xbf,
}
impl From<u8> for OpCode {
fn from(x: u8) -> Self {
unsafe { std::mem::transmute(x) }
}
}
/// The format of the *immediate* operands of an operator
/// Immediates appear directly in the byte stream after the opcode,
/// rather than being popped off the value stack. These are the possible forms.
@ -264,7 +270,7 @@ impl SkipBytes for OpCode {
let opcode_byte: u8 = bytes[*cursor];
let opcode: OpCode = unsafe { std::mem::transmute(opcode_byte) };
let opcode: OpCode = OpCode::from(opcode_byte);
// will return Err if transmute was invalid
let immediates = immediates_for(opcode).map_err(|message| ParseError {
message,