Search in sources :

Example 1 with ConstructorInvocation

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

the class MethodIntermediateVisitor method visitINVOKESPECIAL.

public void visitINVOKESPECIAL(INVOKESPECIAL instruction) {
    LOG.debug("Invoking special.");
    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);
    }
    // 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());
    MethodInvocation methodInvocation = null;
    // create the expression..
    if (StringUtils.equals(Constants.CONSTRUCTOR_NAME, methodName)) {
        LOG.debug(target.getClass());
        // TODO: Figure out why the dup / new causes issues.
        if (target instanceof NewInstance) {
            // get rid of this.
            context.getExpressions().pop();
        }
        methodInvocation = new ConstructorInvocation(context.getCurrentInstruction(), target, methodName, parameters);
    } else {
        methodInvocation = new MethodInvocation(context.getCurrentInstruction(), target, methodName, parameters);
    }
    LOG.debug("Pushing: " + methodInvocation);
    context.getExpressions().push(methodInvocation);
}
Also used : OperationType(org.candle.decompiler.intermediate.expression.OperationType) ArithmeticType(org.candle.decompiler.intermediate.expression.ArithmeticType) ConstructorInvocation(org.candle.decompiler.intermediate.expression.ConstructorInvocation) TypedExpression(org.candle.decompiler.intermediate.expression.TypedExpression) Expression(org.candle.decompiler.intermediate.expression.Expression) ArrayList(java.util.ArrayList) MethodInvocation(org.candle.decompiler.intermediate.expression.MethodInvocation) NewInstance(org.candle.decompiler.intermediate.expression.NewInstance)

Aggregations

ArrayList (java.util.ArrayList)1 ArithmeticType (org.candle.decompiler.intermediate.expression.ArithmeticType)1 ConstructorInvocation (org.candle.decompiler.intermediate.expression.ConstructorInvocation)1 Expression (org.candle.decompiler.intermediate.expression.Expression)1 MethodInvocation (org.candle.decompiler.intermediate.expression.MethodInvocation)1 NewInstance (org.candle.decompiler.intermediate.expression.NewInstance)1 OperationType (org.candle.decompiler.intermediate.expression.OperationType)1 TypedExpression (org.candle.decompiler.intermediate.expression.TypedExpression)1