diff options
author | Florian Klink <flokli@flokli.de> | 2023-12-30T20·36+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-12-31T13·15+0000 |
commit | 4fba57c2c90f2e7b02da9187e59f8d64deef3fb2 (patch) | |
tree | 9e29cd30ab4a9c060bc15550ddca400f6af03da4 /tvix/cli/src | |
parent | a5c5f1a29e8e9b39314a3ab024e170745ac96a3e (diff) |
refactor(tvix/eval): remove code and location from struct r/7289
Instead, it's passed in the evaluate/compile_only functions, which feels more naturally. It lets us set up the Evaluation struct long before we actually feed it with data to evaluate. Now that Evaluation::new() would be accepting an empty list of arguments, we can simply implement Default, making things a bit more idiomatic. Change-Id: I4369658634909a0c504fdffa18242a130daa0239 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10475 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/cli/src')
-rw-r--r-- | tvix/cli/src/main.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs index f1c7a735d1fd..149b08fa8e71 100644 --- a/tvix/cli/src/main.rs +++ b/tvix/cli/src/main.rs @@ -62,7 +62,7 @@ struct Args { /// and the result itself. The return value indicates whether /// evaluation succeeded. fn interpret(code: &str, path: Option<PathBuf>, args: &Args, explain: bool) -> bool { - let mut eval = tvix_eval::Evaluation::new_impure(code, path); + let mut eval = tvix_eval::Evaluation::new_impure(); eval.strict = args.strict; @@ -101,7 +101,7 @@ fn interpret(code: &str, path: Option<PathBuf>, args: &Args, explain: bool) -> b eval.runtime_observer = Some(&mut runtime_observer); } - eval.evaluate() + eval.evaluate(code, path) }; if args.display_ast { @@ -135,7 +135,7 @@ fn interpret(code: &str, path: Option<PathBuf>, args: &Args, explain: bool) -> b /// Interpret the given code snippet, but only run the Tvix compiler /// on it and return errors and warnings. fn lint(code: &str, path: Option<PathBuf>, args: &Args) -> bool { - let mut eval = tvix_eval::Evaluation::new_impure(code, path); + let mut eval = tvix_eval::Evaluation::new_impure(); eval.strict = args.strict; let source_map = eval.source_map(); @@ -150,7 +150,7 @@ fn lint(code: &str, path: Option<PathBuf>, args: &Args) -> bool { eprintln!("warning: --trace-runtime has no effect with --compile-only!"); } - let result = eval.compile_only(); + let result = eval.compile_only(code, path); if args.display_ast { if let Some(ref expr) = result.expr { |