refactor(tazjin/rlox): Introduce newtypes for various indices
Since this code is essentially a fairly plain translation from C, it is a bit confusing to deal with the original untyped code. This is an attempt to try and clean some of it up. Change-Id: Icd21f531932e1a811c0d6dbf2e9acba61ca9c45d Reviewed-on: https://cl.tvl.fyi/c/depot/+/3734 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
e92a951f6c
commit
050a2b473c
4 changed files with 31 additions and 25 deletions
|
|
@ -196,13 +196,13 @@ impl VM {
|
|||
}
|
||||
|
||||
OpCode::OpGetLocal(local_idx) => {
|
||||
let value = self.stack[*local_idx].clone();
|
||||
let value = self.stack[local_idx.0].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();
|
||||
debug_assert!(self.stack.len() > local_idx.0, "stack is not currently large enough for local");
|
||||
self.stack[local_idx.0] = self.stack.last().unwrap().clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue