Search in sources :

Example 26 with Expression

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

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

the class MethodIntermediateVisitor method visitLRETURN.

public void visitLRETURN(LRETURN 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 28 with Expression

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

the class MethodIntermediateVisitor method visitGETFIELD.

public void visitGETFIELD(GETFIELD instruction) {
    LOG.debug("Getting field..");
    Expression target = context.getExpressions().pop();
    MethodGen mg = context.getMethodGen();
    ConstantPoolGen cpg = mg.getConstantPool();
    FieldAccess ref = new FieldAccess(context.getCurrentInstruction(), target, instruction.getFieldName(cpg));
    context.getExpressions().push(ref);
}
Also used : TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) FieldAccess(org.candle.decompiler.intermediate.expression.FieldAccess)

Example 29 with Expression

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

the class StatementBlock method write.

@Override
public void write(Writer builder) throws IOException {
    final String indent = buildIndent();
    Expression expression = intermediate.getExpression();
    builder.write(indent);
    expression.write(builder);
    builder.write(";");
}
Also used : Expression(org.candle.decompiler.intermediate.expression.Expression)

Example 30 with Expression

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

the class MethodIntermediateVisitor method visitIINC.

public void visitIINC(IINC instruction) {
    //increment variable.
    int index = instruction.getIndex();
    IntermediateVariable iv = context.getVariableResolver().getLocalVariable(index, context.getCurrentInstruction().getPosition());
    Variable variable = null;
    if (iv == null) {
        //generate IV.
        iv = context.getVariableResolver().addLocalVariable(index, context.getCurrentInstruction(), instruction.getType(context.getMethodGen().getConstantPool()));
        variable = new GeneratedVariable(context.getCurrentInstruction(), iv.getType(), iv.getName());
    } else {
        variable = new Variable(context.getCurrentInstruction(), iv.getType(), iv.getName());
    }
    //now, how much does it increment by?
    int incrementBy = instruction.getIncrement();
    StringBuilder incrementerBuilder = new StringBuilder(iv.getName());
    if (incrementBy == 1) {
        incrementerBuilder.append("++");
    } else if (incrementBy == -1) {
        incrementerBuilder.append("--");
    } else if (incrementBy < 1) {
        incrementerBuilder.append(" -= ").append((-1 * incrementBy));
    } else {
        incrementerBuilder.append(" += ").append(incrementBy);
    }
    Expression exp = new Increment(context.getCurrentInstruction(), variable, Type.INT, incrementerBuilder.toString());
    context.pushIntermediateToInstruction(new StatementIntermediate(context.getCurrentInstruction(), exp));
}
Also used : IntermediateVariable(org.candle.decompiler.intermediate.IntermediateVariable) GeneratedVariable(org.candle.decompiler.intermediate.expression.GeneratedVariable) Variable(org.candle.decompiler.intermediate.expression.Variable) IntermediateVariable(org.candle.decompiler.intermediate.IntermediateVariable) GeneratedVariable(org.candle.decompiler.intermediate.expression.GeneratedVariable) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) Increment(org.candle.decompiler.intermediate.expression.Increment) StatementIntermediate(org.candle.decompiler.intermediate.code.StatementIntermediate)

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