use of org.candle.decompiler.intermediate.expression.NewInstance in project candle-decompiler by bradsdavis.
the class MethodIntermediateVisitor method visitNEW.
// New object instances.
public void visitNEW(NEW instruction) {
ObjectType type = instruction.getLoadClassType(this.context.getMethodGen().getConstantPool());
Type t = instruction.getType(this.context.getMethodGen().getConstantPool());
LOG.debug("New object: " + t + ", " + type);
NewInstance instance = new NewInstance(context.getCurrentInstruction(), type);
context.getExpressions().push(instance);
}
use of org.candle.decompiler.intermediate.expression.NewInstance 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);
}
use of org.candle.decompiler.intermediate.expression.NewInstance in project candle-decompiler by bradsdavis.
the class ExpressionEnhancer method visitStatementIntermediate.
@Override
public void visitStatementIntermediate(StatementIntermediate line) {
Expression exp = line.getExpression();
// ok, now we can visit the expression...
exp.visit(new ASTListener() {
@Override
public void accept(Expression e) {
if (e instanceof NewInstance) {
if (((NewInstance) e).getType() instanceof ObjectType) {
ObjectType obj = (ObjectType) ((NewInstance) e).getType();
if (StringUtils.equals("java.lang.StringBuilder", obj.getClassName())) {
System.out.println(obj.getClassName());
}
}
}
}
});
}
Aggregations