Пример #1
0
 public static Bool3 CompareGe_Un(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         return((ulong)a.Value >= (ulong)b.Value ? Bool3.True : Bool3.False);
     }
     if (a.HasValue(ulong.MaxValue))
     {
         return(Bool3.True);                     // max >= x => true
     }
     if (b.HasValue(ulong.MinValue))
     {
         return(Bool3.True);                     // x >= min => true
     }
     return(Bool3.Unknown);
 }
Пример #2
0
 public static Bool3 CompareNeq(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         return(a.Value != b.Value ? Bool3.True : Bool3.False);
     }
     if (ReferenceEquals(a, b))
     {
         return(Bool3.False);
     }
     if (((ulong)a.Value & a.ValidMask & b.ValidMask) != ((ulong)b.Value & a.ValidMask & b.ValidMask))
     {
         return(Bool3.True);
     }
     return(Bool3.Unknown);
 }
Пример #3
0
 public static Bool3 CompareGt(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         return(a.Value > b.Value ? Bool3.True : Bool3.False);
     }
     if (a.HasValue(long.MinValue))
     {
         return(Bool3.False);                    // min > x => false
     }
     if (b.HasValue(long.MaxValue))
     {
         return(Bool3.False);                    // x > max => false
     }
     return(Bool3.Unknown);
 }
Пример #4
0
 public static Bool3 CompareLe(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         return(a.Value <= b.Value ? Bool3.True : Bool3.False);
     }
     if (a.HasValue(long.MinValue))
     {
         return(Bool3.True);                     // min <= x => true
     }
     if (b.HasValue(long.MaxValue))
     {
         return(Bool3.True);                     // x <= max => true
     }
     return(Bool3.Unknown);
 }
Пример #5
0
 public static Int64Value Rem_Un(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         try {
             return(new Int64Value((long)((ulong)a.Value % (ulong)b.Value)));
         }
         catch (ArithmeticException) {
             return(CreateUnknown());
         }
     }
     if ((ReferenceEquals(a, b) && a.IsNonZero()) || b.HasValue(1))
     {
         return(Zero);
     }
     return(CreateUnknown());
 }
Пример #6
0
 public static Int64Value Mul(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         return(new Int64Value(a.Value * b.Value));
     }
     if (a.IsZero() || b.IsZero())
     {
         return(Zero);
     }
     if (a.HasValue(1))
     {
         return(b);
     }
     if (b.HasValue(1))
     {
         return(a);
     }
     return(CreateUnknown());
 }
Пример #7
0
 public static Int64Value Div(Int64Value a, Int64Value b)
 {
     if (a.AllBitsValid() && b.AllBitsValid())
     {
         try {
             return(new Int64Value(a.Value / b.Value));
         }
         catch (ArithmeticException) {
             return(CreateUnknown());
         }
     }
     if (ReferenceEquals(a, b) && a.IsNonZero())
     {
         return(One);
     }
     if (b.HasValue(1))
     {
         return(a);
     }
     return(CreateUnknown());
 }
Пример #8
0
		public static Bool3 CompareFalse(Int64Value a) {
			if (a.AllBitsValid())
				return a.Value == 0 ? Bool3.True : Bool3.False;
			if (((ulong)a.Value & a.ValidMask) != 0)
				return Bool3.False;
			return Bool3.Unknown;
		}
Пример #9
0
		public static Bool3 CompareLt_Un(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return (ulong)a.Value < (ulong)b.Value ? Bool3.True : Bool3.False;
			if (a.HasValue(ulong.MaxValue))
				return Bool3.False;	// max < x => false
			if (b.HasValue(ulong.MinValue))
				return Bool3.False;	// x < min => false
			return Bool3.Unknown;
		}
Пример #10
0
		public static Bool3 CompareLe_Un(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return (ulong)a.Value <= (ulong)b.Value ? Bool3.True : Bool3.False;
			if (a.HasValue(ulong.MinValue))
				return Bool3.True;	// min <= x => true
			if (b.HasValue(ulong.MaxValue))
				return Bool3.True;	// x <= max => true
			return Bool3.Unknown;
		}
