refactor(tvix/eval): add opcode::StackIdx type for less ambiguity

Change-Id: I9b9de1f681972c205d4d20bc5731d2ce79858edb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6287
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-08-26 20:54:39 +03:00 committed by tazjin
parent 2cdc6192b4
commit c73e84d957
3 changed files with 14 additions and 9 deletions

View file

@ -6,7 +6,7 @@ use std::rc::Rc;
use crate::{
chunk::Chunk,
errors::{ErrorKind, EvalResult},
opcode::{JumpOffset, OpCode},
opcode::{JumpOffset, OpCode, StackIdx},
value::{Closure, Lambda, NixAttrs, NixList, Value},
};
@ -318,13 +318,13 @@ impl VM {
}
}
OpCode::OpGetLocal(local_idx) => {
OpCode::OpGetLocal(StackIdx(local_idx)) => {
let idx = self.frame().stack_offset + local_idx;
let value = self.stack[idx].clone();
self.push(value)
}
OpCode::OpPushWith(idx) => self.with_stack.push(idx),
OpCode::OpPushWith(StackIdx(idx)) => self.with_stack.push(idx),
OpCode::OpPopWith => {
self.with_stack.pop();
}