Search in sources :

Example 1 with Throw

use of org.candle.decompiler.intermediate.expression.Throw in project candle-decompiler by bradsdavis.

the class FinallyRangeVisitor method visitFinallyIntermediate.

@Override
public void visitFinallyIntermediate(FinallyIntermediate line) {
    NonGotoIterator iter = new NonGotoIterator(igc.getGraph(), line);
    // walk until we find a THROW.
    AbstractIntermediate throwsStatement = null;
    while (iter.hasNext()) {
        AbstractIntermediate i = iter.next();
        if (i instanceof StatementIntermediate) {
            StatementIntermediate s = (StatementIntermediate) i;
            if (s.getExpression() instanceof Throw) {
                throwsStatement = s;
                break;
            }
        }
    }
    if (throwsStatement != null) {
        line.getBlockRange().setEnd(throwsStatement.getInstruction());
    }
}
Also used : AbstractIntermediate(org.candle.decompiler.intermediate.code.AbstractIntermediate) Throw(org.candle.decompiler.intermediate.expression.Throw) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate)

Example 2 with Throw

use of org.candle.decompiler.intermediate.expression.Throw in project candle-decompiler by bradsdavis.

the class MethodIntermediateVisitor method visitATHROW.

public void visitATHROW(ATHROW instruction) {
    Expression expression = context.getExpressions().pop();
    Throw throwException = new Throw(context.getCurrentInstruction(), expression);
    StatementIntermediate complete = new StatementIntermediate(context.getCurrentInstruction(), throwException);
    context.pushIntermediateToInstruction(complete);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) Throw(org.candle.decompiler.intermediate.expression.Throw) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate)

Example 3 with Throw

use of org.candle.decompiler.intermediate.expression.Throw in project candle-decompiler by bradsdavis.

the class IntermediateGraphFactory method visitStatementIntermediate.

@Override
public void visitStatementIntermediate(StatementIntermediate line) {
    AbstractIntermediate next = ilc.getNext(line);
    // check to see if it is a return statement.
    if (line.getExpression() instanceof Return) {
        // don't add a line to next.
        return;
    }
    if (line.getExpression() instanceof Throw) {
        // don't add a line to next.
        return;
    }
    if (next != null) {
        // find how that actually maps to the abstract line..
        AbstractIntermediate intermediate = next;
        // now, we just add this into the graph.
        igc.getGraph().addVertex(intermediate);
        igc.getGraph().addEdge(line, intermediate);
    }
}
Also used : AbstractIntermediate(org.candle.decompiler.intermediate.code.AbstractIntermediate) Return(org.candle.decompiler.intermediate.expression.Return) Throw(org.candle.decompiler.intermediate.expression.Throw)

Example 4 with Throw

use of org.candle.decompiler.intermediate.expression.Throw in project candle-decompiler by bradsdavis.

the class CatchUpperRangeVisitor method visitCatchIntermediate.

@Override
public void visitCatchIntermediate(CatchIntermediate line) {
    // first, check if the line has an end already..
    if (line.getBlockRange().getEnd() != null) {
        return;
    }
    // processLastCatch(line);
    BreadthFirstIterator<AbstractIntermediate, IntermediateEdge> bfi = new BreadthFirstIterator<AbstractIntermediate, IntermediateEdge>(igc.getGraph(), line);
    AbstractIntermediate lastStatement = null;
    while (bfi.hasNext()) {
        AbstractIntermediate next = bfi.next();
        if (next instanceof GoToIntermediate) {
            // this would be a possible GOTO... find previous.
            LOG.debug("Catch GOGO: " + next + " goto:" + next.getInstruction().getPosition());
            lastStatement = igc.getSinglePredecessor(next);
            break;
        }
        if (next instanceof StatementIntermediate) {
            // determine what type of statement...
            if (((StatementIntermediate) next).getExpression() instanceof Throw) {
                lastStatement = next;
                break;
            }
            if (((StatementIntermediate) next).getExpression() instanceof Return) {
                lastStatement = next;
                break;
            }
        }
    }
    if (lastStatement != null) {
        line.getBlockRange().setEnd(lastStatement.getInstruction());
    }
}
Also used : AbstractIntermediate(org.candle.decompiler.intermediate.code.AbstractIntermediate) BreadthFirstIterator(org.jgrapht.traverse.BreadthFirstIterator) Return(org.candle.decompiler.intermediate.expression.Return) GoToIntermediate(org.candle.decompiler.intermediate.code.GoToIntermediate) Throw(org.candle.decompiler.intermediate.expression.Throw) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) IntermediateEdge(org.candle.decompiler.intermediate.graph.edge.IntermediateEdge)

Aggregations

Throw (org.candle.decompiler.intermediate.expression.Throw)4 AbstractIntermediate (org.candle.decompiler.intermediate.code.AbstractIntermediate)3 StatementIntermediate (org.candle.decompiler.intermediate.code.StatementIntermediate)3 Return (org.candle.decompiler.intermediate.expression.Return)2 GoToIntermediate (org.candle.decompiler.intermediate.code.GoToIntermediate)1 Expression (org.candle.decompiler.intermediate.expression.Expression)1 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)1 IntermediateEdge (org.candle.decompiler.intermediate.graph.edge.IntermediateEdge)1 BreadthFirstIterator (org.jgrapht.traverse.BreadthFirstIterator)1