Search in sources :

Example 36 with Expression

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

the class MethodIntermediateVisitor method visitDRETURN.

public void visitDRETURN(DRETURN 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 37 with Expression

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

the class MethodIntermediateVisitor method visitSWAP.

public void visitSWAP(SWAP instruction) {
    Expression one = context.getExpressions().pop();
    Expression two = context.getExpressions().pop();
    context.getExpressions().push(one);
    context.getExpressions().push(two);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression)

Example 38 with Expression

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

the class MethodIntermediateVisitor method visitFRETURN.

public void visitFRETURN(FRETURN 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 39 with Expression

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

the class MethodIntermediateVisitor method visitNEWARRAY.

/**
 * Decompiles "new primitive array" operations.
 */
public void visitNEWARRAY(NEWARRAY instruction) {
    // first, check to see if the next instruction is a DUP.  If so,
    // this is probably a constant array value.
    Expression count = context.getExpressions().pop();
    ArrayCreation nai = null;
    if (context.getCurrentInstruction().getNext().getInstruction() instanceof DUP) {
        nai = new NewConstantArrayInstance(context.getCurrentInstruction(), instruction.getType(), count);
    } else {
        nai = new ArrayCreation(context.getCurrentInstruction(), instruction.getType(), count);
    }
    context.getExpressions().push(nai);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) ArrayCreation(org.candle.decompiler.intermediate.expression.ArrayCreation) NewConstantArrayInstance(org.candle.decompiler.intermediate.expression.NewConstantArrayInstance)

Example 40 with Expression

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

Aggregations

Expression (org.candle.decompiler.intermediate.expression.Expression)52 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)46 Resolved (org.candle.decompiler.intermediate.expression.Resolved)11 StatementIntermediate (org.candle.decompiler.intermediate.code.StatementIntermediate)10 ArithmeticType (org.candle.decompiler.intermediate.expression.ArithmeticType)10 OperationType (org.candle.decompiler.intermediate.expression.OperationType)10 ArrayList (java.util.ArrayList)6 Assignment (org.candle.decompiler.intermediate.expression.Assignment)6 BooleanBranchIntermediate (org.candle.decompiler.intermediate.code.BooleanBranchIntermediate)5 Return (org.candle.decompiler.intermediate.expression.Return)5 ArrayAccess (org.candle.decompiler.intermediate.expression.ArrayAccess)4 GeneratedVariable (org.candle.decompiler.intermediate.expression.GeneratedVariable)4 MethodInvocation (org.candle.decompiler.intermediate.expression.MethodInvocation)4 MultiConditional (org.candle.decompiler.intermediate.expression.MultiConditional)4 Variable (org.candle.decompiler.intermediate.expression.Variable)4 IntermediateVariable (org.candle.decompiler.intermediate.IntermediateVariable)3 ArrayCreation (org.candle.decompiler.intermediate.expression.ArrayCreation)3 Declaration (org.candle.decompiler.intermediate.expression.Declaration)3 NewConstantArrayInstance (org.candle.decompiler.intermediate.expression.NewConstantArrayInstance)3 AbstractIntermediate (org.candle.decompiler.intermediate.code.AbstractIntermediate)2