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-09-04T13·49+0300
committertazjin <tazjin@tvl.su>2022-09-09T21·10+0000
commit1fe6cfe5a279cd19dbb2586f30db6a8790db7a4d (patch)
tree36f23709803af2112a7bc5a205ce68bb44f33d49 /tvix/eval/src/vm.rs
parent8c64ebe074c9fc99c2174769f5e3c13755b82c55 (diff)
refactor(tvix/eval): index into Chunk with ConstantIdx/CodeIdx r/4773
This is a step towards hiding the internal fields of thunk, and making
the interface of the type more predictable.

Part of the preparation for implementing observers.

Change-Id: I1a88a96419c72eb9e2332b56a2dd94afa47e6f88
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6447
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index d42a2e303312..b9445e39f1b1 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -218,7 +218,7 @@ impl VM {
 
             match op {
                 OpCode::OpConstant(idx) => {
-                    let c = self.chunk().constant(idx).clone();
+                    let c = self.chunk()[idx].clone();
                     self.push(c);
                 }
 
@@ -477,7 +477,7 @@ impl VM {
                 }
 
                 OpCode::OpClosure(idx) => {
-                    let blueprint = match self.chunk().constant(idx) {
+                    let blueprint = match &self.chunk()[idx] {
                         Value::Blueprint(lambda) => lambda.clone(),
                         _ => panic!("compiler bug: non-blueprint in blueprint slot"),
                     };
@@ -501,7 +501,7 @@ impl VM {
                 }
 
                 OpCode::OpThunk(idx) => {
-                    let blueprint = match self.chunk().constant(idx) {
+                    let blueprint = match &self.chunk()[idx] {
                         Value::Blueprint(lambda) => lambda.clone(),
                         _ => panic!("compiler bug: non-blueprint in blueprint slot"),
                     };
@@ -594,7 +594,7 @@ impl VM {
 
     fn resolve_dynamic_upvalue(&mut self, ident_idx: ConstantIdx) -> EvalResult<Value> {
         let chunk = self.chunk();
-        let ident = fallible!(self, chunk.constant(ident_idx).to_str());
+        let ident = fallible!(self, chunk[ident_idx].to_str());
 
         // Peek at the current instruction (note: IP has already
         // advanced!) to see if it is actually data indicating a