public override void VisitNew(NewExpression newExpr)
{
newExpr.TypeSpecifier.Accept(this);
if (newExpr.TypeSpecifier.NodeType == null)
return;
newExpr.Arguments.Accept(this);
TypeData type = newExpr.TypeSpecifier.NodeType;
try {
ConstructorData constructor =
type.LookupConstructor(newExpr.Arguments);
SetupConstructor(newExpr, constructor.ConstructorInfo, type);
}
catch (LookupMethodException e) {
string ctorInfo =
type.FullName + "::.ctor";
if (newExpr.Arguments.Length > 0) {
ctorInfo += "(";
foreach (ModalExpression arg in newExpr.Arguments) {
if (arg != newExpr.Arguments.First)
ctorInfo += ",";
ctorInfo += arg.NodeType.FullName;
}
ctorInfo += ")";
}
report.Error(newExpr.Location,
"{0} for {1}", e.Message, ctorInfo);
}
}