public override Expression VisitConstruct(Construct cons)
{
if (cons == null) return cons;
MemberBinding mb = cons.Constructor as MemberBinding;
if (mb == null)
return null;
//
// Verify that mb.BoundMember is a heap-allocated type
//
TypeNode tn = cons.Type;
ZArray arrayNode = tn as ZArray;
if (tn is Set || arrayNode != null || tn is Class || tn is Chan)
{
if (arrayNode != null)
{
ExpressionList el = cons.Operands;
Debug.Assert(el.Count <= 1);
if (arrayNode.Sizes == null)
{
// This is a variable-sized array. Check that there is exactly
// one argument to the constructor of integer type.
if (el.Count == 0)
{
this.HandleError(cons, Error.IntegerExpressionRequired);
return null;
}
Expression e = (Expression)el[0];
if (e.Type != SystemTypes.Int32)
{
this.HandleError(cons, Error.IntegerExpressionRequired);
return null;
}
}
else
{
// This is a constant-sized array. Check that there is no
// argument to the constructor.
if (el.Count == 1)
{
this.HandleError(cons, Error.UnexpectedToken, new string[] { el[0].ToString() });
return null;
}
}
}
return cons;
}
else
{
this.HandleError(cons, Error.ExpectedComplexType);
return null;
}
}