Example #1
0
        protected virtual BoundExpression RewriteCompoundAssignmentExpression(BoundCompoundAssignmentExpression node)
        {
            var boundVariableExpression   = new BoundVariableExpression(node.Variable);
            var boundBinaryExpression     = new BoundBinaryExpression(boundVariableExpression, node.Op, node.Expression);
            var boundAssignmentExpression = new BoundAssignmentExpression(node.Variable, boundBinaryExpression);

            return(RewriteAssignmentExpression(boundAssignmentExpression));
        }
Example #2
0
        protected virtual BoundExpression RewriteBinaryExpression(BoundBinaryExpression node)
        {
            var left = RewriteExpression(node.Left);
            var right = RewriteExpression(node.Right);
            if (left == node.Left && right == node.Right)
                return node;

            return new BoundBinaryExpression(left, node.Op, right);
        }
Example #3
0
        private static void WriteBinaryExpression(BoundBinaryExpression node, IndentedTextWriter writer)
        {
            var precedence = SyntaxFacts.GetBinaryOperatorPrecedence(node.Operator.SyntaxKind);

            writer.WriteNestedExpression(precedence, node.Left);
            writer.WriteSpace();
            writer.WritePunctuation(node.Operator.SyntaxKind);
            writer.WriteSpace();
            writer.WriteNestedExpression(precedence, node.Right);
        }