diff options
author | Vincent Ambo <mail@tazj.in> | 2022-12-12T14·38+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-12-21T22·37+0000 |
commit | c3c4d752c91f64eff8e7f7f7b21fbcc1209d27a6 (patch) | |
tree | 290dba7b8cf36dfbca53a499891dcddaf3cbe735 /tvix/eval/src/vm.rs | |
parent | 25fc6b7c25d75075461e7976b27b81ba6a8140fe (diff) |
feat(tvix/eval): add EvalIO to public crate API r/5459
This lets users set the `io_handle` field on an `Evaluation`, which is then propagated to the VM. Change-Id: I616d7140724fb2b4db47c2ebf95451d5303a487a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7566 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r-- | tvix/eval/src/vm.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 37d30a6c0178..baf594f9368c 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -7,6 +7,7 @@ use std::{cmp::Ordering, collections::BTreeMap, ops::DerefMut, path::PathBuf, rc use crate::{ chunk::Chunk, errors::{Error, ErrorKind, EvalResult}, + io::EvalIO, nix_search_path::NixSearchPath, observer::RuntimeObserver, opcode::{CodeIdx, Count, JumpOffset, OpCode, StackIdx, UpvalueIdx}, @@ -65,6 +66,8 @@ pub struct VM<'o> { nix_search_path: NixSearchPath, + io_handle: Box<dyn EvalIO>, + observer: &'o mut dyn RuntimeObserver, } @@ -150,7 +153,11 @@ macro_rules! cmp_op { } impl<'o> VM<'o> { - pub fn new(nix_search_path: NixSearchPath, observer: &'o mut dyn RuntimeObserver) -> Self { + pub fn new( + nix_search_path: NixSearchPath, + io_handle: Box<dyn EvalIO>, + observer: &'o mut dyn RuntimeObserver, + ) -> Self { // Backtrace-on-stack-overflow is some seriously weird voodoo and // very unsafe. This double-guard prevents it from accidentally // being enabled on release builds. @@ -162,6 +169,7 @@ impl<'o> VM<'o> { Self { nix_search_path, + io_handle, observer, frames: vec![], stack: vec![], @@ -1084,10 +1092,11 @@ impl<'o> VM<'o> { pub fn run_lambda( nix_search_path: NixSearchPath, + io_handle: Box<dyn EvalIO>, observer: &mut dyn RuntimeObserver, lambda: Rc<Lambda>, ) -> EvalResult<RuntimeResult> { - let mut vm = VM::new(nix_search_path, observer); + let mut vm = VM::new(nix_search_path, io_handle, observer); // Retain the top-level span of the expression in this lambda, as // synthetic "calls" in deep_force will otherwise not have a span |