about summary refs log tree commit diff
path: root/tvix/eval/src/opcode.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-14T21·13+0300
committertazjin <tazjin@tvl.su>2022-08-31T22·26+0000
commit7cfdedfdfb6657a05ca8ce423874833eddb4ee72 (patch)
tree56927b3292c155ac91e75822476ee817d5a4a3fd /tvix/eval/src/opcode.rs
parentec7db0235ffb1bca006e21a2ae51bbfc29382132 (diff)
feat(tvix/eval): compile `with` expression r/4551
Adds an additional structure to the compiler's scope to track the
runtime "with stack", i.e. the stack of values through which
identifiers should be dynamically resolved within a with-scope.

When encountering a `with` expression, the value from which the
bindings should be resolved is pushed onto the stack and tracked by
the compiler in the "with stack", as well as with a "phantom value"
which indicates that the stack contains an additional slot which is
not available to users via identifiers.

Runtime handling of this is not yet implemented.

Change-Id: I5e96fb55b6378e8e2a59c20c8518caa6df83da1c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6217
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/opcode.rs')
-rw-r--r--tvix/eval/src/opcode.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/tvix/eval/src/opcode.rs b/tvix/eval/src/opcode.rs
index ce17dab63124..4a4d47045fbd 100644
--- a/tvix/eval/src/opcode.rs
+++ b/tvix/eval/src/opcode.rs
@@ -52,6 +52,9 @@ pub enum OpCode {
     OpAttrOrNotFound,
     OpAttrsIsSet,
 
+    // `with`-handling
+    OpPushWith(usize),
+
     // Lists
     OpList(usize),
     OpConcat,