Search in sources :

Example 6 with Resolved

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

the class MethodIntermediateVisitor method visitSIPUSH.

public void visitSIPUSH(SIPUSH instruction) {
    Resolved resolved = new Resolved(context.getCurrentInstruction(), Type.SHORT, instruction.getValue().toString());
    context.getExpressions().push(resolved);
    LOG.debug("Pushing: " + resolved);
}
Also used : Resolved(org.candle.decompiler.intermediate.expression.Resolved)

Example 7 with Resolved

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

the class MethodIntermediateVisitor method visitLCMP.

public void visitLCMP(LCMP instruction) {
    Expression left = context.getExpressions().pop();
    Expression right = context.getExpressions().pop();
    MultiConditional eq = new MultiConditional(context.getCurrentInstruction(), left, right, OperationType.EQ);
    MultiConditional logic = new MultiConditional(context.getCurrentInstruction(), left, right, OperationType.GREATER);
    Resolved r0 = new Resolved(context.getCurrentInstruction(), Type.INT, "0");
    Resolved rN = new Resolved(context.getCurrentInstruction(), Type.INT, "-1");
    Resolved rP = new Resolved(context.getCurrentInstruction(), Type.INT, "1");
    Ternary tern2 = new Ternary(context.getCurrentInstruction(), ObjectType.INT, logic, rP, rN);
    Ternary tern1 = new Ternary(context.getCurrentInstruction(), Type.INT, eq, r0, tern2);
    context.getExpressions().push(tern1);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) Ternary(org.candle.decompiler.intermediate.expression.Ternary) Resolved(org.candle.decompiler.intermediate.expression.Resolved) MultiConditional(org.candle.decompiler.intermediate.expression.MultiConditional)

Example 8 with Resolved

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

the class MethodIntermediateVisitor method visitConversionInstruction.

public void visitConversionInstruction(ConversionInstruction instruction) {
    ConstantPoolGen cpg = context.getMethodGen().getConstantPool();
    Expression right = context.getExpressions().pop();
    Type type = instruction.getType(cpg);
    //now see what type it is.
    LOG.debug("To Type: " + type);
    Resolved resolve = new Resolved(context.getCurrentInstruction(), type, type.toString());
    Cast cast = new Cast(context.getCurrentInstruction(), resolve, right);
    context.getExpressions().push(cast);
}
Also used : Cast(org.candle.decompiler.intermediate.expression.Cast) 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) Resolved(org.candle.decompiler.intermediate.expression.Resolved)

Example 9 with Resolved

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

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

the class MethodIntermediateVisitor method visitIFGE.

@Override
public void visitIFGE(IFGE obj) {
    Expression right = new Resolved(context.getCurrentInstruction(), null, "0");
    Expression left = context.getExpressions().pop();
    processMultiConditionalStatement(OperationType.GREATER_EQUAL, left, right);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) Resolved(org.candle.decompiler.intermediate.expression.Resolved)

Aggregations

Resolved (org.candle.decompiler.intermediate.expression.Resolved)20 Expression (org.candle.decompiler.intermediate.expression.Expression)11 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)10 ArithmeticType (org.candle.decompiler.intermediate.expression.ArithmeticType)4 OperationType (org.candle.decompiler.intermediate.expression.OperationType)4 ArrayList (java.util.ArrayList)2 ConstantClass (org.apache.bcel.classfile.ConstantClass)2 InstructionHandle (org.apache.bcel.generic.InstructionHandle)2 AbstractIntermediate (org.candle.decompiler.intermediate.code.AbstractIntermediate)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ObjectType (org.apache.bcel.generic.ObjectType)1 Select (org.apache.bcel.generic.Select)1 CaseIntermediate (org.candle.decompiler.intermediate.code.CaseIntermediate)1 StatementIntermediate (org.candle.decompiler.intermediate.code.StatementIntermediate)1 Assignment (org.candle.decompiler.intermediate.expression.Assignment)1 Case (org.candle.decompiler.intermediate.expression.Case)1 Cast (org.candle.decompiler.intermediate.expression.Cast)1 ConstantArray (org.candle.decompiler.intermediate.expression.ConstantArray)1 Declaration (org.candle.decompiler.intermediate.expression.Declaration)1