wasm_interp: implement local.get, local.set, and local.tee

This commit is contained in:
Brian Carroll 2022-11-21 23:29:08 +00:00
parent 987fcf616e
commit ff63831fd1
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
3 changed files with 83 additions and 11 deletions

View file

@ -34,6 +34,10 @@ impl<'a> ValueStack<'a> {
}
}
pub fn len(&self) -> usize {
self.is_64.len()
}
pub fn push(&mut self, value: Value) {
match value {
Value::I32(x) => {
@ -69,6 +73,14 @@ impl<'a> ValueStack<'a> {
value
}
pub fn peek(&self) -> Value {
let is_64 = self.is_64[self.is_64.len() - 1];
let is_float = self.is_float[self.is_float.len() - 1];
let size = if is_64 { 8 } else { 4 };
let bytes_idx = self.bytes.len() - size;
self.get(is_64, is_float, bytes_idx)
}
fn get(&self, is_64: bool, is_float: bool, bytes_idx: usize) -> Value {
if is_64 {
let mut b = [0; 8];