use of org.candle.decompiler.intermediate.graph.edge.IntermediateEdge in project candle-decompiler by bradsdavis.
the class IntermediateGraphWriter method process.
@Override
public void process() {
if (directory == null) {
return;
}
File a = new File(directory.getAbsolutePath() + File.separator + name);
LOG.debug("Instruction Graph: " + a.getAbsolutePath());
Writer x;
try {
x = new FileWriter(a);
DOTExporter<AbstractIntermediate, IntermediateEdge> dot = new DOTExporter<AbstractIntermediate, IntermediateEdge>(new IntegerNameProvider<AbstractIntermediate>(), new IntermediateLabelProvider(), new IntermediateEdgeProvider(), new IntermediateVertexAttributeProvider(), new InstructionEdgeAttributeProvider());
dot.export(x, igc.getGraph());
} catch (IOException e) {
e.printStackTrace();
}
LOG.debug("End Instruction Graph ======");
}
use of org.candle.decompiler.intermediate.graph.edge.IntermediateEdge in project candle-decompiler by bradsdavis.
the class RetractDuplicateFinally method collectOffsets.
protected Set<Integer> collectOffsets(AbstractIntermediate line) {
// this is the finally template.
AbstractIntermediate first = igc.getSingleSuccessor(line);
// now, store the instruction position.
int position = first.getInstruction().getPosition();
BreadthFirstIterator<AbstractIntermediate, IntermediateEdge> bfi = new BreadthFirstIterator<AbstractIntermediate, IntermediateEdge>(igc.getGraph(), first);
Set<Integer> offsets = new TreeSet<Integer>();
while (bfi.hasNext()) {
AbstractIntermediate next = bfi.next();
int nextPosition = next.getInstruction().getPosition();
int offset = nextPosition - position;
LOG.debug("Offset: " + offset);
offsets.add(offset);
}
return offsets;
}
use of org.candle.decompiler.intermediate.graph.edge.IntermediateEdge in project candle-decompiler by bradsdavis.
the class ConditionToWhileLoop method updateEdges.
protected void updateEdges(WhileIntermediate wi) {
List<AbstractIntermediate> predecessors = igc.getPredecessors(wi);
for (AbstractIntermediate predecessor : predecessors) {
IntermediateEdge ie = igc.getGraph().getEdge(predecessor, wi);
igc.validateBackEdge(ie);
}
List<AbstractIntermediate> successors = igc.getSuccessors(wi);
for (AbstractIntermediate successor : successors) {
IntermediateEdge ie = igc.getGraph().getEdge(wi, successor);
igc.validateBackEdge(ie);
}
}
use of org.candle.decompiler.intermediate.graph.edge.IntermediateEdge in project candle-decompiler by bradsdavis.
the class GraphUtil method redirectPredecessors.
/**
* Takes all parent of source, and redirects their output to the target.
*
* @param source
* @param target
*/
public void redirectPredecessors(T source, T target) {
List<T> predecessors = Graphs.predecessorListOf(this.graph, source);
// remove edges between predecessor and source.
for (T p : predecessors) {
IntermediateEdge existing = graph.getEdge(p, source);
redirectEnd(existing, target);
}
}
use of org.candle.decompiler.intermediate.graph.edge.IntermediateEdge in project candle-decompiler by bradsdavis.
the class ConditionEdgeEnhancer method process.
@Override
public void process(InstructionHandle ih) {
if (ih instanceof BranchHandle) {
// ok, now we need to replace existing successor edges appropriately.
BranchHandle bh = (BranchHandle) ih;
List<InstructionHandle> successors = igc.getSuccessors(ih);
TreeSet<InstructionHandle> orderedSuccessors = new TreeSet<InstructionHandle>(new InstructionComparator());
orderedSuccessors.addAll(successors);
if (successors.size() == 2) {
// lowest will be true condition....
IntermediateEdge truePath = igc.getGraph().getEdge(ih, orderedSuccessors.first());
ConditionEdge trueCondition = createConditionalEdge(truePath, true);
igc.getGraph().removeEdge(truePath);
igc.getGraph().addEdge(ih, orderedSuccessors.first(), trueCondition);
// highest will be false condition....
IntermediateEdge falsePath = igc.getGraph().getEdge(ih, orderedSuccessors.last());
ConditionEdge falseCondition = createConditionalEdge(falsePath, false);
igc.getGraph().removeEdge(falsePath);
igc.getGraph().addEdge(ih, orderedSuccessors.last(), falseCondition);
}
}
}
Aggregations