@Override
public void visit(InstantiationExpression instantiationExpression) {
Type type = instantiationExpression.getType();
methodByteCodeContext.incIndent("new ", type.getName(), "()");
methodByteCodeContext.addInstruction(new TypeInsnNode(NEW, type.getClassIdentifier()), "new ", type.getName(), "()");
methodByteCodeContext.dup("for constructor call");
Method constructor = type.getConstructor(instantiationExpression.getParameters().size());
if (constructor == null) {
throw new RuntimeException(
"can't find constructor with "
+ instantiationExpression.getParameters().size() + " parameters in "
+ type);
}
loadParameters("<init>", constructor, instantiationExpression.getParameters());
methodByteCodeContext.addInstruction(new MethodInsnNode(INVOKESPECIAL, type.getClassIdentifier(), "<init>", constructor.getSignature()), "new ", type.getName(), "(...)");
lastExpressionType = type;
methodByteCodeContext.decIndent();
}