+ //
+ // During an enum evaluation, none of the rules are valid
+ // Not sure whether it is bug in csc or in documentation
+ //
+ if (ec.InEnumContext){
+ if (left is EnumConstant)
+ left = ((EnumConstant) left).Child;
+
+ if (right is EnumConstant)
+ right = ((EnumConstant) right).Child;
+ } else if (left is EnumConstant && rt == lt) {
+ switch (oper){
+ ///
+ /// E operator |(E x, E y);
+ /// E operator &(E x, E y);
+ /// E operator ^(E x, E y);
+ ///
+ case Binary.Operator.BitwiseOr:
+ case Binary.Operator.BitwiseAnd:
+ case Binary.Operator.ExclusiveOr:
+ return BinaryFold (ec, oper, ((EnumConstant)left).Child,
+ ((EnumConstant)right).Child, loc).TryReduce (ec, lt, loc);
+
+ ///
+ /// U operator -(E x, E y);
+ ///
+ case Binary.Operator.Subtraction:
+ result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc);
+ return result.TryReduce (ec, ((EnumConstant)left).Child.Type, loc);
+
+ ///
+ /// bool operator ==(E x, E y);
+ /// bool operator !=(E x, E y);
+ /// bool operator <(E x, E y);
+ /// bool operator >(E x, E y);
+ /// bool operator <=(E x, E y);
+ /// bool operator >=(E x, E y);
+ ///
+ case Binary.Operator.Equality:
+ case Binary.Operator.Inequality:
+ case Binary.Operator.LessThan:
+ case Binary.Operator.GreaterThan:
+ case Binary.Operator.LessThanOrEqual:
+ case Binary.Operator.GreaterThanOrEqual:
+ return BinaryFold(ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc);
+ }
+ return null;
+ }
+