feat(tazjin/rlox): Support local variables
WIP Change-Id: I78fbc885faaac165c380cbd9aa98b4b64a9b8274 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3685 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
ad7e591c80
commit
c318f42c11
6 changed files with 193 additions and 12 deletions
|
|
@ -194,6 +194,16 @@ impl VM {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
OpCode::OpGetLocal(local_idx) => {
|
||||
let value = self.stack[*local_idx].clone();
|
||||
self.push(value);
|
||||
}
|
||||
|
||||
OpCode::OpSetLocal(local_idx) => {
|
||||
debug_assert!(self.stack.len() > *local_idx, "stack is not currently large enough for local");
|
||||
self.stack[*local_idx] = self.stack.last().unwrap().clone();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "disassemble")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue