about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-01T14·47+0300
committertazjin <tazjin@tvl.su>2022-09-07T19·23+0000
commit9f5f85a1c1fe98e83fa57d58511675818cdb1871 (patch)
treee33c61dddbdbb6e3dbc6e6b90e4fbf34dd390431 /tvix/eval/src
parentf37e4a0b9c285f89284059ddcda086b4d7a056ff (diff)
feat(tvix/eval): track source spans for identifier access r/4727
Change-Id: I8e6ec0a84430d6e417fc7fd3e722a588913e4d18
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6394
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/compiler/mod.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 21b236761663..fa4c56d493c5 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -772,7 +772,7 @@ impl Compiler<'_> {
             LocalPosition::Unknown => {
                 // Are we possibly dealing with an upvalue?
                 if let Some(idx) = self.resolve_upvalue(self.contexts.len() - 1, ident.text()) {
-                    self.push_op_old(OpCode::OpGetUpvalue(idx));
+                    self.push_op(OpCode::OpGetUpvalue(idx), &node);
                     return;
                 }
 
@@ -784,12 +784,12 @@ impl Compiler<'_> {
                     // `with`-stack. This means we need to resolve
                     // both in this scope, and in the upvalues.
                     if self.scope().has_with() {
-                        self.emit_constant_old(Value::String(ident.text().into()));
-                        self.push_op_old(OpCode::OpResolveWithOrUpvalue(idx));
+                        self.emit_literal_ident(&node);
+                        self.push_op(OpCode::OpResolveWithOrUpvalue(idx), &node);
                         return;
                     }
 
-                    self.push_op_old(OpCode::OpGetUpvalue(idx));
+                    self.push_op(OpCode::OpGetUpvalue(idx), &node);
                     return;
                 }
 
@@ -800,13 +800,13 @@ impl Compiler<'_> {
 
                 // Variable needs to be dynamically resolved at
                 // runtime.
-                self.emit_constant_old(Value::String(ident.text().into()));
-                self.push_op_old(OpCode::OpResolveWith);
+                self.emit_literal_ident(&node);
+                self.push_op(OpCode::OpResolveWith, &node);
             }
 
             LocalPosition::Known(idx) => {
                 let stack_idx = self.scope().stack_index(idx);
-                self.push_op_old(OpCode::OpGetLocal(stack_idx));
+                self.push_op(OpCode::OpGetLocal(stack_idx), &node);
             }
 
             // This identifier is referring to a value from the same
@@ -815,9 +815,7 @@ impl Compiler<'_> {
             LocalPosition::Recursive(idx) => self.thunk(slot, move |compiler, _| {
                 let upvalue_idx =
                     compiler.add_upvalue(compiler.contexts.len() - 1, Upvalue::Local(idx));
-                compiler
-                    .chunk()
-                    .push_op_old(OpCode::OpGetUpvalue(upvalue_idx));
+                compiler.push_op(OpCode::OpGetUpvalue(upvalue_idx), &node);
             }),
         };
     }