Ejemplo n.º 1
0
 public static int GetSizeOfPrimitiveType( BfsPrimitiveType primitiveType )
 {
     switch (primitiveType.PrimitiveType)
     {
         case BfsPrimitiveTypeEnum.Bool: return 1;
         case BfsPrimitiveTypeEnum.Sbyte: return 1;
         case BfsPrimitiveTypeEnum.Ubyte: return 1;
         case BfsPrimitiveTypeEnum.Short: return 2;
         case BfsPrimitiveTypeEnum.Ushort: return 2;
         case BfsPrimitiveTypeEnum.Int: return 4;
         case BfsPrimitiveTypeEnum.Uint: return 4;
         case BfsPrimitiveTypeEnum.Long: return 4;
         case BfsPrimitiveTypeEnum.Ulong: return 4;
         case BfsPrimitiveTypeEnum.CallExpression:
             BfsCompiler.ReportMessage("Function type...");
             return 1;
     }
     return 1;
 }
Ejemplo n.º 2
0
        private BfsPrimitiveType ConvertPrimitiveType( PegNode node )
        {
            string name = GetNodeText(node);
            BfsPrimitiveType type = new BfsPrimitiveType();
            type.SourceRange = GetSourceRange(node);

            switch (name)
            {
                case "bool": type.PrimitiveType = BfsPrimitiveTypeEnum.Bool; break;
                case "sbyte": type.PrimitiveType = BfsPrimitiveTypeEnum.Sbyte; break;
                case "ubyte": type.PrimitiveType = BfsPrimitiveTypeEnum.Ubyte; break;
                case "short": type.PrimitiveType = BfsPrimitiveTypeEnum.Short; break;
                case "ushort": type.PrimitiveType = BfsPrimitiveTypeEnum.Ushort; break;
                case "int": type.PrimitiveType = BfsPrimitiveTypeEnum.Int; break;
                case "uint": type.PrimitiveType = BfsPrimitiveTypeEnum.Uint; break;
                case "long": type.PrimitiveType = BfsPrimitiveTypeEnum.Long; break;
                case "ulong": type.PrimitiveType = BfsPrimitiveTypeEnum.Ulong; break;
                default: type.PrimitiveType = BfsPrimitiveTypeEnum.Undetermined; break;
            }
            return type;
        }