当前位置: 首页>>代码示例>>C#>>正文


C# CType.isEnumType方法代码示例

本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.isEnumType方法的典型用法代码示例。如果您正苦于以下问题:C# CType.isEnumType方法的具体用法?C# CType.isEnumType怎么用?C# CType.isEnumType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CSharp.RuntimeBinder.Semantics.CType的用法示例。


在下文中一共展示了CType.isEnumType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEnumBinOpType

        private AggregateType GetEnumBinOpType(ExpressionKind ek, CType argType1, CType argType2, out AggregateType ppEnumType)
        {
            Debug.Assert(argType1.isEnumType() || argType2.isEnumType());

            AggregateType type1 = argType1.AsAggregateType();
            AggregateType type2 = argType2.AsAggregateType();

            AggregateType typeEnum = type1.isEnumType() ? type1 : type2;

            Debug.Assert(type1 == typeEnum || type1 == typeEnum.underlyingEnumType());
            Debug.Assert(type2 == typeEnum || type2 == typeEnum.underlyingEnumType());

            AggregateType typeDst = typeEnum;

            switch (ek)
            {
                case ExpressionKind.EK_BITAND:
                case ExpressionKind.EK_BITOR:
                case ExpressionKind.EK_BITXOR:
                    Debug.Assert(type1 == type2);
                    break;

                case ExpressionKind.EK_ADD:
                    Debug.Assert(type1 != type2);
                    break;

                case ExpressionKind.EK_SUB:
                    if (type1 == type2)
                        typeDst = typeEnum.underlyingEnumType();
                    break;

                default:
                    Debug.Assert(ek.isRelational());
                    typeDst = GetReqPDT(PredefinedType.PT_BOOL);
                    break;
            }

            ppEnumType = typeEnum;
            return typeDst;
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:40,代码来源:Operators.cs

示例2: BindIncOpCore

        private EXPR BindIncOpCore(ExpressionKind ek, EXPRFLAG flags, EXPR exprVal, CType type)
        {
            Debug.Assert(ek == ExpressionKind.EK_ADD || ek == ExpressionKind.EK_SUB);
            CONSTVAL cv = new CONSTVAL();
            EXPR pExprResult = null;

            if (type.isEnumType() && type.fundType() > FUNDTYPE.FT_LASTINTEGRAL)
            {
                // This is an error case when enum derives from an illegal type. Just treat it as an int.
                type = GetReqPDT(PredefinedType.PT_INT);
            }

            FUNDTYPE ft = type.fundType();
            CType typeTmp = type;

            switch (ft)
            {
                default:
                    {
                        Debug.Assert(type.isPredefType(PredefinedType.PT_DECIMAL));
                        ek = ek == ExpressionKind.EK_ADD ? ExpressionKind.EK_DECIMALINC : ExpressionKind.EK_DECIMALDEC;
                        PREDEFMETH predefMeth = ek == ExpressionKind.EK_DECIMALINC ? PREDEFMETH.PM_DECIMAL_OPINCREMENT : PREDEFMETH.PM_DECIMAL_OPDECREMENT;
                        pExprResult = CreateUnaryOpForPredefMethodCall(ek, predefMeth, type, exprVal);
                    }
                    break;
                case FUNDTYPE.FT_PTR:
                    cv.iVal = 1;
                    pExprResult = BindPtrBinOp(ek, flags, exprVal, GetExprFactory().CreateConstant(GetReqPDT(PredefinedType.PT_INT), cv));
                    break;
                case FUNDTYPE.FT_I1:
                case FUNDTYPE.FT_I2:
                case FUNDTYPE.FT_U1:
                case FUNDTYPE.FT_U2:
                    typeTmp = GetReqPDT(PredefinedType.PT_INT);
                    cv.iVal = 1;
                    pExprResult = LScalar(ek, flags, exprVal, type, cv, pExprResult, typeTmp);
                    break;
                case FUNDTYPE.FT_I4:
                case FUNDTYPE.FT_U4:
                    cv.iVal = 1;
                    pExprResult = LScalar(ek, flags, exprVal, type, cv, pExprResult, typeTmp);
                    break;
                case FUNDTYPE.FT_I8:
                case FUNDTYPE.FT_U8:
                    cv = GetExprConstants().Create((long)1);
                    pExprResult = LScalar(ek, flags, exprVal, type, cv, pExprResult, typeTmp);
                    break;
                case FUNDTYPE.FT_R4:
                case FUNDTYPE.FT_R8:
                    cv = GetExprConstants().Create(1.0);
                    pExprResult = LScalar(ek, flags, exprVal, type, cv, pExprResult, typeTmp);
                    break;
            }
            Debug.Assert(pExprResult != null);
            Debug.Assert(!pExprResult.type.IsNullableType());
            return pExprResult;
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:57,代码来源:Operators.cs


注:本文中的Microsoft.CSharp.RuntimeBinder.Semantics.CType.isEnumType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。