2008-02-14 Miguel de Icaza <miguel@novell.com>
- * support.cs: Increase the size.
+ * expression.cs: Do not fold BitwiseAnd operators when the left
+ side is a false constant, because we still need to evaluate the
+ right-hand side.
+
+ Fixes #359789
+
+ * support.cs: Instead of throwing an InternalErrorException when
+ the position of the stream is outside the boundary of our buffer,
+ reset the state of the reader, and restart the reading from the
+ beginning of the file.
2008-02-14 Marek Safar <marek.safar@gmail.com>
Constant EnumLiftUp (Constant left, Constant right)
{
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 (left is EnumConstant)
- return left;
-
- if (left.IsZeroInteger)
- return new EnumConstant (left, right.Type);
-
- 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 (right is EnumConstant || left is EnumConstant)
- break;
+ 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 (left is EnumConstant)
return left;
+
+ if (left.IsZeroInteger)
+ return new EnumConstant (left, right.Type);
+
+ 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 (right is EnumConstant || left is EnumConstant)
+ break;
+ return left;
}
Error_OperatorCannotBeApplied ();
return null;
}
-
+
public override Expression DoResolve (EmitContext ec)
{
if (left == null)
}
if (lc != null && lc.IsZeroInteger) {
- return rc is EnumConstant ?
- new EnumConstant (lc, rc.Type):
- lc;
+ if (rc is EnumConstant)
+ return new EnumConstant (lc, rc.Type);
+ Type = TypeManager.bool_type;
+ return this;
}
}
else if (oper == Operator.BitwiseOr) {