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