Beispiel #1
0
        private static EmulatedInteger FromOperation(long value, EmulatedInteger i, string operationName)
        {
            try
            {
                EmulatedIntegerOverflowException.OverflowCheck(operationName, value, i.MinValue, i.MaxValue);
            }
            catch (EmulatedIntegerOverflowException ex)
            {
                throw new InvalidOperationException(string.Format("Error performing operator: \"{1}\" on {0} ", i, operationName ?? "?"), ex);
            }

            return(new EmulatedInteger(value, i));
        }
Beispiel #2
0
        private static EmulatedInteger FromOperation(long value, EmulatedInteger a, EmulatedInteger b, string operationName)
        {
            try
            {
                if (!a.isSameType(b))
                {
                    throw CreateTypeClashException(operationName);
                }

                EmulatedIntegerOverflowException.OverflowCheck(operationName, value, a.MinValue, a.MaxValue);
            }
            catch (EmulatedIntegerOverflowException ex)
            {
                throw new InvalidOperationException(string.Format("Error performing operator: {0} {2} {1}: {3}",
                                                                  a, b, operationName ?? "?", ex.Message),
                                                    ex);
            }

            return(new EmulatedInteger(value, a));
        }