use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.
the class SwitchGotoToBreak method transformGotoToBreak.
public void transformGotoToBreak(GoToIntermediate gotoStatement) {
Break breakExpression = new Break(gotoStatement.getInstruction());
StatementIntermediate breakStatement = new StatementIntermediate(gotoStatement.getInstruction(), breakExpression);
igc.getGraph().addVertex(breakStatement);
igc.redirectPredecessors(gotoStatement, breakStatement);
igc.redirectSuccessors(gotoStatement, breakStatement);
igc.getGraph().removeVertex(gotoStatement);
}
use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.
the class LoopGotoToBreak method transformGotoToBreak.
public void transformGotoToBreak(GoToIntermediate gotoStatement) {
Break breakExpression = new Break(gotoStatement.getInstruction());
StatementIntermediate breakStatement = new StatementIntermediate(gotoStatement.getInstruction(), breakExpression);
igc.getGraph().addVertex(breakStatement);
igc.redirectPredecessors(gotoStatement, breakStatement);
igc.redirectSuccessors(gotoStatement, breakStatement);
igc.getGraph().removeVertex(gotoStatement);
}
use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.
the class ArrayForToEnhancedFor method extractExpressionFromGeneratedArrayAssignment.
private Expression extractExpressionFromGeneratedArrayAssignment(AbstractIntermediate declaration) {
if (declaration instanceof StatementIntermediate) {
StatementIntermediate si = (StatementIntermediate) declaration;
Declaration dec = (Declaration) si.getExpression();
return dec.getAssignment().getRightHandSide();
}
return null;
}
use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitINVOKESTATIC.
public void visitINVOKESTATIC(INVOKESTATIC instruction) {
// collect all parameters from the stack.
ConstantPoolGen cpg = context.getMethodGen().getConstantPool();
Type[] types = instruction.getArgumentTypes(context.getMethodGen().getConstantPool());
final List<Expression> parameters = new ArrayList<Expression>(types.length);
for (int i = 0, j = types.length; i < j; i++) {
Expression param = context.getExpressions().pop();
LOG.debug("Parameter: " + param);
parameters.add(param);
}
Resolved resolvedType = new Resolved(context.getCurrentInstruction(), Type.CLASS, instruction.getLoadClassType(cpg).getClassName());
String methodName = instruction.getMethodName(cpg);
// create the expression..
MethodInvocation methodInvocation = new MethodInvocation(context.getCurrentInstruction(), resolvedType, methodName, parameters);
Type returned = instruction.getReturnType(context.getMethodGen().getConstantPool());
if (returned == BasicType.VOID) {
LOG.debug("This is a void return type!!");
StatementIntermediate completeLine = new StatementIntermediate(context.getCurrentInstruction(), methodInvocation);
context.pushIntermediateToInstruction(completeLine);
} else {
context.getExpressions().push(methodInvocation);
}
}
use of org.candle.decompiler.intermediate.code.StatementIntermediate in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitINVOKEINTERFACE.
public void visitINVOKEINTERFACE(INVOKEINTERFACE instruction) {
ConstantPoolGen cpg = context.getMethodGen().getConstantPool();
// collect all parameters from the stack.
Type[] types = instruction.getArgumentTypes(cpg);
final List<Expression> parameters = new ArrayList<Expression>(types.length);
for (int i = 0, j = types.length; i < j; i++) {
Expression param = context.getExpressions().pop();
LOG.debug("Parameter: " + param);
parameters.add(param);
}
// collect the method name we are calling.
String methodName = instruction.getMethodName(context.getMethodGen().getConstantPool());
Expression left = context.getExpressions().pop();
// create the expression..
MethodInvocation methodInvocation = new MethodInvocation(context.getCurrentInstruction(), left, 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);
}
}
Aggregations