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 <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
parent
268605140e
commit
c28ecbee97
3 changed files with 20 additions and 15 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue