Search in sources :

Example 11 with StatementIntermediate

use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.

the class SwitchGotoToBreak method transformGotoToBreak.

public void transformGotoToBreak(GoToIntermediate gotoStatement) {
    Break breakExpression = new Break(gotoStatement.getInstruction());
    StatementIntermediate breakStatement = new StatementIntermediate(gotoStatement.getInstruction(), breakExpression);
    igc.getGraph().addVertex(breakStatement);
    igc.redirectPredecessors(gotoStatement, breakStatement);
    igc.redirectSuccessors(gotoStatement, breakStatement);
    igc.getGraph().removeVertex(gotoStatement);
}
Also used : StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) Break(org.candle.decompiler.intermediate.expression.Break)

Example 12 with StatementIntermediate

use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.

the class LoopGotoToBreak method transformGotoToBreak.

public void transformGotoToBreak(GoToIntermediate gotoStatement) {
    Break breakExpression = new Break(gotoStatement.getInstruction());
    StatementIntermediate breakStatement = new StatementIntermediate(gotoStatement.getInstruction(), breakExpression);
    igc.getGraph().addVertex(breakStatement);
    igc.redirectPredecessors(gotoStatement, breakStatement);
    igc.redirectSuccessors(gotoStatement, breakStatement);
    igc.getGraph().removeVertex(gotoStatement);
}
Also used : StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) Break(org.candle.decompiler.intermediate.expression.Break)

Example 13 with StatementIntermediate

use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.

the class ArrayForToEnhancedFor method extractExpressionFromGeneratedArrayAssignment.

private Expression extractExpressionFromGeneratedArrayAssignment(AbstractIntermediate declaration) {
    if (declaration instanceof StatementIntermediate) {
        StatementIntermediate si = (StatementIntermediate) declaration;
        Declaration dec = (Declaration) si.getExpression();
        return dec.getAssignment().getRightHandSide();
    }
    return null;
}
Also used : StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) Declaration(org.candle.decompiler.intermediate.expression.Declaration)

Example 14 with StatementIntermediate

use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.

the class MethodIntermediateVisitor method visitINVOKESTATIC.

public void visitINVOKESTATIC(INVOKESTATIC instruction) {
    // collect all parameters from the stack.
    ConstantPoolGen cpg = context.getMethodGen().getConstantPool();
    Type[] types = instruction.getArgumentTypes(context.getMethodGen().getConstantPool());
    final List<Expression> parameters = new ArrayList<Expression>(types.length);
    for (int i = 0, j = types.length; i < j; i++) {
        Expression param = context.getExpressions().pop();
        LOG.debug("Parameter: " + param);
        parameters.add(param);
    }
    Resolved resolvedType = new Resolved(context.getCurrentInstruction(), Type.CLASS, instruction.getLoadClassType(cpg).getClassName());
    String methodName = instruction.getMethodName(cpg);
    // create the expression..
    MethodInvocation methodInvocation = new MethodInvocation(context.getCurrentInstruction(), resolvedType, methodName, parameters);
    Type returned = instruction.getReturnType(context.getMethodGen().getConstantPool());
    if (returned == BasicType.VOID) {
        LOG.debug("This is a void return type!!");
        StatementIntermediate completeLine = new StatementIntermediate(context.getCurrentInstruction(), methodInvocation);
        context.pushIntermediateToInstruction(completeLine);
    } else {
        context.getExpressions().push(methodInvocation);
    }
}
Also used : OperationType(org.candle.decompiler.intermediate.expression.OperationType) ArithmeticType(org.candle.decompiler.intermediate.expression.ArithmeticType) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) ArrayList(java.util.ArrayList) Resolved(org.candle.decompiler.intermediate.expression.Resolved) MethodInvocation(org.candle.decompiler.intermediate.expression.MethodInvocation)

Example 15 with StatementIntermediate

use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.

the class MethodIntermediateVisitor method visitINVOKEINTERFACE.

public void visitINVOKEINTERFACE(INVOKEINTERFACE instruction) {
    ConstantPoolGen cpg = context.getMethodGen().getConstantPool();
    // collect all parameters from the stack.
    Type[] types = instruction.getArgumentTypes(cpg);
    final List<Expression> parameters = new ArrayList<Expression>(types.length);
    for (int i = 0, j = types.length; i < j; i++) {
        Expression param = context.getExpressions().pop();
        LOG.debug("Parameter: " + param);
        parameters.add(param);
    }
    // collect the method name we are calling.
    String methodName = instruction.getMethodName(context.getMethodGen().getConstantPool());
    Expression left = context.getExpressions().pop();
    // create the expression..
    MethodInvocation methodInvocation = new MethodInvocation(context.getCurrentInstruction(), left, methodName, parameters);
    Type returned = instruction.getReturnType(context.getMethodGen().getConstantPool());
    if (returned == BasicType.VOID) {
        StatementIntermediate completeLine = new StatementIntermediate(context.getCurrentInstruction(), methodInvocation);
        context.pushIntermediateToInstruction(completeLine);
        LOG.debug("Pushed complete line: " + completeLine.toString());
    } else {
        context.getExpressions().push(methodInvocation);
        LOG.debug("Pushed expression: " + methodInvocation);
    }
}
Also used : OperationType(org.candle.decompiler.intermediate.expression.OperationType) ArithmeticType(org.candle.decompiler.intermediate.expression.ArithmeticType) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate) ArrayList(java.util.ArrayList) MethodInvocation(org.candle.decompiler.intermediate.expression.MethodInvocation)

Aggregations

StatementIntermediate (org.candle.decompiler.intermediate.code.StatementIntermediate)24 AbstractIntermediate (org.candle.decompiler.intermediate.code.AbstractIntermediate)11 Expression (org.candle.decompiler.intermediate.expression.Expression)10 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)9 Declaration (org.candle.decompiler.intermediate.expression.Declaration)7 ArithmeticType (org.candle.decompiler.intermediate.expression.ArithmeticType)5 Assignment (org.candle.decompiler.intermediate.expression.Assignment)5 OperationType (org.candle.decompiler.intermediate.expression.OperationType)5 GoToIntermediate (org.candle.decompiler.intermediate.code.GoToIntermediate)4 GeneratedVariable (org.candle.decompiler.intermediate.expression.GeneratedVariable)4 MethodInvocation (org.candle.decompiler.intermediate.expression.MethodInvocation)4 Variable (org.candle.decompiler.intermediate.expression.Variable)4 ArrayList (java.util.ArrayList)3 IntermediateVariable (org.candle.decompiler.intermediate.IntermediateVariable)3 Throw (org.candle.decompiler.intermediate.expression.Throw)3 TreeSet (java.util.TreeSet)2 BooleanBranchIntermediate (org.candle.decompiler.intermediate.code.BooleanBranchIntermediate)2 IntermediateComparator (org.candle.decompiler.intermediate.code.IntermediateComparator)2 EnhancedForIntermediate (org.candle.decompiler.intermediate.code.loop.EnhancedForIntermediate)2 ArrayAccess (org.candle.decompiler.intermediate.expression.ArrayAccess)2