diff options
Diffstat (limited to 'tvix/eval/src/compiler/scope.rs')
-rw-r--r-- | tvix/eval/src/compiler/scope.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tvix/eval/src/compiler/scope.rs b/tvix/eval/src/compiler/scope.rs index 1909a8dc8a76..29947ea4a208 100644 --- a/tvix/eval/src/compiler/scope.rs +++ b/tvix/eval/src/compiler/scope.rs @@ -123,7 +123,7 @@ pub struct Scope { pub upvalues: Vec<Upvalue>, /// How many scopes "deep" are these locals? - pub scope_depth: usize, + scope_depth: usize, /// Current size of the `with`-stack at runtime. with_stack_size: usize, @@ -272,6 +272,12 @@ impl Scope { StackIdx(idx.0 - uninitialised_count) } + /// Increase the current scope depth (e.g. within a new bindings + /// block, or `with`-scope). + pub fn begin_scope(&mut self) { + self.scope_depth += 1; + } + /// Decrease the scope depth and remove all locals still tracked /// for the current scope. /// @@ -314,4 +320,9 @@ impl Scope { (pops, unused_spans) } + + /// Access the current scope depth. + pub fn scope_depth(&self) -> usize { + self.scope_depth + } } |