File: Microsoft\CSharp\RuntimeBinder\Semantics\BinOpArgInfo.cs
Web Access
Project: src\src\libraries\Microsoft.CSharp\src\Microsoft.CSharp.csproj (Microsoft.CSharp)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Diagnostics;
using Microsoft.CSharp.RuntimeBinder.Syntax;
 
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
    internal readonly partial struct ExpressionBinder
    {
        private sealed class BinOpArgInfo
        {
            public BinOpArgInfo(Expr op1, Expr op2)
            {
                Debug.Assert(op1 != null);
                Debug.Assert(op2 != null);
                arg1 = op1;
                arg2 = op2;
                type1 = arg1.Type;
                type2 = arg2.Type;
                typeRaw1 = type1.StripNubs();
                typeRaw2 = type2.StripNubs();
                pt1 = type1.IsPredefined ? type1.PredefinedType : PredefinedType.PT_COUNT;
                pt2 = type2.IsPredefined ? type2.PredefinedType : PredefinedType.PT_COUNT;
                ptRaw1 = typeRaw1.IsPredefined ? typeRaw1.PredefinedType : PredefinedType.PT_COUNT;
                ptRaw2 = typeRaw2.IsPredefined ? typeRaw2.PredefinedType : PredefinedType.PT_COUNT;
            }
 
            public Expr arg1;
            public Expr arg2;
            public PredefinedType pt1;
            public PredefinedType pt2;
            public PredefinedType ptRaw1;
            public PredefinedType ptRaw2;
            public CType type1;
            public CType type2;
            public CType typeRaw1;
            public CType typeRaw2;
            public BinOpKind binopKind;
            public BinOpMask mask;
 
            public bool ValidForDelegate()
            {
                return (mask & BinOpMask.Delegate) != 0;
            }
 
            public bool ValidForEnumAndUnderlyingType()
            {
                return (mask & BinOpMask.EnumUnder) != 0;
            }
 
            public bool ValidForUnderlyingTypeAndEnum()
            {
                return (mask & BinOpMask.UnderEnum) != 0;
            }
 
            public bool ValidForEnum()
            {
                return (mask & BinOpMask.Enum) != 0;
            }
        }
    }
}