use of org.candle.decompiler.intermediate.expression.Resolved 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.candle.decompiler.intermediate.expression.Resolved in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitINSTANCEOF.
public void visitINSTANCEOF(INSTANCEOF instruction) {
ConstantPoolGen cpg = context.getMethodGen().getConstantPool();
String type = instruction.getLoadClassType(cpg).getClassName();
//get the left, create the right
Expression left = context.getExpressions().pop();
Expression right = new Resolved(context.getCurrentInstruction(), Type.BOOLEAN, type);
InstanceOf instanceOf = new InstanceOf(context.getCurrentInstruction(), left, right);
context.getExpressions().push(instanceOf);
}
use of org.candle.decompiler.intermediate.expression.Resolved in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitLDC.
public void visitLDC(LDC instruction) {
//load from constant pool.
LOG.debug("Loading from constant pool" + instruction.getClass());
MethodGen mg = context.getMethodGen();
ConstantPoolGen cpg = mg.getConstantPool();
StringBuilder resolvedValue = new StringBuilder();
Type type = instruction.getType(cpg);
if (Type.STRING == type) {
resolvedValue.append("\"");
}
Object instructionValue = instruction.getValue(cpg);
if (instructionValue instanceof ConstantClass) {
String clzName = getClassName((ConstantClass) instructionValue, cpg.getConstantPool());
resolvedValue.append(clzName);
} else {
resolvedValue.append(instructionValue.toString());
}
if (Type.STRING == type) {
resolvedValue.append("\"");
}
Resolved resolved = new Resolved(context.getCurrentInstruction(), type, resolvedValue.toString());
context.getExpressions().push(resolved);
}
use of org.candle.decompiler.intermediate.expression.Resolved in project candle-decompiler by bradsdavis.
the class ExceptionEdgeEnhancer method addExceptionHandle.
private void addExceptionHandle(IntermediateEdge ie, CodeExceptionGen ceg) {
ObjectType ot = ceg.getCatchType();
Resolved resolved = null;
if (ot == null) {
resolved = new Resolved((InstructionHandle) ie.getTarget(), Type.THROWABLE, "e");
} else {
resolved = new Resolved((InstructionHandle) ie.getTarget(), ot, ot.toString());
}
ie.getAttributes().put(EXCEPTION_STACK_KEY, resolved);
}
use of org.candle.decompiler.intermediate.expression.Resolved in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitLCONST.
public void visitLCONST(LCONST instruction) {
Resolved cons = new Resolved(context.getCurrentInstruction(), Type.LONG, instruction.getValue().toString());
context.getExpressions().push(cons);
}
Aggregations