This commit is contained in:
Folkert 2022-03-21 22:44:14 +01:00
parent cc9873eb6d
commit a170f461e0
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 2 additions and 146 deletions

View file

@ -1251,94 +1251,6 @@ where
result
}
pub(crate) fn references_from_local<'a, T>(
defined_symbol: Symbol,
visited: &'a mut MutSet<Symbol>,
refs_by_def: &'a MutMap<Symbol, (T, References)>,
closures: &'a MutMap<Symbol, References>,
) -> References
where
T: Debug,
{
let mut answer: References = References::new();
match refs_by_def.get(&defined_symbol) {
Some((_, refs)) => {
visited.insert(defined_symbol);
for local in refs.value_lookups.iter() {
if !visited.contains(local) {
let other_refs: References =
references_from_local(*local, visited, refs_by_def, closures);
answer = answer.union(other_refs);
}
answer.value_lookups.insert(*local);
}
for call in refs.calls.iter() {
if !visited.contains(call) {
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
answer = answer.union(other_refs);
}
answer.calls.insert(*call);
}
answer
}
None => answer,
}
}
pub(crate) fn references_from_call<'a, T>(
call_symbol: Symbol,
visited: &'a mut MutSet<Symbol>,
refs_by_def: &'a MutMap<Symbol, (T, References)>,
closures: &'a MutMap<Symbol, References>,
) -> References
where
T: Debug,
{
match closures.get(&call_symbol) {
Some(references) => {
let mut answer = references.clone();
visited.insert(call_symbol);
for closed_over_local in references.value_lookups.iter() {
if !visited.contains(closed_over_local) {
let other_refs =
references_from_local(*closed_over_local, visited, refs_by_def, closures);
answer = answer.union(other_refs);
}
answer.value_lookups.insert(*closed_over_local);
}
for call in references.calls.iter() {
if !visited.contains(call) {
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
answer = answer.union(other_refs);
}
answer.calls.insert(*call);
}
answer
}
None => {
// If the call symbol was not in the closure map, that means we're calling a non-function and
// will get a type mismatch later. For now, assume no references as a result of the "call."
References::new()
}
}
}
enum CanonicalizeRecordProblem {
InvalidOptionalValue {
field_name: Lowercase,