本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType.isSimpleType方法的典型用法代码示例。如果您正苦于以下问题:C# AggregateType.isSimpleType方法的具体用法?C# AggregateType.isSimpleType怎么用?C# AggregateType.isSimpleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType
的用法示例。
在下文中一共展示了AggregateType.isSimpleType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: bindExplicitConversionBetweenSimpleTypes
private AggCastResult bindExplicitConversionBetweenSimpleTypes(AggregateType aggTypeDest)
{
// 13.2.1
//
// Because the explicit conversions include all implicit and explicit numeric conversions,
// it is always possible to convert from any numeric-type to any other numeric-type using
// a cast expression (14.6.6).
Debug.Assert(_typeSrc != null);
Debug.Assert(aggTypeDest != null);
if (!_typeSrc.isSimpleType() || !aggTypeDest.isSimpleType())
{
return AggCastResult.Failure;
}
AggregateSymbol aggDest = aggTypeDest.getAggregate();
Debug.Assert(_typeSrc.isPredefined() && aggDest.IsPredefined());
PredefinedType ptSrc = _typeSrc.getPredefType();
PredefinedType ptDest = aggDest.GetPredefType();
Debug.Assert((int)ptSrc < NUM_SIMPLE_TYPES && (int)ptDest < NUM_SIMPLE_TYPES);
ConvKind convertKind = GetConvKind(ptSrc, ptDest);
// Identity and implicit conversions should already have been handled.
Debug.Assert(convertKind != ConvKind.Implicit);
Debug.Assert(convertKind != ConvKind.Identity);
if (convertKind != ConvKind.Explicit)
{
return AggCastResult.Failure;
}
if (_exprSrc.GetConst() != null)
{
// Fold the constant cast if possible.
ConstCastResult result = _binder.bindConstantCast(_exprSrc, _exprTypeDest, _needsExprDest, out _exprDest, true);
if (result == ConstCastResult.Success)
{
return AggCastResult.Success; // else, don't fold and use a regular cast, below.
}
if (result == ConstCastResult.CheckFailure && 0 == (_flags & CONVERTTYPE.CHECKOVERFLOW))
{
return AggCastResult.Abort;
}
}
bool bConversionOk = true;
if (_needsExprDest)
{
// Explicit conversions involving decimals are bound as user-defined conversions.
if (isUserDefinedConversion(ptSrc, ptDest))
{
// According the language, this is a standard conversion, but it is implemented
// through a user-defined conversion. Because it's a standard conversion, we don't
// test the CONVERTTYPE.NOUDC flag here.
bConversionOk = _binder.bindUserDefinedConversion(_exprSrc, _typeSrc, aggTypeDest, _needsExprDest, out _exprDest, false);
}
else
{
_binder.bindSimpleCast(_exprSrc, _exprTypeDest, out _exprDest, (_flags & CONVERTTYPE.CHECKOVERFLOW) != 0 ? EXPRFLAG.EXF_CHECKOVERFLOW : 0);
}
}
return bConversionOk ? AggCastResult.Success : AggCastResult.Failure;
}