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."); }
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()); } }
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."); } }
public static Int32 Int32(this IConstExpression expression) { return(checked ((Int32)expression.Value)); }
public static int Int32(this IConstExpression expression) => checked ((int)expression.Value);
public static short Int16(this IConstExpression expression) => checked ((short)expression.Value);
public static GFs GFs(this IConstExpression expression) => checked ((GFs)expression.Value);
public static Characters Characters(this IConstExpression expression) => checked ((Characters)expression.Value);
public static Cards.ID Cards(this IConstExpression expression) => checked ((Cards.ID)expression.Value);
public static byte Byte(this IConstExpression expression) => checked ((byte)expression.Value);
public static Int32 Int32(this IConstExpression expression) => checked((Int32)expression.Value);
public static Int16 Int16(this IConstExpression expression) => checked((Int16)expression.Value);