private void LeaveAddressOf(UnaryExpression node)
{
IType dataType = GetExpressionType(node.Operand);
if (dataType.IsArray) //if array reference take address of first element
{
dataType = dataType.ElementType;
node.Replace(node.Operand, new SlicingExpression(node.Operand, new IntegerLiteralExpression(0)));
BindExpressionType(node.Operand, dataType);
}
if (TypeSystemServices.IsPointerCompatible(dataType))
{
node.Entity = dataType.MakePointerType();
BindExpressionType(node, dataType.MakePointerType());
return;
}
BindExpressionType(node, TypeSystemServices.ErrorEntity);
Error(CompilerErrorFactory.PointerIncompatibleType(node.Operand, dataType));
}