Ejemplo n.º 1
0
        static uint GetTypeAlign(ParserTargetInfo target, ParserIntType type)
        {
            switch (type)
            {
            case ParserIntType.SignedChar:
            case ParserIntType.UnsignedChar:
                return(target.CharAlign);

            case ParserIntType.SignedShort:
            case ParserIntType.UnsignedShort:
                return(target.ShortAlign);

            case ParserIntType.SignedInt:
            case ParserIntType.UnsignedInt:
                return(target.IntAlign);

            case ParserIntType.SignedLong:
            case ParserIntType.UnsignedLong:
                return(target.LongAlign);

            case ParserIntType.SignedLongLong:
            case ParserIntType.UnsignedLongLong:
                return(target.LongLongAlign);

            default:
                throw new Exception("Type has no alignment");
            }
        }
Ejemplo n.º 2
0
        static uint GetTypeSize(ParserTargetInfo target, ParserIntType type)
        {
            switch (type)
            {
            case ParserIntType.SignedChar:
            case ParserIntType.UnsignedChar:
                return(target.CharWidth);

            case ParserIntType.SignedShort:
            case ParserIntType.UnsignedShort:
                return(target.ShortWidth);

            case ParserIntType.SignedInt:
            case ParserIntType.UnsignedInt:
                return(target.IntWidth);

            case ParserIntType.SignedLong:
            case ParserIntType.UnsignedLong:
                return(target.LongWidth);

            case ParserIntType.SignedLongLong:
            case ParserIntType.UnsignedLongLong:
                return(target.LongLongWidth);

            default:
                throw new Exception("Type has no size");
            }
        }
        public static bool IsSigned(this ParserIntType intType)
        {
            switch (intType)
            {
            case ParserIntType.SignedChar:
            case ParserIntType.SignedShort:
            case ParserIntType.SignedInt:
            case ParserIntType.SignedLong:
            case ParserIntType.SignedLongLong:
                return(true);

            default:
                return(false);
            }
        }
 static uint GetTypeSize(ParserTargetInfo target, ParserIntType type)
 {
     switch (type)
     {
         case ParserIntType.SignedChar:
         case ParserIntType.UnsignedChar:
             return target.CharWidth;
         case ParserIntType.SignedShort:
         case ParserIntType.UnsignedShort:
             return target.ShortWidth;
         case ParserIntType.SignedInt:
         case ParserIntType.UnsignedInt:
             return target.IntWidth;
         case ParserIntType.SignedLong:
         case ParserIntType.UnsignedLong:
             return target.LongWidth;
         case ParserIntType.SignedLongLong:
         case ParserIntType.UnsignedLongLong:
             return target.LongLongWidth;
         default:
             throw new Exception("Type has no size");
     }
 }
 static uint GetTypeAlign(ParserTargetInfo target, ParserIntType type)
 {
     switch (type)
     {
         case ParserIntType.SignedChar:
         case ParserIntType.UnsignedChar:
             return target.CharAlign;
         case ParserIntType.SignedShort:
         case ParserIntType.UnsignedShort:
             return target.ShortAlign;
         case ParserIntType.SignedInt:
         case ParserIntType.UnsignedInt:
             return target.IntAlign;
         case ParserIntType.SignedLong:
         case ParserIntType.UnsignedLong:
             return target.LongAlign;
         case ParserIntType.SignedLongLong:
         case ParserIntType.UnsignedLongLong:
             return target.LongLongAlign;
         default:
             throw new Exception("Type has no alignment");
     }
 }