about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/scope.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-01T15·02+0300
committertazjin <tazjin@tvl.su>2022-09-07T20·04+0000
commit3efed26940cf24676e6de9b329d24b2a555f2330 (patch)
treeaabb2ad78a89f2d2569574b797e0f34eddf95d00 /tvix/eval/src/compiler/scope.rs
parentb8874f8d352f1f255a9eed0fdadc31d45de85e46 (diff)
refactor(tvix/eval): split out Upvalue struct & UpvalueKind enum r/4732
This separation makes it possible to annotate the upvalue itself with
the span that created it, which (due to upvalue reuse) is only the
first one for an instance of the given UpvalueKind.

Change-Id: I9a991da6a3e8d71a92f981314bed900bcf434d44
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6399
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r--tvix/eval/src/compiler/scope.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/tvix/eval/src/compiler/scope.rs b/tvix/eval/src/compiler/scope.rs
index 87b43ad1ca..01e0801e65 100644
--- a/tvix/eval/src/compiler/scope.rs
+++ b/tvix/eval/src/compiler/scope.rs
@@ -72,7 +72,7 @@ pub enum LocalPosition {
 /// Represents the different ways in which upvalues can be captured in
 /// closures or thunks.
 #[derive(Clone, Debug, PartialEq, Eq)]
-pub enum Upvalue {
+pub enum UpvalueKind {
     /// This upvalue captures a local from the stack.
     Local(LocalIdx),
 
@@ -91,6 +91,11 @@ pub enum Upvalue {
     },
 }
 
+#[derive(Clone, Debug)]
+pub struct Upvalue {
+    pub kind: UpvalueKind,
+}
+
 /// Represents the index of a local in the scope's local array, which
 /// is subtly different from its `StackIdx` (which excludes
 /// uninitialised values in between).