about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-26T17·46+0300
committertazjin <tazjin@tvl.su>2022-09-03T13·22+0000
commit4f00f75e31afc6bb1f163aa67e4b1cb0cadb2e12 (patch)
treea1d3d6c69841191901290a03d1e3c91a315dabf3 /tvix/eval/src/vm.rs
parent3b64b7eb2ec178c11056d1e361def5b5b965ba43 (diff)
refactor(tvix/eval): add opcode::JumpOffset type for less ambiguity r/4619
This adds a transparent wrapper around `usize` used for jump offsets
in the opcodes. This is a step towards getting rid of ambiguous plain
`usize` usage in the opcode.

Change-Id: I21e35e67d94b32d68251908b96c7f62b6f56a8bb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6282
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 6de9cd03c49c..a74051a64975 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -6,7 +6,7 @@ use std::rc::Rc;
 use crate::{
     chunk::Chunk,
     errors::{ErrorKind, EvalResult},
-    opcode::OpCode,
+    opcode::{JumpOffset, OpCode},
     value::{Closure, Lambda, NixAttrs, NixList, Value},
 };
 
@@ -266,23 +266,23 @@ impl VM {
 
                 OpCode::OpInterpolate(count) => self.run_interpolate(count)?,
 
-                OpCode::OpJump(offset) => {
+                OpCode::OpJump(JumpOffset(offset)) => {
                     self.frame_mut().ip += offset;
                 }
 
-                OpCode::OpJumpIfTrue(offset) => {
+                OpCode::OpJumpIfTrue(JumpOffset(offset)) => {
                     if self.peek(0).as_bool()? {
                         self.frame_mut().ip += offset;
                     }
                 }
 
-                OpCode::OpJumpIfFalse(offset) => {
+                OpCode::OpJumpIfFalse(JumpOffset(offset)) => {
                     if !self.peek(0).as_bool()? {
                         self.frame_mut().ip += offset;
                     }
                 }
 
-                OpCode::OpJumpIfNotFound(offset) => {
+                OpCode::OpJumpIfNotFound(JumpOffset(offset)) => {
                     if matches!(self.peek(0), Value::AttrNotFound) {
                         self.pop();
                         self.frame_mut().ip += offset;