Пример #1
0
 public Constant DepositBits(Constant newBits, int bitOffset)
 {
     if (bitOffset < 0 || newBits.DataType.BitSize + bitOffset > this.DataType.BitSize)
     {
         throw new ArgumentException();
     }
     if (!newBits.IsValid)
     {
         return(InvalidConstant.Create(this.DataType));
     }
     return(DoDepositBits(newBits, bitOffset));
 }
Пример #2
0
 public static InvalidConstant Create(DataType dt)
 {
     lock (cacheLock)
     {
         if (!cache.TryGetValue(dt, out var ic))
         {
             ic = new InvalidConstant(dt);
             cache.Add(dt, ic);
         }
         return(ic);
     }
 }
Пример #3
0
        public static Constant Create(DataType dt, double value)
        {
            var pt = PrimitiveType.Create(Domain.Real, dt.BitSize);

            switch (dt.BitSize)
            {
            case 16: return(new ConstantReal16(pt, value));

            case 32: return(new ConstantReal32(pt, (float)value));

            case 48: return(new ConstantReal64(pt, value));

            case 64: return(new ConstantReal64(pt, value));
            }
            // Unsupported floating point constant sizes cannot be represented yet.
            return(InvalidConstant.Create(dt));
        }