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

@ -45,7 +45,7 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
crate::compiler::compile(
root_expr,
location,
&file,
file.clone(),
global_builtins(),
&mut DisassemblingObserver::new(codemap.clone(), std::io::stderr()),
)
@ -53,7 +53,7 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
crate::compiler::compile(
root_expr,
location,
&file,
file.clone(),
global_builtins(),
&mut NoOpObserver::default(),
)