mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
use bitvec in the input for sccs
This commit is contained in:
parent
13fc0f9a1e
commit
8a209334cc
3 changed files with 16 additions and 31 deletions
|
@ -192,17 +192,12 @@ fn sort_type_defs_before_introduction(
|
|||
}
|
||||
|
||||
// find the strongly connected components and their relations
|
||||
let nodes: Vec<_> = (0..capacity as u32).collect();
|
||||
|
||||
let mut output = Vec::with_capacity(capacity);
|
||||
|
||||
for group in matrix.strongly_connected_components(&nodes).groups() {
|
||||
for index in group.iter_ones() {
|
||||
output.push(symbols[index])
|
||||
}
|
||||
}
|
||||
|
||||
output
|
||||
matrix
|
||||
.strongly_connected_components_all()
|
||||
.groups()
|
||||
.flat_map(|group| group.iter_ones())
|
||||
.map(|index| symbols[index])
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -790,14 +785,10 @@ pub(crate) fn sort_can_defs(
|
|||
};
|
||||
}
|
||||
|
||||
let nodes: Vec<_> = (0..defs.len() as u32).collect();
|
||||
|
||||
// We first perform SCC based on any reference, both variable usage and calls
|
||||
// considering both value definitions and function bodies. This will spot any
|
||||
// recursive relations between any 2 definitions.
|
||||
let sccs = def_ordering
|
||||
.references
|
||||
.strongly_connected_components(&nodes);
|
||||
let sccs = def_ordering.references.strongly_connected_components_all();
|
||||
|
||||
let mut declarations = Vec::new();
|
||||
|
||||
|
@ -838,10 +829,9 @@ pub(crate) fn sort_can_defs(
|
|||
// boom = \{} -> boom {}
|
||||
//
|
||||
// In general we cannot spot faulty recursion (halting problem) so this is our best attempt
|
||||
let nodes: Vec<_> = group.iter_ones().map(|v| v as u32).collect();
|
||||
let direct_sccs = def_ordering
|
||||
.direct_references
|
||||
.strongly_connected_components(&nodes);
|
||||
.strongly_connected_components_subset(group);
|
||||
|
||||
let declaration = if direct_sccs.groups().count() == 1 {
|
||||
// all defs are part of the same direct cycle, that is invalid!
|
||||
|
@ -1571,8 +1561,7 @@ fn correct_mutual_recursive_type_alias<'a>(
|
|||
|
||||
let mut solved_aliases = bitvec::vec::BitVec::<usize>::repeat(false, capacity);
|
||||
|
||||
let group: Vec<_> = (0u32..capacity as u32).collect();
|
||||
let sccs = matrix.strongly_connected_components(&group);
|
||||
let sccs = matrix.strongly_connected_components_all();
|
||||
|
||||
// scratchpad to store aliases that are modified in the current iteration.
|
||||
// Only used when there is are more than one alias in a group. See below why
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue