allow notion od edge labels to be overridden in the CDG
This commit is contained in:
parent
f3b5d41af9
commit
8855f80c97
|
@ -49,7 +49,7 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
* If requested, this is a map from parentXchild Pairs representing edges in the CDG to the labels of the control flow edges that
|
||||
* edge corresponds to. The labels are Boolean.True or Boolean.False for conditionals and an Integer for a switch label.
|
||||
*/
|
||||
private Map<Pair, Set<Object>> edgeLabels;
|
||||
private Map<Pair, Set<? extends Object>> edgeLabels;
|
||||
|
||||
/**
|
||||
* This is the heart of the CDG computation. Based on Cytron et al., this is the reverse dominance frontier based algorithm for
|
||||
|
@ -77,12 +77,12 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
T x = ns2.next();
|
||||
controlDependence.get(x).add(y);
|
||||
if (wantEdgeLabels) {
|
||||
Set<Object> labels = HashSetFactory.make();
|
||||
HashSet<Object> labels = HashSetFactory.make();
|
||||
edgeLabels.put(Pair.make(x, y), labels);
|
||||
for (Iterator<? extends T> ss = cfg.getSuccNodes(x); ss.hasNext();) {
|
||||
T s = ss.next();
|
||||
if (RDF.isDominatedBy(s, y)) {
|
||||
labels.add(s);
|
||||
labels.add(makeEdgeLabel(x, y, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,11 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
return controlDependence;
|
||||
}
|
||||
|
||||
/**
|
||||
protected Object makeEdgeLabel(T x, T y, T s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the control-dependence edges in a forward direction (i.e. edges from control parents to control children), this method
|
||||
* creates an EdgeManager that provides the edge half of the Graph abstraction.
|
||||
*/
|
||||
|
@ -245,7 +249,7 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
* Return the set of edge labels for the control flow edges that cause the given edge in the CDG. Requires that the CDG be
|
||||
* constructed with wantEdgeLabels being true.
|
||||
*/
|
||||
public Set<Object> getEdgeLabels(Object from, Object to) {
|
||||
public Set<? extends Object> getEdgeLabels(Object from, Object to) {
|
||||
return edgeLabels.get(Pair.make(from, to));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ package com.ibm.wala.util.graph;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.naming.OperationNotSupportedException;
|
||||
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IBinaryNaturalRelation;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
|
|
|
@ -18,11 +18,8 @@ import java.util.LinkedHashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.util.Predicate;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.Predicate;
|
||||
import com.ibm.wala.util.collections.FilterIterator;
|
||||
import com.ibm.wala.util.collections.FilterPredicate;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.IteratorUtil;
|
||||
|
@ -41,9 +38,8 @@ public class GraphSlicer {
|
|||
*
|
||||
* @param <T> type for nodes
|
||||
* @param g the graph to slice
|
||||
* @param f identifies targets for the backward slice
|
||||
* @param p identifies targets for the backward slice
|
||||
* @return the set of nodes in g, from which any of the targets (nodes that f accepts) is reachable.
|
||||
* @throws WalaException
|
||||
*/
|
||||
public static <T> Set<T> slice(Graph<T> g, Predicate<T> p){
|
||||
if (g == null) {
|
||||
|
|
Loading…
Reference in New Issue