refactor(tvix/eval): clone the Arc<codemap::File> for the compiler

This disconnects ownership of the `File` reference in a compiler from
the calling scope, which is required for when we implement `import`.

`import` will need to carry an `Rc<RefCell<CodeMap>>` (or maybe, in
the future, Arc) to give us the ability to add new detected code
files at runtime.

Note that the choice of `Arc` over `Rc` here is not ours - it's the
codemap crate's.

Change-Id: I3aeca4ffc167acbd1701846a332d93550b56ba7d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6630
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-09-18 02:52:23 +03:00 committed by tazjin
parent 5dd5c7e254
commit 0e5baae7ad
5 changed files with 12 additions and 11 deletions

View file

@ -77,8 +77,8 @@ expr_to_span!(ast::Str);
expr_to_span!(ast::UnaryOp);
expr_to_span!(ast::With);
impl Compiler<'_, '_> {
impl Compiler<'_> {
pub(super) fn span_for<S: ToSpan>(&self, to_span: &S) -> Span {
to_span.span_for(self.file)
to_span.span_for(&self.file)
}
}