/// <summary> /// Compares two ranges for equality /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <returns></returns> public override bool CompareForEquality(IValue left, IValue right) { bool retVal = false; left = derefEnum(left); right = derefEnum(right); IntValue int1 = left as IntValue; IntValue int2 = right as IntValue; if (int1 != null && int2 != null) { retVal = (int1.Val == int2.Val); } else { DoubleValue double1 = left as DoubleValue; DoubleValue double2 = right as DoubleValue; if (double1 != null && double2 != null) { retVal = DoubleType.CompareDoubleForEquality(double1.Val, double2.Val); ; } else { retVal = base.CompareForEquality(left, right); } } return(retVal); }
/// <summary> /// Indicates that binary operation is valid for this type and the other type /// </summary> /// <param name="otherType"></param> /// <returns></returns> public override bool ValidBinaryOperation(BinaryExpression.Operator operation, Type otherType) { bool retVal = base.ValidBinaryOperation(operation, otherType); if (!retVal) { if (operation == BinaryExpression.Operator.Add || operation == BinaryExpression.Operator.Div || operation == BinaryExpression.Operator.Mult || operation == BinaryExpression.Operator.Sub) { // Allow implicit conversions IntegerType integerType = otherType as IntegerType; if (integerType != null) { retVal = true; } else { DoubleType doubleType = otherType as DoubleType; retVal = (doubleType != null); } } } return(retVal); }