mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
refactor
This commit is contained in:
parent
d3f00c8c6d
commit
be6006bbab
1 changed files with 6 additions and 14 deletions
|
@ -363,12 +363,16 @@ impl Scope {
|
|||
// - exposed_ident_count: unchanged
|
||||
// - home: unchanged
|
||||
let aliases_count = self.aliases.len();
|
||||
let locals_snapshot = self.locals.snapshot();
|
||||
let locals_snapshot = self.locals.in_scope.len();
|
||||
|
||||
let result = f(self);
|
||||
|
||||
self.aliases.truncate(aliases_count);
|
||||
self.locals.revert(locals_snapshot);
|
||||
|
||||
// anything added in the inner scope is no longer in scope now
|
||||
for i in locals_snapshot..self.locals.in_scope.len() {
|
||||
self.locals.in_scope.set(i, false);
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
@ -459,18 +463,6 @@ impl ScopedIdentIds {
|
|||
}
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> usize {
|
||||
debug_assert_eq!(self.ident_ids.len(), self.in_scope.len());
|
||||
|
||||
self.ident_ids.len()
|
||||
}
|
||||
|
||||
fn revert(&mut self, snapshot: usize) {
|
||||
for i in snapshot..self.in_scope.len() {
|
||||
self.in_scope.set(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
fn has_in_scope(&self, ident: &Ident) -> Option<(Symbol, Region)> {
|
||||
match self.contains_ident(ident.as_str()) {
|
||||
ContainsIdent::InScope(symbol, region) => Some((symbol, region)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue