Search in sources :

Example 1 with NullIntermediate

use of org.candle.decompiler.intermediate.graph.context.NullIntermediate in project candle-decompiler by bradsdavis.

the class IntermediateTryCatch method generateCatch.

private void generateCatch(TryIntermediate tryIntermediate, CodeExceptionGen ceg) {
    LOG.debug("CEG: " + ceg);
    //convert the node to catch blocks...
    AbstractIntermediate catchDeclaration = igc.getOrderedIntermediate().ceiling(new NullIntermediate(ceg.getHandlerPC()));
    LOG.debug("Catch Declaration:" + catchDeclaration);
    if (catchDeclaration instanceof StatementIntermediate) {
        StatementIntermediate declarationStatement = (StatementIntermediate) catchDeclaration;
        if (declarationStatement.getExpression() instanceof Declaration) {
            Declaration declaration = (Declaration) declarationStatement.getExpression();
            //now, we can convert this into a catch block.
            CatchIntermediate catchIntermediate = new CatchIntermediate(declarationStatement.getInstruction(), ceg, declaration.getVariable());
            igc.getGraph().addVertex(catchIntermediate);
            //redirect statement to catch.
            igc.redirectPredecessors(declarationStatement, catchIntermediate);
            igc.redirectSuccessors(declarationStatement, catchIntermediate);
            //now, we just need to remove the statement.
            igc.getGraph().removeVertex(declarationStatement);
            //populate the bounds..
            //add the link between try and catch.
            igc.getGraph().addEdge(tryIntermediate, catchIntermediate);
        }
    }
}
Also used : AbstractIntermediate(org.candle.decompiler.intermediate.code.AbstractIntermediate) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) CatchIntermediate(org.candle.decompiler.intermediate.code.CatchIntermediate) Declaration(org.candle.decompiler.intermediate.expression.Declaration) NullIntermediate(org.candle.decompiler.intermediate.graph.context.NullIntermediate)

Example 2 with NullIntermediate

use of org.candle.decompiler.intermediate.graph.context.NullIntermediate in project candle-decompiler by bradsdavis.

the class IfLowerRangeVisitor method visitIfIntermediate.

@Override
public void visitIfIntermediate(IfIntermediate line) {
    AbstractIntermediate l = igc.getTrueTarget(line);
    InstructionHandle lower = l.getInstruction();
    line.getBlockRange().setStart(lower);
    //upper range...
    AbstractIntermediate u = igc.getFalseTarget(line);
    NullIntermediate nullIntermediate = new NullIntermediate(u.getInstruction().getPrev());
    AbstractIntermediate ai = igc.getOrderedIntermediate().floor(nullIntermediate);
    if (ai != null) {
        line.getBlockRange().setEnd(ai.getInstruction());
    }
}
Also used : AbstractIntermediate(org.candle.decompiler.intermediate.code.AbstractIntermediate) InstructionHandle(org.apache.bcel.generic.InstructionHandle) NullIntermediate(org.candle.decompiler.intermediate.graph.context.NullIntermediate)

Aggregations

AbstractIntermediate (org.candle.decompiler.intermediate.code.AbstractIntermediate)2 NullIntermediate (org.candle.decompiler.intermediate.graph.context.NullIntermediate)2 InstructionHandle (org.apache.bcel.generic.InstructionHandle)1 CatchIntermediate (org.candle.decompiler.intermediate.code.CatchIntermediate)1 StatementIntermediate (org.candle.decompiler.intermediate.code.StatementIntermediate)1 Declaration (org.candle.decompiler.intermediate.expression.Declaration)1