From c28ecbee970c0a16b7f93241a5a2ef2df49406c6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 13 Sep 2022 16:04:52 +0300 Subject: refactor(tvix/eval): encapsulate scope_depth in compiler::scope This field no longer needs to be directly accessible by the compiler. Addresses a sterni lint from cl/6466 Change-Id: I5e6791943d7f0ab3d9b7a30bb1654c4a6a435b1f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6564 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/compiler/scope.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/compiler/scope.rs') 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, /// 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 + } } -- cgit 1.4.1