本文整理汇总了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;
}
示例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;
}