about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/mod.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-06T11·33+0300
committertazjin <tazjin@tvl.su>2022-10-08T10·58+0000
commit50baf0bcfc5ce29f7eed114535e7bb27ffd06cb6 (patch)
treed23430409970fbf3cb3e323986093e3394db216d /tvix/eval/src/compiler/mod.rs
parentf3c089ae3e10c22f849e4970e5e3bde0b6ce291f (diff)
refactor(tvix/eval): move `spans` module to crate root r/5057
This is also useful for error-handling related logic, outside of just
the compiler module.

Change-Id: I5c386e2b4c31cda0a0209b31136ca07f00e39e45
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6869
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/compiler/mod.rs')
-rw-r--r--tvix/eval/src/compiler/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 472f4aaf363d..1463bb100eae 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -15,7 +15,6 @@
 
 mod bindings;
 mod scope;
-mod spans;
 
 use codemap::Span;
 use path_clean::PathClean;
@@ -31,11 +30,11 @@ use crate::chunk::Chunk;
 use crate::errors::{Error, ErrorKind, EvalResult};
 use crate::observer::CompilerObserver;
 use crate::opcode::{CodeIdx, Count, JumpOffset, OpCode, UpvalueIdx};
+use crate::spans::ToSpan;
 use crate::value::{Closure, Lambda, Thunk, Value};
 use crate::warnings::{EvalWarning, WarningKind};
 
 use self::scope::{LocalIdx, LocalPosition, Scope, Upvalue, UpvalueKind};
-use self::spans::ToSpan;
 
 /// Represents the result of compiling a piece of Nix code. If
 /// compilation was successful, the resulting bytecode can be passed
@@ -99,6 +98,12 @@ struct Compiler<'observer> {
     observer: &'observer mut dyn CompilerObserver,
 }
 
+impl Compiler<'_> {
+    pub(super) fn span_for<S: ToSpan>(&self, to_span: &S) -> Span {
+        to_span.span_for(&self.file)
+    }
+}
+
 /// Compiler construction
 impl<'observer> Compiler<'observer> {
     pub(crate) fn new(