From 1ea88fcb6587c110acd8c798a5c198b492e04bad Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 1 Sep 2022 19:07:44 +0300 Subject: feat(tvix/eval): track source spans for scopes Change-Id: Iaedb0742940e4c2b9f4210579ed28e6deb32d5c8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6401 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/compiler/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 92507b5703..09123d3a99 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -755,7 +755,7 @@ impl Compiler<'_> { // Deal with the body, then clean up the locals afterwards. self.compile(slot, node.body().unwrap()); - self.end_scope(); + self.end_scope(&node); } fn compile_ident(&mut self, slot: Option, node: ast::Ident) { @@ -849,7 +849,7 @@ impl Compiler<'_> { self.push_op(OpCode::OpPopWith, &node); self.scope_mut().pop_with(); - self.end_scope(); + self.end_scope(&node); } fn compile_lambda(&mut self, slot: Option, node: ast::Lambda) { @@ -876,7 +876,7 @@ impl Compiler<'_> { } self.compile(slot, node.body().unwrap()); - self.end_scope(); + self.end_scope(&node); // TODO: determine and insert enclosing name, if available. @@ -932,7 +932,7 @@ impl Compiler<'_> { self.contexts.push(LambdaCtx::new()); self.begin_scope(); content(self, node, slot); - self.end_scope(); + self.end_scope(node); let thunk = self.contexts.pop().unwrap(); @@ -1032,7 +1032,7 @@ impl Compiler<'_> { self.scope_mut().scope_depth += 1; } - fn end_scope(&mut self) { + fn end_scope(&mut self, node: &N) { debug_assert!(self.scope().scope_depth != 0, "can not end top scope"); // If this scope poisoned any builtins or special identifiers, @@ -1071,7 +1071,7 @@ impl Compiler<'_> { } if pops > 0 { - self.push_op_old(OpCode::OpCloseScope(Count(pops))); + self.push_op(OpCode::OpCloseScope(Count(pops)), node); } } -- cgit 1.4.1