public override void VisitBinaryExpression(Ast.Expressions.BinaryExpression node)
 {
     if (node.IsAssignmentExpression && node.Left.CodeNodeType == CodeNodeType.VariableReferenceExpression)
     {
         RemoveVariable((node.Left as VariableReferenceExpression).Variable.Resolve());
     }
     base.VisitBinaryExpression(node);
 }
Exemple #2
0
        public override void VisitBinaryExpression(Ast.Expressions.BinaryExpression node)
        {
            base.VisitBinaryExpression(node);

            if (node.IsAssignmentExpression && node.Left.HasType && !(node.Right is LiteralExpression) && node.Right.HasType &&
                ShouldAddCastToAssignment(node.Left.ExpressionType, node.Right.ExpressionType))
            {
                Expression toCast = node.Right;

                if (node.Right is ExplicitCastExpression)
                {
                    ExplicitCastExpression rightCast = node.Right as ExplicitCastExpression;
                    if (IsIntegerType(rightCast.TargetType))
                    {
                        toCast = rightCast.Expression;
                    }
                }

                node.Right = new ExplicitCastExpression(toCast, node.Left.ExpressionType, null);
            }
        }