Beispiel #1
0
        public static IntegerTypeInfo NormalizeInts(ILGeneratorContext context, IntegerTypeInfo lhs, IntegerTypeInfo rhs)
        {
            IntegerWidth width  = lhs.Width > rhs.Width ? lhs.Width : rhs.Width;
            bool         signed = lhs.Signed | rhs.Signed;

            switch (width)
            {
            case IntegerWidth.I8:
                return((IntegerTypeInfo)(signed ? context.Context.GlobalTypes.GetType("sbyte") : context.Context.GlobalTypes.GetType("byte")));

            case IntegerWidth.I16:
                return((IntegerTypeInfo)(signed ? context.Context.GlobalTypes.GetType("short") : context.Context.GlobalTypes.GetType("ushort")));

            case IntegerWidth.I32:
                return((IntegerTypeInfo)(signed ? context.Context.GlobalTypes.GetType("int") : context.Context.GlobalTypes.GetType("uint")));

            case IntegerWidth.I64:
                return((IntegerTypeInfo)(signed ? context.Context.GlobalTypes.GetType("long") : context.Context.GlobalTypes.GetType("ulong")));
            }

            throw new System.InvalidOperationException();
        }
Beispiel #2
0
 public IntegerTypeInfo(string name, TypeKind kind, BinaryReader reader)
     : base(name, kind, reader)
 {
     Width  = (IntegerWidth)reader.ReadInt32();
     Signed = reader.ReadBoolean();
 }
Beispiel #3
0
 public IntegerTypeInfo(string name, IntegerWidth width, bool signed)
     : base(name, TypeKind.Integer)
 {
     Width  = width;
     Signed = signed;
 }