Exemple #1
0
        private BoundExpression BindBinaryExpression(BinaryExpressionSyntax syntax)
        {
            var boundLeft  = BindExpression(syntax.Left);
            var boundRight = BindExpression(syntax.Right);

            if (boundLeft.Type == TypeSymbol.Error || boundRight.Type == TypeSymbol.Error)
            {
                return(new BoundErrorExpression());
            }

            var boundOperator = BoundBinaryOperator.Bind(syntax.OperatorToken.Kind, boundLeft.Type, boundRight.Type);

            if (boundOperator == null)
            {
                Diagnostics.ReportUndefinedBinaryOperator(syntax.OperatorToken.Span, syntax.OperatorToken.Text, boundLeft.Type, boundRight.Type);
                return(new BoundErrorExpression());
            }

            return(new BoundBinaryExpression(boundLeft, boundOperator, boundRight));
        }
Exemple #2
0
 public BoundBinaryExpression(BoundExpression left, BoundBinaryOperator op, BoundExpression right)
 {
     Left  = left;
     Op    = op;
     Right = right;
 }