feat(tvix/eval): resolve relative path literals
Resolves relative paths (e.g. `./foo`) either relative to the location of the Nix file, or relative to the working directory if none is supplied. Change-Id: I70ec574657b221b458015117a004b6e4a9c25a30 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6185 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
1f8aad0ab4
commit
6fe5e2d752
4 changed files with 37 additions and 10 deletions
|
|
@ -1,8 +1,10 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use rnix::{self, types::TypedNode};
|
||||
|
||||
use crate::{errors::EvalResult, value::Value};
|
||||
|
||||
pub fn interpret(code: &str) -> EvalResult<Value> {
|
||||
pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
|
||||
let ast = rnix::parse(code);
|
||||
|
||||
let errors = ast.errors();
|
||||
|
|
@ -14,7 +16,7 @@ pub fn interpret(code: &str) -> EvalResult<Value> {
|
|||
println!("{}", ast.root().dump());
|
||||
}
|
||||
|
||||
let result = crate::compiler::compile(ast)?;
|
||||
let result = crate::compiler::compile(ast, location)?;
|
||||
println!("code: {:?}", result.chunk);
|
||||
|
||||
for warning in result.warnings {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue