use of org.apache.bcel.generic.InstructionHandle in project candle-decompiler by bradsdavis.
the class StackClonePointListener method finish.
public void finish(VertexTraversalEvent<InstructionHandle> e) {
InstructionHandle ih = e.getVertex();
List<InstructionHandle> successors = igc.getSuccessors(ih);
if (successors.size() > 1) {
// duplicate the stack to all children...
if (LOG.isDebugEnabled()) {
LOG.debug("Must duplicate stack to all children: " + ih);
}
for (InstructionHandle successor : successors) {
addExpressionStack(successor, (Stack) ic.getExpressions().clone());
}
}
}
use of org.apache.bcel.generic.InstructionHandle in project candle-decompiler by bradsdavis.
the class ClassIntermediateVisitor method writeGraph.
private void writeGraph(String name, InstructionGraphContext igc) {
LOG.debug("Instruction Graph ======");
File a = new File("/Users/bradsdavis/Projects/workspace/clzTest/" + name);
Writer x;
try {
x = new FileWriter(a);
DOTExporter<InstructionHandle, IntermediateEdge> f = new DOTExporter<InstructionHandle, IntermediateEdge>(new IntegerNameProvider<InstructionHandle>(), new InstructionLabelProvider(), new IntermediateEdgeProvider(), null, new InstructionEdgeAttributeProvider());
f.export(x, igc.getGraph());
} catch (IOException e) {
e.printStackTrace();
}
LOG.debug("End Instruction Graph ======");
}
use of org.apache.bcel.generic.InstructionHandle in project candle-decompiler by bradsdavis.
the class IntermediateGraphFactory method visitMultiBranchIntermediate.
@Override
public void visitMultiBranchIntermediate(MultiBranchIntermediate line) {
Select select = (Select) line.getInstruction().getInstruction();
Set<Case> cases = new HashSet<Case>();
InstructionHandle[] handles = select.getTargets();
int[] matches = select.getMatchs();
for (int i = 0, j = handles.length; i < j; i++) {
InstructionHandle ih = handles[i];
int match = matches[i];
Resolved resolved = new Resolved(line.getInstruction(), BasicType.INT, "" + match);
Case caseEntry = new Case(line.getInstruction(), ih, resolved);
cases.add(caseEntry);
}
if (select.getTarget() != null) {
DefaultCase defaultCase = new DefaultCase(line.getInstruction(), select.getTarget());
line.setDefaultCase(defaultCase);
}
// now, create the graph.
line.setCases(cases);
// now, create the graph.
igc.getGraph().addVertex(line);
if (line.getDefaultCase() != null) {
CaseIntermediate si = new CaseIntermediate(line.getInstruction(), line.getDefaultCase());
igc.getGraph().addVertex(si);
// add an edge.
igc.getGraph().addEdge(line, si);
// add edge from outcome to edge.
LOG.debug(si);
AbstractIntermediate target = ilc.getNext(line.getDefaultCase().getTarget().getPosition());
LOG.debug("TargeT:" + target);
igc.getGraph().addVertex(target);
igc.getGraph().addEdge(si, target);
}
for (Case caseVal : line.getCases()) {
CaseIntermediate si = new CaseIntermediate(line.getInstruction(), caseVal);
igc.getGraph().addVertex(si);
// add an edge.
igc.getGraph().addEdge(line, si);
// add edge from outcome to edge.
AbstractIntermediate target = ilc.getNext(caseVal.getTarget().getPosition());
igc.getGraph().addVertex(target);
igc.getGraph().addEdge(si, target);
}
}
use of org.apache.bcel.generic.InstructionHandle in project candle-decompiler by bradsdavis.
the class IntermediateLineContext method getNext.
public AbstractIntermediate getNext(AbstractIntermediate ai) {
if (ai instanceof GoToIntermediate) {
BranchHandle bh = (BranchHandle) ai.getInstruction();
Integer position = bh.getTarget().getPosition();
return getNext(position);
}
// otherwise, get it from the next position.
InstructionHandle next = ai.getInstruction().getNext();
// return either null, if next is null (last next). Otherwise, send next position.
return next == null ? null : getNext(next.getPosition());
}
use of org.apache.bcel.generic.InstructionHandle in project candle-decompiler by bradsdavis.
the class BackEdgeEnhancer method process.
@Override
public void process(InstructionHandle ih) {
List<InstructionHandle> successors = Graphs.successorListOf(igc.getGraph(), ih);
for (InstructionHandle successor : successors) {
IntermediateEdge ie = igc.getGraph().getEdge(ih, successor);
// color back...
int t1 = ih.getPosition();
int t2 = successor.getPosition();
if (t2 < t1) {
ie.setType(EdgeType.BACK);
}
}
}
Aggregations