mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-31 00:57:24 +00:00
wasm_interp: create execute
module
This commit is contained in:
parent
d038094a51
commit
2ca74e5070
4 changed files with 557 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue