Microsoft.Zing.Checker.VisitUnaryExpression C# (CSharp) Méthode

VisitUnaryExpression() public méthode

public VisitUnaryExpression ( UnaryExpression unaryExpression ) : Expression
unaryExpression UnaryExpression
Résultat Expression
        public override Expression VisitUnaryExpression(UnaryExpression unaryExpression)
        {
            if (unaryExpression.NodeType != NodeType.Sizeof)
                return base.VisitUnaryExpression(unaryExpression);

            unaryExpression.Operand = (Expression)this.Visit(unaryExpression.Operand);

            if (unaryExpression.Operand == null)
                return null;

            if (unaryExpression.Operand is Literal)
            {
                // If the operand is a literal, it must be an array type reference
                Literal operand = (Literal)unaryExpression.Operand;

                if (!(operand.Value is ZArray))
                {
                    this.HandleError(unaryExpression.Operand, Error.InvalidSizeofOperand);
                    return null;
                }
            }
            else
            {
                // If the operand is an expression, it must refer to an array, set, or channel.
                TypeNode opndType = unaryExpression.Operand.Type;

                if (!(opndType is ZArray) && !(opndType is Set) && !(opndType is Chan))
                {
                    this.HandleError(unaryExpression.Operand, Error.InvalidSizeofOperand);
                    return null;
                }
            }

            return unaryExpression;
        }