Ejemplo n.º 1
0
        static Meta()
        {
            #region VecTypes

            var vectorTypes = new List <VecType>();
            VecTypeMapArray = new Dictionary <SimpleType, VecType> [5];

            foreach (var n in VecTypeDimensions)
            {
                var typeMap = new Dictionary <SimpleType, VecType>();
                foreach (var ft in VecFieldTypes)
                {
                    var t = new VecType("V" + n + ft.Char)
                    {
                        Len       = n,
                        FieldType = ft,
                        Fields    = VecFields.Take(n).ToArray(),
                    };
                    typeMap[ft] = t;
                    vectorTypes.Add(t);
                }
                VecTypeMapArray[n] = typeMap;
            }

            VecTypes = vectorTypes.ToArray();

            #endregion

            #region MatTypes

            var matrixTypes = new List <MatType>();
            MatTypeMapArray = new Dictionary <SimpleType, MatType> [5, 5];

            foreach (var dim in MatTypeDimensions)
            {
                var typeMap = new Dictionary <SimpleType, MatType>();
                foreach (var ft in MatFieldTypes)
                {
                    var t = new MatType("M" + dim.Rows + dim.Cols + ft.Char)
                    {
                        Rows = dim.Rows, Cols = dim.Cols, FieldType = ft
                    };
                    typeMap[ft] = t;
                    matrixTypes.Add(t);
                }
                MatTypeMapArray[dim.Rows, dim.Cols] = typeMap;
            }

            MatTypes = matrixTypes.ToArray();

            #endregion

            VectorType = new GenericTensorType("Vector")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 1,
                IndexType    = LongType,
                IntIndexType = IntType,
            };

            VectorWithViewType = new GenericTensorType("Vector")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 1,
                IndexType    = LongType,
                IntIndexType = IntType,
            };

            MatrixType = new GenericTensorType("Matrix")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 2,
                IndexType    = VecTypeOf(2, LongType),
                IntIndexType = VecTypeOf(2, IntType),
            };

            MatrixWithViewType = new GenericTensorType("Matrix")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 2,
                IndexType    = VecTypeOf(2, LongType),
                IntIndexType = VecTypeOf(2, IntType),
            };

            VolumeType = new GenericTensorType("Volume")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 3,
                IndexType    = VecTypeOf(3, LongType),
                IntIndexType = VecTypeOf(3, IntType),
            };

            VolumeWithViewType = new GenericTensorType("Volume")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 3,
                IndexType    = VecTypeOf(3, LongType),
                IntIndexType = VecTypeOf(3, IntType),
            };

            Tensor4Type = new GenericTensorType("Tensor4")
            {
                DataType     = TDataType,
                ViewType     = TDataType,
                Dim          = 4,
                IndexType    = VecTypeOf(4, LongType),
                IntIndexType = VecTypeOf(4, IntType),
            };

            Tensor4WithViewType = new GenericTensorType("Tensor4")
            {
                DataType     = TDataType,
                ViewType     = TViewType,
                Dim          = 4,
                IndexType    = VecTypeOf(4, LongType),
                IntIndexType = VecTypeOf(4, IntType),
            };

            GenericTensorTypes = new GenericTensorType[]
            {
                VectorType, VectorWithViewType,
                MatrixType, MatrixWithViewType,
                VolumeType, VolumeWithViewType,
                Tensor4Type, Tensor4WithViewType,
            };

            RangeTypes       = GenerateRangeTypes().ToArray();
            BoxTypes         = GenerateBoxTypes().ToArray();
            RangeAndBoxTypes = RangeTypes.Concat(BoxTypes).ToArray();

            #region ColorTypes

            var colorTypes = new List <ColorType>();
            ColorTypeMapArray = new Dictionary <SimpleType, ColorType> [5];

            foreach (var n in ColorTypeDimensions)
            {
                var typeMap = new Dictionary <SimpleType, ColorType>();
                foreach (var ft in ColorFieldTypes)
                {
                    var t = new ColorType("C" + n + ft.Char)
                    {
                        Len       = n,
                        FieldType = ft,
                        Fields    = ColorFields.Take(n).ToArray(),
                        Channels  = ColorFields.Take(3).ToArray(),
                        HasAlpha  = n == 4,
                        MinValue  = ColorFieldTypeMinValue[ft],
                        MaxValue  = ColorFieldTypeMaxValue[ft],
                    };
                    typeMap[ft] = t;
                    colorTypes.Add(t);
                }
                ColorTypeMapArray[n] = typeMap;
            }

            ColorTypes = colorTypes.ToArray();

            #endregion

            DirectlyCodeableBuiltinTypes = IntegerTypes.Concat(RealTypes).ToArray();

            BuiltInTypes = BoolType.IntoArray()
                           .Concat(DirectlyCodeableBuiltinTypes)
                           .ToArray();

            StandardNumericTypes = IntegerTypes
                                   .Concat(RealTypes)
                                   .ToArray();

            foreach (var t in StandardNumericTypes)
            {
                s_typeNameIdentifierMap[t.Name] = t.Caps;
            }
            foreach (var t in TextTypes)
            {
                s_typeNameIdentifierMap[t.Name.ToLower()] = t.Name;
            }
            s_typeNameIdentifierMap[BoolType.Name] = BoolType.Caps;

            BuiltInNumericTypes = StandardNumericTypes
                                  .Concat(DecimalType.IntoArray())
                                  .ToArray();

            NumericTypes = StandardNumericTypes
                           .Concat(FractionType.IntoArray())
                           .ToArray();

            ComparableTypes = NumericTypes
                              .Concat(TimeTypes)
                              .ToArray();

            StructTypes = BuiltInTypes
                          .Concat(FractionType.IntoArray())
                          .Concat(SystemTypes)
                          .Concat(VecTypes)
                          .Concat(MatTypes)
                          .Concat(ColorTypes)
                          .Concat(RangeAndBoxTypes)
                          .Concat(TrafoTypes)
                          .ToArray();

            DirectlyCodeableTypes = DirectlyCodeableBuiltinTypes
                                    .Concat(FractionType.IntoArray())
                                    .Concat(VecTypes)
                                    .Concat(MatTypes)
                                    .Concat(ColorTypes)
                                    .Concat(RangeAndBoxTypes)
                                    .Concat(TrafoTypes)
                                    .ToArray();
        }