use super::ScopeVisitor;
impl ScopeVisitor<'_> {
pub(in crate::embedded::walk) fn enter_function(&mut self) {
self.member_query_proof.next_function_id += 1;
self.member_query_proof
.function_ids
.push(self.member_query_proof.next_function_id);
self.var_scopes.push(self.scopes.len().saturating_sub(1));
self.function_scopes
.push(self.scopes.len().saturating_sub(1));
}
pub(in crate::embedded::walk) fn leave_function(&mut self) {
self.member_query_proof.function_ids.pop();
self.function_scopes.pop();
self.var_scopes.pop();
}
pub(in crate::embedded::walk) fn append_crosses_function(&self, name: &str) -> bool {
let Some(&fn_start) = self.function_scopes.last() else {
return false;
};
self.scopes
.iter()
.enumerate()
.rev()
.find_map(|(index, scope)| scope.contains_key(name).then_some(index))
.is_some_and(|index| index < fn_start)
}
}