refactor(tvix/eval): after calling, the caller has to pop

Previously the various call functions either returned `EvalResult<()>`
or `EvalResult<Value>`, which was confusing.

Now only vm::call_with returns a Value directly, and other parts of
the API just leave the stack top in the post-call state.

This makes it easier to reason about what's going on in non-tail-call
cases (which are making a comeback).

Change-Id: I264ffc683a11aca72dd06e2220a5ff6e7c5fc2b0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6936
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-10-11 02:14:47 +03:00 committed by tazjin
parent 0b04dfe03c
commit 1f84d90811
3 changed files with 29 additions and 21 deletions

View file

@ -163,7 +163,8 @@ impl Value {
let call_to_string = |value: &Value, vm: &mut VM| {
// Leave self on the stack as an argument to the function call.
vm.push(self.clone());
let result = vm.call_value(value)?;
vm.call_value(value)?;
let result = vm.pop();
match result {
Value::String(s) => Ok(s),