feat(tvix/eval): track source spans for identifier access
Change-Id: I8e6ec0a84430d6e417fc7fd3e722a588913e4d18 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6394 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
parent
f37e4a0b9c
commit
9f5f85a1c1
1 changed files with 8 additions and 10 deletions
|
@ -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);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue