refactor(tvix/eval): thread dynamic upvalues through all contexts
With this change, encountering a dynamic upvalue will thread through all contexts starting from the lowest context that has a non-empty `with`-stack. The additional upvalues are not actually used yet, so the effective behaviour remains mostly the same. This is done in preparation for an upcoming change, which will implement proper dynamic resolution for complex cases of nested dynamic upvalues. Yes, this whole upvalue + dynamic values thing is a little bit mind-bending, but we would like to not give up being able to resolve a large chunk of the scoping behaviour statically. Change-Id: Ia58cdd47d79212390a6503ef13cef46b6b3e19a2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6321 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
f6de4434c3
commit
8982e16e26
2 changed files with 65 additions and 9 deletions
|
|
@ -81,7 +81,7 @@ pub enum LocalPosition {
|
|||
|
||||
/// Represents the different ways in which upvalues can be captured in
|
||||
/// closures or thunks.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Upvalue {
|
||||
/// This upvalue captures a local from the stack.
|
||||
Stack(StackIdx),
|
||||
|
|
@ -91,7 +91,14 @@ pub enum Upvalue {
|
|||
|
||||
/// This upvalue captures a dynamically resolved value (i.e.
|
||||
/// `with`).
|
||||
Dynamic(SmolStr),
|
||||
///
|
||||
/// It stores the identifier with which to perform a dynamic
|
||||
/// lookup, as well as the optional upvalue index in the enclosing
|
||||
/// function (if any).
|
||||
Dynamic {
|
||||
name: SmolStr,
|
||||
up: Option<UpvalueIdx>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Represents a scope known during compilation, which can be resolved
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue