コード例 #1
0
ファイル: Binder.cs プロジェクト: bradleyjford/brad-lang
        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));
        }
コード例 #2
0
 public BoundBinaryExpression(BoundExpression left, BoundBinaryOperator @operator, BoundExpression right)
 {
     Left     = left;
     Operator = @operator;
     Right    = right;
 }