public static OrderedLiteralBase BitRightShift(OrderedLiteralBase a, OrderedLiteralBase b) { (a, b) = LiftToCommonType(a, b); if (a.GetType() != b.GetType()) { throw new ApplicationException($"{a.GetType()} != {b.GetType()}"); } switch (a) { case CharLiteral charLiteralA when b is CharLiteral charLiteralB: return(IntegerLiteral.From(charLiteralA.Value >> charLiteralB.Value)); case FloatLiteral _ when b is FloatLiteral: return(null); case IntegerLiteral integerLiteralA when b is IntegerLiteral integerLiteralB: return(IntegerLiteral.BitRightShift(integerLiteralA, integerLiteralB)); default: throw new ArgumentOutOfRangeException(nameof(a)); } }
public static OrderedLiteralBase operator %(OrderedLiteralBase a, OrderedLiteralBase b) { (a, b) = LiftToCommonType(a, b); if (a.GetType() != b.GetType()) { throw new ApplicationException($"{a.GetType()} != {b.GetType()}"); } switch (a) { case CharLiteral charLiteralA when b is CharLiteral charLiteralB: return(IntegerLiteral.From(charLiteralA.Value % charLiteralB.Value)); case FloatLiteral floatLiteralA when b is FloatLiteral floatLiteralB: return(new FloatLiteral(floatLiteralA.Value % floatLiteralB.Value)); case IntegerLiteral integerLiteralA when b is IntegerLiteral integerLiteralB: return(integerLiteralA % integerLiteralB); default: throw new ArgumentOutOfRangeException(nameof(a)); } }