diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-04-06 17:28:59 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-05-18 10:11:35 -0400 |
| commit | f89041bbe3da48d98c1512b39c819ed42cff4e78 (patch) | |
| tree | 15d04ce7c922dd7be2d038d10a5a21e36e0cdb40 /src/librustc_data_structures/graph | |
| parent | bc02a54d12f8b03506ae8eda50a05784cf04b63f (diff) | |
| download | rust-f89041bbe3da48d98c1512b39c819ed42cff4e78.tar.gz rust-f89041bbe3da48d98c1512b39c819ed42cff4e78.zip | |
identify inputs of `MetaData(X)` nodes
Generate a second hash file that contains the metadata for an X node.
Diffstat (limited to 'src/librustc_data_structures/graph')
| -rw-r--r-- | src/librustc_data_structures/graph/mod.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/librustc_data_structures/graph/mod.rs b/src/librustc_data_structures/graph/mod.rs index 99a87d1e760..731471b0600 100644 --- a/src/librustc_data_structures/graph/mod.rs +++ b/src/librustc_data_structures/graph/mod.rs @@ -292,11 +292,15 @@ impl<N: Debug, E: Debug> Graph<N, E> { } } - pub fn depth_traverse<'a>(&'a self, start: NodeIndex) -> DepthFirstTraversal<'a, N, E> { + pub fn depth_traverse<'a>(&'a self, + start: NodeIndex, + direction: Direction) + -> DepthFirstTraversal<'a, N, E> { DepthFirstTraversal { graph: self, stack: vec![start], visited: BitVector::new(self.nodes.len()), + direction: direction, } } } @@ -371,6 +375,7 @@ pub struct DepthFirstTraversal<'g, N: 'g, E: 'g> { graph: &'g Graph<N, E>, stack: Vec<NodeIndex>, visited: BitVector, + direction: Direction, } impl<'g, N: Debug, E: Debug> Iterator for DepthFirstTraversal<'g, N, E> { @@ -382,9 +387,10 @@ impl<'g, N: Debug, E: Debug> Iterator for DepthFirstTraversal<'g, N, E> { continue; } - for (_, edge) in self.graph.outgoing_edges(idx) { - if !self.visited.contains(edge.target().node_id()) { - self.stack.push(edge.target()); + for (_, edge) in self.graph.adjacent_edges(idx, self.direction) { + let target = edge.source_or_target(self.direction); + if !self.visited.contains(target.node_id()) { + self.stack.push(target); } } |
