ConvertToUnsignedInteger() публичный абстрактный Метод

Pops a value from the stack, converts it to an unsigned integer, then pushes it back onto the stack.
public abstract ConvertToUnsignedInteger ( ) : void
Результат void
Пример #1
0
        /// <summary>
        /// Pops the value on the stack, converts it to an integer, then pushes the integer result
        /// onto the stack.  Large numbers wrap (i.e. 4294967296 -> 0).
        /// </summary>
        /// <param name="generator"> The IL generator. </param>
        /// <param name="fromType"> The type to convert from. </param>
        public static void ToInt32(ILGenerator generator, PrimitiveType fromType)
        {
            // Check that a conversion is actually necessary.
            if (fromType == PrimitiveType.Int32 || fromType == PrimitiveType.UInt32 || fromType == PrimitiveType.Bool)
            {
                return;
            }

            switch (fromType)
            {
            case PrimitiveType.Undefined:
            case PrimitiveType.Null:
                // Converting from undefined or null produces 0.
                generator.Pop();
                generator.LoadInt32(0);
                break;

            case PrimitiveType.Number:
                // Converting from a number produces the number mod 4294967296.  NaN produces 0.
                generator.ConvertToUnsignedInteger();
                break;

            case PrimitiveType.String:
            case PrimitiveType.ConcatenatedString:
            case PrimitiveType.Any:
            case PrimitiveType.Object:
                // Otherwise, fall back to calling TypeConverter.ToInt32()
                generator.Call(ReflectionHelpers.TypeConverter_ToInt32);
                break;

            default:
                throw new NotImplementedException(string.Format("Unsupported primitive type: {0}", fromType));
            }
        }
Пример #2
0
 /// <summary>
 /// Pops the value on the stack, converts it to an unsigned integer, then pushes the
 /// integer result onto the stack.  Large numbers wrap (i.e. 4294967296 -> 0).
 /// </summary>
 /// <param name="generator"> The IL generator. </param>
 /// <param name="fromType"> The type to convert from. </param>
 public static void ToUInt32(ILGenerator generator, PrimitiveType fromType)
 {
     ToInt32(generator, fromType);
     generator.ConvertToUnsignedInteger();
 }
Пример #3
0
        /// <summary>
        /// Pops the value on the stack, converts it to an integer, then pushes the integer result
        /// onto the stack.  Large numbers wrap (i.e. 4294967296 -> 0).
        /// </summary>
        /// <param name="generator"> The IL generator. </param>
        /// <param name="fromType"> The type to convert from. </param>
        public static void ToInt32(ILGenerator generator, PrimitiveType fromType)
        {
            // Check that a conversion is actually necessary.
            if (fromType == PrimitiveType.Int32 || fromType == PrimitiveType.UInt32 || fromType == PrimitiveType.Bool)
                return;

            switch (fromType)
            {
                case PrimitiveType.Undefined:
                case PrimitiveType.Null:
                    // Converting from undefined or null produces 0.
                    generator.Pop();
                    generator.LoadInt32(0);
                    break;

                case PrimitiveType.Number:
                    // Converting from a number produces the number mod 4294967296.  NaN produces 0.
                    generator.ConvertToUnsignedInteger();
                    break;

                case PrimitiveType.String:
                case PrimitiveType.ConcatenatedString:
                case PrimitiveType.Any:
                case PrimitiveType.Object:
                    // Otherwise, fall back to calling TypeConverter.ToInt32()
                    generator.Call(ReflectionHelpers.TypeConverter_ToInt32);
                    break;

                default:
                    throw new NotImplementedException(string.Format("Unsupported primitive type: {0}", fromType));
            }
        }