示例#1
0
        /// <summary>
        /// Create a constant Zen integer value.
        /// </summary>
        /// <typeparam name="T">The integer gype.</typeparam>
        /// <param name="value">The Zen integer value.</param>
        /// <returns>A long.</returns>
        public static Zen <T> CreateConstantValue <T>(long value)
        {
            var type = typeof(T);

            if (type == ReflectionUtilities.BoolType)
            {
                return((Zen <T>)(object)(value == 0L ? Language.False() : Language.True()));
            }
            if (type == ReflectionUtilities.ByteType)
            {
                return((Zen <T>)(object) ZenConstantByteExpr.Create((byte)value));
            }
            if (type == ReflectionUtilities.ShortType)
            {
                return((Zen <T>)(object) ZenConstantShortExpr.Create((short)value));
            }
            if (type == ReflectionUtilities.UshortType)
            {
                return((Zen <T>)(object) ZenConstantUshortExpr.Create((ushort)value));
            }
            if (type == ReflectionUtilities.IntType)
            {
                return((Zen <T>)(object) ZenConstantIntExpr.Create((int)value));
            }
            if (type == ReflectionUtilities.UintType)
            {
                return((Zen <T>)(object) ZenConstantUintExpr.Create((uint)value));
            }
            if (type == ReflectionUtilities.LongType)
            {
                return((Zen <T>)(object) ZenConstantLongExpr.Create(value));
            }

            return((Zen <T>)(object) ZenConstantUlongExpr.Create((ulong)value));
        }
示例#2
0
        public static Zen <ushort> Create(ushort value)
        {
            if (hashConsTable.TryGetValue(value, out var v))
            {
                return(v);
            }

            var ret = new ZenConstantUshortExpr(value);

            hashConsTable[value] = ret;
            return(ret);
        }