Search in sources :

Example 1 with ArrayCreation

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

the class MethodIntermediateVisitor method visitANEWARRAY.

/**
 * Decompiles "new object array" operations.
 */
public void visitANEWARRAY(ANEWARRAY instruction) {
    Type type = instruction.getType(context.getMethodGen().getConstantPool());
    Expression count = context.getExpressions().pop();
    ArrayCreation nai = null;
    if (context.getCurrentInstruction().getNext().getInstruction() instanceof DUP) {
        nai = new NewConstantArrayInstance(context.getCurrentInstruction(), type, count);
    } else {
        nai = new ArrayCreation(context.getCurrentInstruction(), type, count);
    }
    context.getExpressions().push(nai);
}
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) ArrayCreation(org.candle.decompiler.intermediate.expression.ArrayCreation) NewConstantArrayInstance(org.candle.decompiler.intermediate.expression.NewConstantArrayInstance)

Example 2 with ArrayCreation

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

the class MethodIntermediateVisitor method visitMULTIANEWARRAY.

/**
 * Decompiles "new multi-dimentional array" operations.
 */
public void visitMULTIANEWARRAY(MULTIANEWARRAY instruction) {
    Type type = instruction.getType(context.getMethodGen().getConstantPool());
    LinkedList<Expression> counts = new LinkedList<Expression>();
    int provided = instruction.getDimensions();
    for (int i = 0; i < provided; i++) {
        counts.addFirst(context.getExpressions().pop());
    }
    ArrayCreation nai = new ArrayCreation(context.getCurrentInstruction(), type, counts);
    context.getExpressions().push(nai);
}
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) ArrayCreation(org.candle.decompiler.intermediate.expression.ArrayCreation) LinkedList(java.util.LinkedList)

Example 3 with ArrayCreation

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

Aggregations

ArrayCreation (org.candle.decompiler.intermediate.expression.ArrayCreation)3 Expression (org.candle.decompiler.intermediate.expression.Expression)3 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)3 ArithmeticType (org.candle.decompiler.intermediate.expression.ArithmeticType)2 NewConstantArrayInstance (org.candle.decompiler.intermediate.expression.NewConstantArrayInstance)2 OperationType (org.candle.decompiler.intermediate.expression.OperationType)2 LinkedList (java.util.LinkedList)1