Search in sources :

Example 16 with Expression

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

the class MethodIntermediateVisitor method printExpressions.

public void printExpressions() {
    if (LOG.isDebugEnabled()) {
        List<Expression> currentStack = new ArrayList<Expression>(context.getExpressions());
        LOG.debug("Current Expression Stack: ");
        for (Expression e : currentStack) {
            LOG.debug("Expression Stack: " + e);
        }
    }
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) ArrayList(java.util.ArrayList)

Example 17 with Expression

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

the class MethodIntermediateVisitor method visitLDC2_W.

public void visitLDC2_W(LDC2_W instruction) {
    //load from constant pool.
    LOG.debug("Loading from constant pool" + instruction.getClass());
    MethodGen mg = context.getMethodGen();
    ConstantPoolGen cpg = mg.getConstantPool();
    Type type = instruction.getType(cpg);
    Object instructionValue = instruction.getValue(cpg);
    if (Type.STRING == type) {
        Expression resolved = new StringLiteral(context.getCurrentInstruction(), instructionValue.toString());
        context.getExpressions().push(resolved);
        return;
    } else {
    }
    StringBuilder resolvedValue = new StringBuilder();
    if (instructionValue instanceof ConstantClass) {
        String clzName = getClassName((ConstantClass) instructionValue, cpg.getConstantPool());
        resolvedValue.append(clzName);
    } else {
        resolvedValue.append(instructionValue.toString());
    }
    Expression resolved = new Resolved(context.getCurrentInstruction(), type, resolvedValue.toString());
    context.getExpressions().push(resolved);
}
Also used : OperationType(org.candle.decompiler.intermediate.expression.OperationType) ArithmeticType(org.candle.decompiler.intermediate.expression.ArithmeticType) StringLiteral(org.candle.decompiler.intermediate.expression.StringLiteral) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) Resolved(org.candle.decompiler.intermediate.expression.Resolved) ConstantClass(org.apache.bcel.classfile.ConstantClass)

Example 18 with Expression

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

the class MethodIntermediateVisitor method processArrayLoad.

//array load operations
protected void processArrayLoad() {
    Expression arrayPosition = context.getExpressions().pop();
    Expression arrayObject = context.getExpressions().pop();
    //now, we just need to create the array reference.
    ArrayAccess apr = new ArrayAccess(context.getCurrentInstruction(), arrayObject, arrayPosition);
    context.getExpressions().push(apr);
}
Also used : ArrayAccess(org.candle.decompiler.intermediate.expression.ArrayAccess) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression)

Example 19 with Expression

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

the class MethodIntermediateVisitor method visitDUP_X1.

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

Example 20 with Expression

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

the class MethodIntermediateVisitor method processMultiConditionalStatement.

public void processMultiConditionalStatement(OperationType operation) {
    //first, get the things to be operated on.
    Expression right = context.getExpressions().pop();
    Expression left = context.getExpressions().pop();
    processMultiConditionalStatement(operation, left, right);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression)

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