Пример #1
0
        private void VisitBinaryArithmetic(BinaryExpression n)
        {
            var lhs = CheckSubTree(n.Left);
            var rhs = CheckSubTree(n.Right);

            if (lhs.IsNumeric && rhs.IsNumeric)
            {
                _lastSeenType = n.InternalType = Supertype(lhs, rhs);
            }
            else if(lhs.CilType == typeof(DateTime) && rhs.CilType == typeof(DateTime))
            {
                _lastSeenType = n.InternalType = new TypeSpan();
            }
            else
            {
                ReportError(n.Location, "Invalid operands for operation {0}. Got types '{1}' and '{2}'.", n.GetType().ToString(), TypeToFriendlyName(lhs), TypeToFriendlyName(rhs));
            }
        }