]> git.proxmox.com Git - rustc.git/blame - src/librustc_data_structures/control_flow_graph/mod.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / librustc_data_structures / control_flow_graph / mod.rs
CommitLineData
3157f602
XL
1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11use super::indexed_vec::Idx;
12pub use std::slice::Iter;
13
14pub mod dominators;
15pub mod iterate;
16pub mod reachable;
17mod reference;
18pub mod transpose;
19
20#[cfg(test)]
21mod test;
22
23pub trait ControlFlowGraph
24 where Self: for<'graph> GraphPredecessors<'graph, Item=<Self as ControlFlowGraph>::Node>,
25 Self: for<'graph> GraphSuccessors<'graph, Item=<Self as ControlFlowGraph>::Node>
26{
27 type Node: Idx;
28
29 fn num_nodes(&self) -> usize;
30 fn start_node(&self) -> Self::Node;
31 fn predecessors<'graph>(&'graph self, node: Self::Node)
32 -> <Self as GraphPredecessors<'graph>>::Iter;
33 fn successors<'graph>(&'graph self, node: Self::Node)
34 -> <Self as GraphSuccessors<'graph>>::Iter;
35}
36
37pub trait GraphPredecessors<'graph> {
38 type Item;
c30ab7b3 39 type Iter: Iterator<Item = Self::Item>;
3157f602
XL
40}
41
42pub trait GraphSuccessors<'graph> {
43 type Item;
c30ab7b3
SL
44 type Iter: Iterator<Item = Self::Item>;
45}