feat(tvix/eval): compile simple let ... in ... expressions
These expressions now leave the binding values on the stack, and clean up the scope after the body of the expression. While variable access is not yet implemented (as the identifier node remains unhandled), this already gives us the correct stack behaviour. Change-Id: I138c20ace9c64502c94b2c0f99a6077cd912c00d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6188 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
bbad338017
commit
691a596aac
3 changed files with 98 additions and 0 deletions
|
|
@ -240,6 +240,20 @@ impl VM {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the given number of elements from the stack,
|
||||
// but retain the top value.
|
||||
OpCode::OpCloseScope(count) => {
|
||||
// Immediately move the top value into the right
|
||||
// position.
|
||||
let target_idx = self.stack.len() - 1 - count;
|
||||
self.stack[target_idx] = self.pop();
|
||||
|
||||
// Then drop the remaining values.
|
||||
for _ in 0..(count - 1) {
|
||||
self.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if self.ip == self.chunk.code.len() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue