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);
}
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);
}
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);
}
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(";");
}
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));
}
Aggregations