Search in sources :

Example 1 with Return

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

the class MethodIntermediateVisitor method visitLRETURN.

public void visitLRETURN(LRETURN instruction) {
    Expression exp = context.getExpressions().pop();
    Return ret = new Return(context.getCurrentInstruction(), exp);
    processReturn(ret);
}
Also used : Return(org.candle.decompiler.intermediate.expression.Return) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression)

Example 2 with Return

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

the class MethodIntermediateVisitor method visitIRETURN.

public void visitIRETURN(IRETURN instruction) {
    Expression exp = context.getExpressions().pop();
    Return ret = new Return(context.getCurrentInstruction(), exp);
    processReturn(ret);
}
Also used : Return(org.candle.decompiler.intermediate.expression.Return) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression)

Example 3 with Return

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

the class MethodIntermediateVisitor method visitARETURN.

public void visitARETURN(ARETURN instruction) {
    Expression exp = context.getExpressions().pop();
    Return ret = new Return(context.getCurrentInstruction(), exp);
    processReturn(ret);
}
Also used : Return(org.candle.decompiler.intermediate.expression.Return) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression)

Example 4 with Return

use of org.candle.decompiler.intermediate.expression.Return 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 5 with Return

use of org.candle.decompiler.intermediate.expression.Return 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

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