soot.toolkits.graph.DominatorTreeAdapter Maven / Gradle / Ivy
package soot.toolkits.graph;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2004 Navindra Umanee
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* This adapter provides a DirectedGraph interface to DominatorTree.
*
*
*
* This might be useful if e.g. you want to apply a DirectedGraph analysis such as the PseudoTopologicalOrderer to a
* DominatorTree.
*
* @author Navindra Umanee
**/
public class DominatorTreeAdapter implements DirectedGraph> {
DominatorTree dt;
public DominatorTreeAdapter(DominatorTree dt) {
this.dt = dt;
}
public List> getHeads() {
return dt.getHeads();
}
public List> getTails() {
return dt.getTails();
}
public List> getPredsOf(DominatorNode node) {
return Collections.singletonList(dt.getParentOf(node));
}
public List> getSuccsOf(DominatorNode node) {
return dt.getChildrenOf(node);
}
public Iterator> iterator() {
return dt.iterator();
}
public int size() {
return dt.size();
}
}