wasm_interp: implement store instructions

This commit is contained in:
Brian Carroll 2022-11-25 15:36:40 +00:00
parent d9a8c6f64c
commit 598e62275d
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
2 changed files with 108 additions and 23 deletions

View file

@ -679,6 +679,33 @@ pub enum Value {
F64(f64),
}
impl Value {
pub fn unwrap_i32(&self) -> i32 {
match self {
Value::I32(x) => *x,
_ => panic!("Expected I32 but found {:?}", self),
}
}
pub fn unwrap_i64(&self) -> i64 {
match self {
Value::I64(x) => *x,
_ => panic!("Expected I64 but found {:?}", self),
}
}
pub fn unwrap_f32(&self) -> f32 {
match self {
Value::F32(x) => *x,
_ => panic!("Expected F32 but found {:?}", self),
}
}
pub fn unwrap_f64(&self) -> f64 {
match self {
Value::F64(x) => *x,
_ => panic!("Expected F64 but found {:?}", self),
}
}
}
/// 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