Пример #11
0
		public static Bool3 CompareGe(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return a.Value >= b.Value ? Bool3.True : Bool3.False;
			if (a.HasValue(long.MaxValue))
				return Bool3.True;	// max >= x => true
			if (b.HasValue(long.MinValue))
				return Bool3.True;	// x >= min => true
			return Bool3.Unknown;
		}
Пример #12
0
		public static Bool3 CompareGt(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return a.Value > b.Value ? Bool3.True : Bool3.False;
			if (a.HasValue(long.MinValue))
				return Bool3.False;	// min > x => false
			if (b.HasValue(long.MaxValue))
				return Bool3.False;	// x > max => false
			return Bool3.Unknown;
		}
Пример #13
0
		public static Int64Value Add(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return new Int64Value(a.Value + b.Value);
			if (ReferenceEquals(a, b))
				return new Int64Value(a.Value << 1, (a.ValidMask << 1) | 1);
			return CreateUnknown();
		}
Пример #14
0
		public static Int64Value Mul_Ovf_Un(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid()) {
				ulong aa = (ulong)a.Value, bb = (ulong)b.Value;
				try {
					return new Int64Value((long)checked(aa * bb));
				}
				catch (OverflowException) {
				}
			}
			return CreateUnknown();
		}
Пример #15
0
		public static Int64Value Mul_Ovf(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid()) {
				try {
					return new Int64Value(checked(a.Value * b.Value));
				}
				catch (OverflowException) {
				}
			}
			return CreateUnknown();
		}
Пример #16
0
		public static Real8Value Conv_R_Un(Int64Value a) {
			if (a.AllBitsValid())
				return new Real8Value((float)(ulong)a.Value);
			return Real8Value.CreateUnknown();
		}
Пример #17
0
		public static Int64Value Rem_Un(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid()) {
				try {
					return new Int64Value((long)((ulong)a.Value % (ulong)b.Value));
				}
				catch (ArithmeticException) {
					return CreateUnknown();
				}
			}
			if ((ReferenceEquals(a, b) && a.IsNonZero()) || b.HasValue(1))
				return Zero;
			return CreateUnknown();
		}
Пример #18
0
		public static Int64Value Div(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid()) {
				try {
					return new Int64Value(a.Value / b.Value);
				}
				catch (ArithmeticException) {
					return CreateUnknown();
				}
			}
			if (ReferenceEquals(a, b) && a.IsNonZero())
				return One;
			if (b.HasValue(1))
				return a;
			return CreateUnknown();
		}
Пример #19
0
		public static Int64Value Mul(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return new Int64Value(a.Value * b.Value);
			if (a.IsZero() || b.IsZero())
				return Zero;
			if (a.HasValue(1))
				return b;
			if (b.HasValue(1))
				return a;
			return CreateUnknown();
		}
Пример #20
0
		public static Int64Value Sub(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return new Int64Value(a.Value - b.Value);
			if (ReferenceEquals(a, b))
				return Zero;
			return CreateUnknown();
		}
Пример #21
0
		public static Bool3 CompareNeq(Int64Value a, Int64Value b) {
			if (a.AllBitsValid() && b.AllBitsValid())
				return a.Value != b.Value ? Bool3.True : Bool3.False;
			if (ReferenceEquals(a, b))
				return Bool3.False;
			if (((ulong)a.Value & a.ValidMask & b.ValidMask) != ((ulong)b.Value & a.ValidMask & b.ValidMask))
				return Bool3.True;
			return Bool3.Unknown;
		}
Пример #22
0
		public static Int64Value Neg(Int64Value a) {
			if (a.AllBitsValid())
				return new Int64Value(-a.Value);
			return CreateUnknown();
		}
Пример #23
0
		public static Real8Value Conv_R8(Int64Value a) {
			if (a.AllBitsValid())
				return new Real8Value((double)(long)a.Value);
			return Real8Value.CreateUnknown();
		}