本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.EXPR.isChecked方法的典型用法代码示例。如果您正苦于以下问题:C# EXPR.isChecked方法的具体用法?C# EXPR.isChecked怎么用?C# EXPR.isChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.EXPR
的用法示例。
在下文中一共展示了EXPR.isChecked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateConversion
protected virtual EXPR GenerateConversion(EXPR arg, CType CType, bool bChecked)
{
return GenerateConversionWithSource(Visit(arg), CType, bChecked || arg.isChecked());
}
示例2: GenerateUserDefinedConversion
protected virtual EXPR GenerateUserDefinedConversion(EXPR arg, CType CType, EXPR target, MethWithInst method)
{
// The user-defined explicit conversion from enum? to decimal or decimal? requires
// that we convert the enum? to its nullable underlying CType.
if (isEnumToDecimalConversion(arg.type, CType))
{
// Special case: If we have enum? to decimal? then we need to emit
// a conversion from enum? to its nullable underlying CType first.
// This is unfortunate; we ought to reorganize how conversions are
// represented in the EXPR tree so that this is more transparent.
// converting an enum to its underlying CType never fails, so no need to check it.
CType underlyingType = arg.type.StripNubs().underlyingEnumType();
CType nullableType = GetSymbolLoader().GetTypeManager().GetNullable(underlyingType);
EXPR typeofNubEnum = CreateTypeOf(nullableType);
target = GenerateCall(PREDEFMETH.PM_EXPRESSION_CONVERT, target, typeofNubEnum);
}
// If the methodinfo does not return the target CType AND this is not a lifted conversion
// from one value CType to another, then we need to wrap the whole thing in another conversion,
// e.g. if we have a user-defined conversion from int to S? and we have (S)myint, then we need to generate
// Convert(Convert(myint, typeof(S?), op_implicit), typeof(S))
CType pMethodReturnType = GetSymbolLoader().GetTypeManager().SubstType(method.Meth().RetType,
method.GetType(), method.TypeArgs);
bool fDontLiftReturnType = (pMethodReturnType == CType || (IsNullableValueType(arg.type) && IsNullableValueType(CType)));
EXPR typeofInner = CreateTypeOf(fDontLiftReturnType ? CType : pMethodReturnType);
EXPR methodInfo = GetExprFactory().CreateMethodInfo(method);
PREDEFMETH pdmInner = arg.isChecked() ? PREDEFMETH.PM_EXPRESSION_CONVERTCHECKED_USER_DEFINED : PREDEFMETH.PM_EXPRESSION_CONVERT_USER_DEFINED;
EXPR callUserDefinedConversion = GenerateCall(pdmInner, target, typeofInner, methodInfo);
if (fDontLiftReturnType)
{
return callUserDefinedConversion;
}
PREDEFMETH pdmOuter = arg.isChecked() ? PREDEFMETH.PM_EXPRESSION_CONVERTCHECKED : PREDEFMETH.PM_EXPRESSION_CONVERT;
EXPR typeofOuter = CreateTypeOf(CType);
return GenerateCall(pdmOuter, callUserDefinedConversion, typeofOuter);
}
示例3: GenerateQuestionMarkOperand
protected virtual EXPR GenerateQuestionMarkOperand(EXPR pExpr)
{
Debug.Assert(pExpr != null);
// We must not optimize away compiler-generated reference casts because
// the expression tree API insists that the CType of both sides be identical.
if (pExpr.isCAST())
{
return GenerateConversion(pExpr.asCAST().GetArgument(), pExpr.type, pExpr.isChecked());
}
return Visit(pExpr);
}