private SendStatement VisitSend(SendStatement send)
{
if (send == null) return null;
send.channel = this.VisitExpression(send.channel);
send.data = this.VisitExpression(send.data);
if (send.channel == null || send.data == null)
return null;
Chan chanType = send.channel.Type as Chan;
if (chanType == null)
{
// The channel argument must refer to a channel type
this.HandleError(send.channel, Error.ExpectedChannelType);
return null;
}
if (chanType.ChannelType != send.data.Type)
{
// the data argument must match the message type of the channel
this.HandleError(send.data, Error.InvalidMessageType);
return null;
}
return send;
}