Beispiel #1
0
        private BoundExpression BindBinaryExpression(BinaryExpressionSyntax syntax)
        {
            var left  = BindExpression(syntax.LeftExpression);
            var right = BindExpression(syntax.RightExpression);

            if (left.Type == TypeSymbol.Error || right.Type == TypeSymbol.Error)
            {
                return(new BoundErrorExpression());
            }

            var boundOperator = BoundBinaryOperator.Bind(syntax.OperatorToken.Kind, left.Type, right.Type);

            if (boundOperator == null)
            {
                _diagnostics.ReportUndefinedBinaryOperator(syntax.OperatorToken.Span, syntax.OperatorToken.Text, left.Type, right.Type);

                return(new BoundErrorExpression());
            }

            return(new BoundBinaryExpression(left, boundOperator, right));
        }
Beispiel #2
0
 public BoundBinaryExpression(BoundExpression left, BoundBinaryOperator @operator, BoundExpression right)
 {
     Left     = left;
     Operator = @operator;
     Right    = right;
 }