mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
wasm_interp: implement local.get, local.set, and local.tee
This commit is contained in:
parent
987fcf616e
commit
ff63831fd1
3 changed files with 83 additions and 11 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue