本文整理匯總了C#中Mono.CSharp.Constant.TryReduce方法的典型用法代碼示例。如果您正苦於以下問題:C# Constant.TryReduce方法的具體用法?C# Constant.TryReduce怎麽用?C# Constant.TryReduce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.CSharp.Constant
的用法示例。
在下文中一共展示了Constant.TryReduce方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: EnumLiftUp
// at least one of 'left' or 'right' is an enumeration constant (EnumConstant or SideEffectConstant or ...)
// if 'left' is not an enumeration constant, create one from the type of 'right'
Constant EnumLiftUp (ResolveContext ec, Constant left, Constant right, Location loc)
{
switch (oper) {
case Operator.BitwiseOr:
case Operator.BitwiseAnd:
case Operator.ExclusiveOr:
case Operator.Equality:
case Operator.Inequality:
case Operator.LessThan:
case Operator.LessThanOrEqual:
case Operator.GreaterThan:
case Operator.GreaterThanOrEqual:
if (TypeManager.IsEnumType (left.Type))
return left;
if (left.IsZeroInteger)
return left.TryReduce (ec, right.Type, loc);
break;
case Operator.Addition:
case Operator.Subtraction:
return left;
case Operator.Multiply:
case Operator.Division:
case Operator.Modulus:
case Operator.LeftShift:
case Operator.RightShift:
if (TypeManager.IsEnumType (right.Type) || TypeManager.IsEnumType (left.Type))
break;
return left;
}
Error_OperatorCannotBeApplied (ec, this.left, this.right);
return null;
}