Search in sources :

Example 1 with DuplicateHandle

use of org.apache.bcel.generic.DuplicateHandle in project candle-decompiler by bradsdavis.

the class LoopHeader method splitLoopHeader.

public void splitLoopHeader(InstructionHandle ih) {
    DuplicateHandle duplicate = new DuplicateHandle(ih);
    System.out.println(igc.getGraph().addVertex(duplicate));
    System.out.println(duplicate);
    List<InstructionHandle> preds = Graphs.predecessorListOf(igc.getGraph(), ih);
    for (InstructionHandle pred : preds) {
        IntermediateEdge ie = igc.getGraph().getEdge(pred, ih);
        IntermediateEdge in = igc.getGraph().addEdge(pred, duplicate);
        in.setType(ie.getType());
        // now remove the original edge.
        igc.getGraph().removeEdge(ie);
    }
    // add edge from duplicate to new.
    igc.getGraph().addEdge(duplicate, ih);
}
Also used : DuplicateHandle(org.apache.bcel.generic.DuplicateHandle) IntermediateEdge(org.candle.decompiler.intermediate.graph.edge.IntermediateEdge) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Example 2 with DuplicateHandle

use of org.apache.bcel.generic.DuplicateHandle in project candle-decompiler by bradsdavis.

the class SplitInstructionEnhancer method splitVertex.

protected void splitVertex(InstructionHandle iv) {
    List<InstructionHandle> preds = this.igc.getPredecessors(this.current);
    List<InstructionHandle> sucs = this.igc.getSuccessors(this.current);
    // remove all edges.
    for (InstructionHandle source : preds) {
        this.igc.getGraph().removeEdge(source, iv);
    }
    int i = 0;
    InstructionHandle target = iv;
    for (InstructionHandle source : preds) {
        // source = findSource(source);
        if (i > 0) {
            // clone.
            try {
                target = new DuplicateHandle(iv);
                igc.getGraph().addVertex(target);
                for (InstructionHandle successor : sucs) {
                    igc.getGraph().addEdge(target, successor);
                }
            } catch (Exception e) {
                LOG.error("Exception cloning.", e);
            }
        }
        igc.getGraph().addEdge(source, target);
        i++;
    }
}
Also used : DuplicateHandle(org.apache.bcel.generic.DuplicateHandle) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Aggregations

DuplicateHandle (org.apache.bcel.generic.DuplicateHandle)2 InstructionHandle (org.apache.bcel.generic.InstructionHandle)2 IntermediateEdge (org.candle.decompiler.intermediate.graph.edge.IntermediateEdge)1