Ejemplo n.º 1
0
        override public void OnMethodInvocationExpression(MethodInvocationExpression node)
        {
            base.OnMethodInvocationExpression(node);

            if (0 == node.Arguments.Count)
            {
                return;
            }

            IMethod target = node.Target.Entity as IMethod;

            if (null == target)
            {
                return;
            }
            IParameter[] parameters = target.GetParameters();
            if (parameters.Length != node.Arguments.Count)
            {
                return;
            }

            for (int i = 0; i < parameters.Length; ++i)
            {
                if (node.Arguments[i].NodeType != NodeType.IntegerLiteralExpression)
                {
                    continue;
                }
                if (!TypeSystemServices.IsPrimitiveNumber(parameters[i].Type))
                {
                    continue;
                }

                AssertLiteralInRange((IntegerLiteralExpression)node.Arguments[i], parameters[i].Type);
            }
        }
Ejemplo n.º 2
0
        override public void OnArrayLiteralExpression(ArrayLiteralExpression node)
        {
            base.OnArrayLiteralExpression(node);

            IType expectedType = GetExpressionType(node).ElementType;

            if (!TypeSystemServices.IsPrimitiveNumber(expectedType))
            {
                return;
            }

            foreach (Expression item in node.Items)
            {
                IType itemType = item.ExpressionType;
                if (item is LiteralExpression)
                {
                    if (item.NodeType == NodeType.IntegerLiteralExpression)
                    {
                        AssertLiteralInRange((IntegerLiteralExpression)item, expectedType);
                    }
                    if (expectedType != itemType)
                    {
                        BindExpressionType(item, expectedType);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        override public void OnArrayLiteralExpression(ArrayLiteralExpression node)
        {
            if (!_checked)
            {
                return;
            }

            base.OnArrayLiteralExpression(node);

            var expectedType = GetExpressionType(node).ElementType;

            if (!TypeSystemServices.IsPrimitiveNumber(expectedType))
            {
                return;
            }

            foreach (var item in node.Items)
            {
                var integerLiteral = item as IntegerLiteralExpression;
                if (integerLiteral != null)
                {
                    AssertLiteralInRange(integerLiteral, expectedType);
                    continue;
                }
            }
        }
Ejemplo n.º 4
0
        override public void OnBinaryExpression(BinaryExpression node)
        {
            base.OnBinaryExpression(node);

            if (node.Operator != BinaryOperatorType.Assign ||
                node.Right.NodeType != NodeType.IntegerLiteralExpression)
            {
                return;
            }

            IType expectedType = GetExpressionType(node.Left);

            if (!TypeSystemServices.IsPrimitiveNumber(expectedType))
            {
                return;
            }

            AssertLiteralInRange((IntegerLiteralExpression)node.Right, expectedType);
        }