From 6fe5e2d75257504f0321e2e98b6fb675b716fe25 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 12 Aug 2022 18:28:45 +0300 Subject: 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 --- tvix/eval/src/eval.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tvix/eval/src/eval.rs') diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs index 31280e4cd1..903708f108 100644 --- a/tvix/eval/src/eval.rs +++ b/tvix/eval/src/eval.rs @@ -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 { +pub fn interpret(code: &str, location: Option) -> EvalResult { let ast = rnix::parse(code); let errors = ast.errors(); @@ -14,7 +16,7 @@ pub fn interpret(code: &str) -> EvalResult { 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 { -- cgit 1.4.1