Search in sources :

Example 1 with DepthFirstIterator

use of org.jgrapht.traverse.DepthFirstIterator in project jop by jop-devel.

the class CallGraph method getReachableImplementationsSet.

/**
     * Retrieve non-abstract methods reachable from the given call graph node.
     * All callgraph nodes reachable from nodes representing the given a method are collected
     * @param cgNode where to start
     * @return a list of all reachable implementations, sorted in DFS order
     */
public Set<MethodInfo> getReachableImplementationsSet(ExecutionContext cgNode) {
    Set<MethodInfo> implemented = new LinkedHashSet<MethodInfo>();
    DepthFirstIterator<ExecutionContext, ContextEdge> ti = new DepthFirstIterator<ExecutionContext, ContextEdge>(callGraph, cgNode);
    ti.setCrossComponentTraversal(false);
    while (ti.hasNext()) {
        MethodInfo m = ti.next().getMethodInfo();
        if (m == null)
            throw new AssertionError("Abstract method in callgraph");
        implemented.add(m);
    }
    return implemented;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DepthFirstIterator(org.jgrapht.traverse.DepthFirstIterator) MethodInfo(com.jopdesign.common.MethodInfo)

Example 2 with DepthFirstIterator

use of org.jgrapht.traverse.DepthFirstIterator in project jop by jop-devel.

the class CallGraph method getReachableImplementationsSet.

/**
     * Retrieve non-abstract methods reachable from the given method.
     * All callgraph nodes reachable from nodes representing the given a method are collected
     *
     * @param rootMethod start method
     * @return a list of all reachable methods, sorted in topological order
     */
public Set<MethodInfo> getReachableImplementationsSet(MethodInfo rootMethod) {
    Set<MethodInfo> implemented = new LinkedHashSet<MethodInfo>();
    for (ExecutionContext cgNode : methodNodes.get(rootMethod).getInstances()) {
        DepthFirstIterator<ExecutionContext, ContextEdge> ti = new DepthFirstIterator<ExecutionContext, ContextEdge>(callGraph, cgNode);
        ti.setCrossComponentTraversal(false);
        while (ti.hasNext()) {
            MethodInfo m = ti.next().getMethodInfo();
            if (m == null)
                throw new AssertionError("Abstract method in callgraph");
            implemented.add(m);
        }
    }
    return implemented;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DepthFirstIterator(org.jgrapht.traverse.DepthFirstIterator) MethodInfo(com.jopdesign.common.MethodInfo)

Example 3 with DepthFirstIterator

use of org.jgrapht.traverse.DepthFirstIterator in project candle-decompiler by bradsdavis.

the class InstructionToIntermediateEnhancer method process.

@Override
public void process() {
    GraphIterator<InstructionHandle, IntermediateEdge> iterator = new DepthFirstIterator<InstructionHandle, IntermediateEdge>(igc.getGraph());
    iterator.addTraversalListener(new InstructionTransversalListener(igc, intermediateContext));
    while (iterator.hasNext()) {
        iterator.next();
    }
}
Also used : DepthFirstIterator(org.jgrapht.traverse.DepthFirstIterator) InstructionTransversalListener(org.candle.decompiler.instruction.intermediate.InstructionTransversalListener) IntermediateEdge(org.candle.decompiler.intermediate.graph.edge.IntermediateEdge) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Aggregations

DepthFirstIterator (org.jgrapht.traverse.DepthFirstIterator)3 MethodInfo (com.jopdesign.common.MethodInfo)2 LinkedHashSet (java.util.LinkedHashSet)2 InstructionHandle (org.apache.bcel.generic.InstructionHandle)1 InstructionTransversalListener (org.candle.decompiler.instruction.intermediate.InstructionTransversalListener)1 IntermediateEdge (org.candle.decompiler.intermediate.graph.edge.IntermediateEdge)1