use of org.candle.decompiler.ast.MethodBlock in project candle-decompiler by bradsdavis.
the class ClassIntermediateVisitor method extractMethodSignature.
protected MethodBlock extractMethodSignature(MethodGen methodGen) {
MethodBlock mb = null;
boolean isConstructor = false;
ConstantPoolGen cpg = methodGen.getConstantPool();
LocalVariableTable lvt = methodGen.getLocalVariableTable(cpg);
String access = Utility.accessToString(methodGen.getAccessFlags());
String signature = Type.getMethodSignature(methodGen.getType(), methodGen.getArgumentTypes());
String name = methodGen.getName();
if (StringUtils.equals(name, Constants.CONSTRUCTOR_NAME)) {
name = StringUtils.substringAfterLast(methodGen.getClassName(), ".");
isConstructor = true;
}
if (StringUtils.equals(methodGen.getName(), Constants.STATIC_INITIALIZER_NAME)) {
signature = "static ";
} else {
signature = org.apache.bcel.classfile.Utility.methodSignatureToString(signature, name, access, true, lvt);
}
StringBuilder builder = new StringBuilder(signature);
if (methodGen.getExceptions().length > 0) {
for (String excep : methodGen.getExceptions()) {
builder.append(" throws ").append(excep);
}
}
if (isConstructor) {
mb = new ConstructorBlock(builder.toString(), methodGen.getInstructionList().getEnd().getPosition());
} else {
mb = new MethodBlock(builder.toString(), methodGen.getInstructionList().getEnd().getPosition());
}
return mb;
}
use of org.candle.decompiler.ast.MethodBlock in project candle-decompiler by bradsdavis.
the class ClassIntermediateVisitor method visitMethod.
@Override
public void visitMethod(Method obj) {
MethodGen methodGenerator = new MethodGen(obj, this.javaClass.getClassName(), this.constantPool);
LOG.debug("Processing MethodInvocation: " + methodGenerator.toString());
IntermediateContext intermediateContext = new IntermediateContext(this.javaClass, methodGenerator);
InstructionList instructions = methodGenerator.getInstructionList();
instructions.setPositions(true);
InstructionGraphFactory igf = new InstructionGraphFactory(instructions, methodGenerator.getExceptionHandlers());
InstructionGraphContext igc = igf.process();
List<InstructionGraphEnhancer> iges = new ArrayList<InstructionGraphEnhancer>();
iges.add(new InstructionGraphWriter(igc, "before.dot"));
iges.add(new SplitInstructionEnhancer(igc));
iges.add(new ConditionEdgeEnhancer(igc));
iges.add(new ExceptionEdgeEnhancer(igc, methodGenerator.getExceptionHandlers()));
iges.add(new InstructionToIntermediateEnhancer(igc, intermediateContext));
iges.add(new BackEdgeEnhancer(igc));
iges.add(new LoopHeader(igc));
iges.add(new ContinuousLoop(igc));
iges.add(new NonIntermediateEliminator(igc));
iges.add(new InstructionGraphWriter(igc, "after.dot"));
for (InstructionGraphEnhancer ige : iges) {
ige.process();
}
IntermediateGraphTransformer igt = new IntermediateGraphTransformer(igc);
IntermediateGraphContext interGraphContext = igt.getIntermediateGraphContext();
processIntermediate(interGraphContext);
MethodBlock method = extractMethodSignature(methodGenerator);
BlockVisitor iv = new BlockVisitor(interGraphContext, method);
iv.process();
classBlock.addChild(method);
method.setParent(classBlock);
}
Aggregations