Example #1
0
        public static Boolean Boolean(this IConstExpression expression)
        {
            if (expression.Value == 0)
                return false;
            if (expression.Value == 1)
                return true;

            throw new NotSupportedException($"Cannot convert value {expression.Value} to Boolean.");
        }
Example #2
0
 public void Generate(IConstExpression expression)
 {
     if (expression == null || expression.constValue == null)
     {
         Spit("null");
     }
     else
     {
         var val = expression.constValue;
         Spit(val is string? '"' + val.ToString() + '"' : val.ToString());
     }
 }
Example #3
0
        public static bool Boolean(this IConstExpression expression)
        {
            switch (expression.Value)
            {
            case 0:
                return(false);

            case 1:
                return(true);

            default:
                throw new NotSupportedException($"Cannot convert value {expression.Value} to Boolean.");
            }
        }
Example #4
0
 public static Int32 Int32(this IConstExpression expression)
 {
     return(checked ((Int32)expression.Value));
 }
Example #5
0
 public static int Int32(this IConstExpression expression) => checked ((int)expression.Value);
Example #6
0
 public static short Int16(this IConstExpression expression) => checked ((short)expression.Value);
Example #7
0
 public static GFs GFs(this IConstExpression expression) => checked ((GFs)expression.Value);
Example #8
0
 public static Characters Characters(this IConstExpression expression) => checked ((Characters)expression.Value);
Example #9
0
 public static Cards.ID Cards(this IConstExpression expression) => checked ((Cards.ID)expression.Value);
Example #10
0
 public static byte Byte(this IConstExpression expression) => checked ((byte)expression.Value);
Example #11
0
 public static Int32 Int32(this IConstExpression expression) => checked((Int32)expression.Value);
Example #12
0
 public static Int16 Int16(this IConstExpression expression) => checked((Int16)expression.Value);