Exemplo n.º 1
0
 static EType LogicalType(EType a, EType b)
 {
     if (a is EInt || b is EInt)
     {
         if (!(a is EInt ai))
         {
             throw new NotSupportedException("Logical expression contains lhs that is non-int");
         }
         if (!(b is EInt bi))
         {
             throw new NotSupportedException("Logical expression contains rhs that is non-int");
         }
         return(new EInt(
                    ai.Signed == bi.Signed && ai.Signed,
                    Math.Max(ai.Width, bi.Width)
                    )
         {
             Runtime = ai.Runtime || bi.Runtime
         });
     }
     if (a is EFloat || b is EFloat)
     {
         if (!(a is EFloat af))
         {
             throw new NotSupportedException("Logical expression contains lhs that is non-float");
         }
         if (!(b is EFloat bf))
         {
             throw new NotSupportedException("Logical expression contains rhs that is non-float");
         }
         return(new EFloat(Math.Max(af.Width, bf.Width))
         {
             Runtime = af.Runtime || bf.Runtime
         });
     }
     throw new NotImplementedException("Logical expression has non-int/non-float type");
 }
Exemplo n.º 2
0
 protected MissingValueException(EType type) => Type = type;
Exemplo n.º 3
0
 public static string GenerateType(EType type) => Core.GenerateType(type);