use of org.candle.decompiler.intermediate.expression.Expression in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method processInvoke.
public void processInvoke(InvokeInstruction instruction, int nparams) {
//collect all parameters from the stack.
final List<Expression> parameters = new ArrayList<Expression>(nparams);
for (int i = 0; i < nparams; i++) {
Expression param = context.getExpressions().pop();
LOG.debug("Parameter: " + param);
parameters.add(param);
}
//now, get the target that we are calling the method on.
Expression target = context.getExpressions().pop();
//collect the method name we are calling.
String methodName = instruction.getMethodName(context.getMethodGen().getConstantPool());
//create the expression..
MethodInvocation methodInvocation = new MethodInvocation(context.getCurrentInstruction(), target, methodName, parameters);
Type returned = instruction.getReturnType(context.getMethodGen().getConstantPool());
if (returned == BasicType.VOID) {
StatementIntermediate completeLine = new StatementIntermediate(context.getCurrentInstruction(), methodInvocation);
context.pushIntermediateToInstruction(completeLine);
LOG.debug("Pushed complete line: " + completeLine.toString());
} else {
context.getExpressions().push(methodInvocation);
LOG.debug("Pushed expression: " + methodInvocation);
}
}
use of org.candle.decompiler.intermediate.expression.Expression in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitDUP2_X1.
public void visitDUP2_X1(DUP2_X1 instruction) {
Expression one = context.getExpressions().pop();
Expression two = context.getExpressions().pop();
Expression three = context.getExpressions().pop();
//push on 1, 2
context.getExpressions().push(two);
context.getExpressions().push(one);
//push on 1, 2, 3
context.getExpressions().push(three);
context.getExpressions().push(two);
context.getExpressions().push(one);
}
use of org.candle.decompiler.intermediate.expression.Expression 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);
}
use of org.candle.decompiler.intermediate.expression.Expression 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);
}
use of org.candle.decompiler.intermediate.expression.Expression in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitDUP.
//Now provide the suplication visitors
public void visitDUP(DUP instruction) {
Expression exp = context.getExpressions().pop();
try {
Expression dup = (Expression) exp.clone();
dup.setInstructionHandle(context.getCurrentInstruction());
context.getExpressions().push(dup);
context.getExpressions().push(exp);
} catch (CloneNotSupportedException e) {
LOG.error("Exception duplicating expression: " + exp.toString(), e);
}
}
Aggregations