Search in sources :

Example 1 with MultiConditional

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

the class MethodIntermediateVisitor method visitIFNONNULL.

@Override
public void visitIFNONNULL(IFNONNULL instruction) {
    Expression left = context.getExpressions().pop();
    Expression right = new NullLiteral(context.getCurrentInstruction());
    MultiConditional conditional = new MultiConditional(context.getCurrentInstruction(), left, right, OperationType.NE);
    BooleanBranchIntermediate line = new BooleanBranchIntermediate(context.getCurrentInstruction(), conditional);
    context.pushIntermediateToInstruction(line);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) BooleanBranchIntermediate(org.candle.decompiler.intermediate.code.BooleanBranchIntermediate) NullLiteral(org.candle.decompiler.intermediate.expression.NullLiteral) MultiConditional(org.candle.decompiler.intermediate.expression.MultiConditional)

Example 2 with MultiConditional

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

the class MethodIntermediateVisitor method processComparator.

protected void processComparator() {
    Expression left = context.getExpressions().pop();
    Expression right = context.getExpressions().pop();
    MultiConditional conditional = new MultiConditional(context.getCurrentInstruction(), left, right, OperationType.EQ);
    BooleanBranchIntermediate line = new BooleanBranchIntermediate(this.context.getCurrentInstruction(), conditional);
    context.pushIntermediateToInstruction(line);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) BooleanBranchIntermediate(org.candle.decompiler.intermediate.code.BooleanBranchIntermediate) MultiConditional(org.candle.decompiler.intermediate.expression.MultiConditional)

Example 3 with MultiConditional

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

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

the class MethodIntermediateVisitor method visitIFNULL.

@Override
public void visitIFNULL(IFNULL instruction) {
    Expression left = context.getExpressions().pop();
    Expression right = new NullLiteral(context.getCurrentInstruction());
    MultiConditional conditional = new MultiConditional(context.getCurrentInstruction(), left, right, OperationType.EQ);
    BooleanBranchIntermediate line = new BooleanBranchIntermediate(context.getCurrentInstruction(), conditional);
    context.pushIntermediateToInstruction(line);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) BooleanBranchIntermediate(org.candle.decompiler.intermediate.code.BooleanBranchIntermediate) NullLiteral(org.candle.decompiler.intermediate.expression.NullLiteral) MultiConditional(org.candle.decompiler.intermediate.expression.MultiConditional)

Example 5 with MultiConditional

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

the class MethodIntermediateVisitor method processMultiConditionalStatement.

public void processMultiConditionalStatement(OperationType operation, Expression left, Expression right) {
    MultiConditional conditional = new MultiConditional(context.getCurrentInstruction(), left, right, operation);
    //context.getExpressions().push(conditional);
    BooleanBranchIntermediate line = new BooleanBranchIntermediate(this.context.getCurrentInstruction(), conditional);
    //check to see whether you need to negate.
    //if the conditional's target is greater than the conditional's next statement, don't negate.
    BranchHandle branchHandle = (BranchHandle) context.getCurrentInstruction();
    int next = branchHandle.getNext().getPosition();
    int target = branchHandle.getTarget().getPosition();
    //Important.  Make sure the expression "true" is pointed towards the lower branch.
    if (target > next) {
        line.getExpression().negate();
    }
    context.pushIntermediateToInstruction(line);
}
Also used : BooleanBranchIntermediate(org.candle.decompiler.intermediate.code.BooleanBranchIntermediate) MultiConditional(org.candle.decompiler.intermediate.expression.MultiConditional)

Aggregations

MultiConditional (org.candle.decompiler.intermediate.expression.MultiConditional)5 BooleanBranchIntermediate (org.candle.decompiler.intermediate.code.BooleanBranchIntermediate)4 Expression (org.candle.decompiler.intermediate.expression.Expression)4 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)4 NullLiteral (org.candle.decompiler.intermediate.expression.NullLiteral)2 Resolved (org.candle.decompiler.intermediate.expression.Resolved)1 Ternary (org.candle.decompiler.intermediate.expression.Ternary)1