move reference matrix

This commit is contained in:
Folkert 2022-05-05 20:48:50 +02:00
parent dd51479764
commit c5b7ff98fd
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
6 changed files with 8 additions and 6 deletions

1
Cargo.lock generated
View file

@ -3573,6 +3573,7 @@ dependencies = [
name = "roc_collections" name = "roc_collections"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitvec 1.0.0",
"bumpalo", "bumpalo",
"hashbrown 0.11.2", "hashbrown 0.11.2",
"im", "im",

View file

@ -9,9 +9,9 @@ use crate::expr::Expr::{self, *};
use crate::expr::{canonicalize_expr, Output, Recursive}; use crate::expr::{canonicalize_expr, Output, Recursive};
use crate::pattern::{canonicalize_def_header_pattern, BindingsFromPattern, Pattern}; use crate::pattern::{canonicalize_def_header_pattern, BindingsFromPattern, Pattern};
use crate::procedure::References; use crate::procedure::References;
use crate::reference_matrix::ReferenceMatrix;
use crate::scope::create_alias; use crate::scope::create_alias;
use crate::scope::Scope; use crate::scope::Scope;
use roc_collections::ReferenceMatrix;
use roc_collections::VecMap; use roc_collections::VecMap;
use roc_collections::{ImSet, MutMap, SendMap}; use roc_collections::{ImSet, MutMap, SendMap};
use roc_module::ident::Ident; use roc_module::ident::Ident;

View file

@ -16,7 +16,6 @@ pub mod num;
pub mod operator; pub mod operator;
pub mod pattern; pub mod pattern;
pub mod procedure; pub mod procedure;
mod reference_matrix;
pub mod scope; pub mod scope;
pub mod string; pub mod string;
pub mod traverse; pub mod traverse;

View file

@ -11,3 +11,4 @@ im-rc = "15.0.0"
wyhash = "0.5.0" wyhash = "0.5.0"
bumpalo = { version = "3.8.0", features = ["collections"] } bumpalo = { version = "3.8.0", features = ["collections"] }
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] } hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }
bitvec = "1"

View file

@ -3,12 +3,14 @@
#![allow(clippy::large_enum_variant)] #![allow(clippy::large_enum_variant)]
pub mod all; pub mod all;
mod reference_matrix;
mod small_string_interner; mod small_string_interner;
pub mod soa; pub mod soa;
mod vec_map; mod vec_map;
mod vec_set; mod vec_set;
pub use all::{default_hasher, BumpMap, ImEntry, ImMap, ImSet, MutMap, MutSet, SendMap}; pub use all::{default_hasher, BumpMap, ImEntry, ImMap, ImSet, MutMap, MutSet, SendMap};
pub use reference_matrix::{ReferenceMatrix, Sccs};
pub use small_string_interner::SmallStringInterner; pub use small_string_interner::SmallStringInterner;
pub use vec_map::VecMap; pub use vec_map::VecMap;
pub use vec_set::VecSet; pub use vec_set::VecSet;

View file

@ -1,4 +1,3 @@
// see if we get better performance with different integer types
type Order = bitvec::order::Lsb0; type Order = bitvec::order::Lsb0;
type Element = usize; type Element = usize;
type BitVec = bitvec::vec::BitVec<Element, Order>; type BitVec = bitvec::vec::BitVec<Element, Order>;
@ -9,7 +8,7 @@ type BitSlice = bitvec::prelude::BitSlice<Element, Order>;
/// We use this for sorting definitions so every definition is defined before it is used. /// We use this for sorting definitions so every definition is defined before it is used.
/// This functionality is also used to spot and report invalid recursion. /// This functionality is also used to spot and report invalid recursion.
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct ReferenceMatrix { pub struct ReferenceMatrix {
bitvec: BitVec, bitvec: BitVec,
length: usize, length: usize,
} }
@ -156,7 +155,7 @@ impl ReferenceMatrix {
} }
#[allow(dead_code)] #[allow(dead_code)]
pub(crate) enum TopologicalSort { pub enum TopologicalSort {
/// There were no cycles, all nodes have been partitioned into groups /// There were no cycles, all nodes have been partitioned into groups
Groups { groups: Vec<Vec<u32>> }, Groups { groups: Vec<Vec<u32>> },
/// Cycles were found. All nodes that are not part of a cycle have been partitioned /// Cycles were found. All nodes that are not part of a cycle have been partitioned
@ -259,7 +258,7 @@ fn recurse_onto(length: usize, bitvec: &BitVec, v: usize, params: &mut Params) {
} }
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct Sccs { pub struct Sccs {
components: usize, components: usize,
matrix: ReferenceMatrix, matrix: ReferenceMatrix,
} }