Skip to content

Commit

Permalink
Remove unused dependencies from filelist
Browse files Browse the repository at this point in the history
  • Loading branch information
dalance committed Nov 12, 2024
1 parent 106d29d commit ce21f20
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
42 changes: 19 additions & 23 deletions crates/analyzer/src/type_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::symbol::{Symbol, SymbolId};
use crate::symbol_path::SymbolPathNamespace;
use crate::symbol_table;
use bimap::BiMap;
use daggy::petgraph::unionfind::UnionFind;
use daggy::petgraph::visit::{EdgeRef, NodeIndexable};
use daggy::petgraph::visit::Dfs;
use daggy::{petgraph::algo, Dag, Walker};
use std::{cell::RefCell, collections::HashMap, collections::HashSet};
use veryl_parser::veryl_token::Token;
Expand Down Expand Up @@ -143,31 +142,28 @@ impl TypeDag {
}

fn connected_components(&self) -> Vec<Vec<Symbol>> {
let graph = self.dag.graph();
let mut vertex_sets = UnionFind::new(graph.node_bound());
for edge in graph.edge_references() {
let (a, b) = (edge.source(), edge.target());
let mut ret = Vec::new();
let mut graph = self.dag.graph().clone();

// Ignore Index0 because it is root node
if a.index() != 0 {
vertex_sets.union(graph.to_index(a), graph.to_index(b));
}
}
let labels = vertex_sets.into_labeling();
// Reverse edge to traverse nodes which are called from parent node
graph.reverse();

let mut ret = HashMap::new();
for node in graph.node_indices() {
let label = labels[graph.to_index(node)];
let index = node.index() as u32;

if self.paths.contains_key(&index) {
let sym = self.get_symbol(index);
ret.entry(label)
.and_modify(|x: &mut Vec<_>| x.push(sym.clone()))
.or_insert(vec![sym]);
for node in self.symbols.keys() {
let mut connected = Vec::new();
let mut dfs = Dfs::new(&graph, (*node).into());
while let Some(x) = dfs.next(&graph) {
let index = x.index() as u32;
if self.paths.contains_key(&index) {
let symbol = self.get_symbol(index);
connected.push(symbol);
}
}
if !connected.is_empty() {
ret.push(connected);
}
}
ret.into_values().collect()

ret
}

fn dump(&self) -> String {
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ mod filelist {
"module_a.veryl",
"module_b.veryl",
"module_c.veryl",
"fifo_controller.veryl",
"fifo.veryl",
"ram.veryl",
];
check_list(&paths, all);
Expand Down
6 changes: 1 addition & 5 deletions crates/veryl/src/cmd_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,7 @@ impl CmdBuild {

let mut candidate_symbols: Vec<_> = type_dag::connected_components()
.into_iter()
.filter(|symbols| {
symbols
.iter()
.any(|symbol| symbol.namespace.included(&prj_namespace))
})
.filter(|symbols| symbols[0].namespace.included(&prj_namespace))
.flatten()
.collect();
if include_tests {
Expand Down

0 comments on commit ce21f20

Please sign in to comment.