public Action <ILNameSyntax> GetArrayType(Action <ILNameSyntax> elementType, ArrayShape shape)
 {
     return(syntax => {
         var syntaxForElementTypes = syntax == ILNameSyntax.SignatureNoNamedTypeParameters ? syntax : ILNameSyntax.Signature;
         elementType(syntaxForElementTypes);
         output.Write('[');
         for (int i = 0; i < shape.Rank; i++)
         {
             if (i > 0)
             {
                 output.Write(", ");
             }
             if (i < shape.LowerBounds.Length || i < shape.Sizes.Length)
             {
                 int lower = 0;
                 if (i < shape.LowerBounds.Length)
                 {
                     lower = shape.LowerBounds[i];
                     output.Write(lower.ToString());
                 }
                 output.Write("...");
                 if (i < shape.Sizes.Length)
                 {
                     output.Write((lower + shape.Sizes[i] - 1).ToString());
                 }
             }
         }
         output.Write(']');
     });
 }
        public virtual MrType GetArrayType(MrType elementType, ArrayShape shape)
        {
            Debug.Assert(false);
            throw new Exception("Not supported yet");
            //var builder = new StringBuilder();

            //builder.Append(elementType);
            //builder.Append('[');

            //for (int i = 0; i < shape.Rank; i++)
            //{
            //    int lowerBound = 0;

            //    if (i < shape.LowerBounds.Length)
            //    {
            //        lowerBound = shape.LowerBounds[i];
            //        builder.Append(lowerBound);
            //    }

            //    builder.Append("...");

            //    if (i < shape.Sizes.Length)
            //    {
            //        builder.Append(lowerBound + shape.Sizes[i] - 1);
            //    }

            //    if (i < shape.Rank - 1)
            //    {
            //        builder.Append(',');
            //    }
            //}

            //builder.Append(']');
            //return builder.ToString();
        }
Ejemplo n.º 3
0
            public virtual LocalVariable GetArrayType(LocalVariable elementType, ArrayShape shape)
            {
                throw new NotSupportedException();
                //var builder = new StringBuilder();

                //builder.Append(elementType);
                //builder.Append('[');

                //for (int i = 0; i < shape.Rank; i++)
                //{
                //    int lowerBound = 0;

                //    if (i < shape.LowerBounds.Length)
                //    {
                //        lowerBound = shape.LowerBounds[i];
                //        builder.Append(lowerBound);
                //    }

                //    builder.Append("...");

                //    if (i < shape.Sizes.Length)
                //    {
                //        builder.Append(lowerBound + shape.Sizes[i] - 1);
                //    }

                //    if (i < shape.Rank - 1)
                //    {
                //        builder.Append(',');
                //    }
                //}

                //builder.Append(']');
                //return builder.ToString();
            }
Ejemplo n.º 4
0
        private TType DecodeArrayType(ref BlobReader blobReader)
        {
            // PERF_TODO: Cache/reuse common case of small number of all-zero lower-bounds.

            TType elementType = DecodeType(ref blobReader);
            int rank = blobReader.ReadCompressedInteger();
            var sizes = ImmutableArray<int>.Empty;
            var lowerBounds = ImmutableArray<int>.Empty;

            int sizesCount = blobReader.ReadCompressedInteger();
            if (sizesCount > 0)
            {
                var builder = ImmutableArray.CreateBuilder<int>(sizesCount);
                for (int i = 0; i < sizesCount; i++)
                {
                    builder.Add(blobReader.ReadCompressedInteger());
                }
                sizes = builder.MoveToImmutable();
            }

            int lowerBoundsCount = blobReader.ReadCompressedInteger();
            if (lowerBoundsCount > 0)
            {
                var builder = ImmutableArray.CreateBuilder<int>(lowerBoundsCount);
                for (int i = 0; i < lowerBoundsCount; i++)
                {
                    builder.Add(blobReader.ReadCompressedSignedInteger());
                }
                lowerBounds = builder.MoveToImmutable();
            }

            var arrayShape = new ArrayShape(rank, sizes, lowerBounds);
            return _provider.GetArrayType(elementType, arrayShape);
        }
Ejemplo n.º 5
0
        public string GetArrayType(string elementType, ArrayShape shape)
        {
            var           ranks = "";
            StringBuilder sb    = shape.Rank > 0 ? new StringBuilder() : null;

            for (int i = 0; i < shape.Rank; i++)
            {
                if (i > 0)
                {
                    sb.Append(", ");
                }

                int lower = 0;
                if (shape.LowerBounds.Length < i)
                {
                    lower = shape.LowerBounds [i];
                    sb.Append(lower);
                }

                sb.Append("...");

                if (i < shape.Sizes.Length)
                {
                    sb.Append(shape.Sizes [i] + lower - 1);
                }
            }

            if (sb != null)
            {
                ranks = sb.ToString();
            }

            return($"{elementType}[{ranks}]");
        }
Ejemplo n.º 6
0
        public CilType GetArrayType(CilType elementType, ArrayShape shape)
        {
            elementType.Append("[");
            for (int i = 0; i < shape.Rank; i++)
            {
                int lowerBound = 0;
                if (i < shape.LowerBounds.Length)
                {
                    lowerBound = shape.LowerBounds[i];
                    elementType.Append(lowerBound.ToString());
                    elementType.Append("...");
                }

                if (i < shape.Sizes.Length)
                {
                    elementType.Append((lowerBound + shape.Sizes[i] - 1).ToString());
                }

                if (i < shape.Rank - 1)
                {
                    elementType.Append(",");
                }
            }
            elementType.Append("]");
            return(elementType);
        }
        public MemberMetadataInfo GetArrayType(MemberMetadataInfo elementType, ArrayShape shape)
        {
            var builder = new StringBuilder("[");

            for (int i = 0; i < shape.Rank; i++)
            {
                int lowerBound = 0;

                if (i < shape.LowerBounds.Length)
                {
                    lowerBound = shape.LowerBounds[i];
                    builder.Append(lowerBound);
                    builder.Append(":");
                }

                if (i < shape.Sizes.Length)
                {
                    builder.Append(lowerBound + shape.Sizes[i] - 1);
                }

                if (i < shape.Rank - 1)
                {
                    builder.Append(',');
                }
            }

            builder.Append(']');
            elementType.ArrayTypeInfo = builder.ToString();
            return(elementType);
        }
Ejemplo n.º 8
0
            public Name GetArrayType(Name elementType, ArrayShape shape)
            {
                var sb = elementType.Builder;

                if (sb == null)
                {
                    return(default);
Ejemplo n.º 9
0
 static ArrayTypeMetadata()
 {
     s_szArrayLowerBounds     = new [] { 0 }.ToImmutableArray();
     s_szArrayShape           = new ArrayShape(rank: 1, sizes: ImmutableArray <int> .Empty, lowerBounds: s_szArrayLowerBounds);
     s_arrayProbeTypeMetadata = (ClassMetadata)LoadedTypes.FromType(typeof(ArrayProbeType));
     s_arrayTypeMetadata      = (DefinedTypeMetadata)LoadedTypes.FromType(typeof(ArrayProbeType[]));
 }
Ejemplo n.º 10
0
        public virtual string GetArrayType(string elementType, ArrayShape shape)
        {
            var builder = new StringBuilder();

            builder.Append(elementType);
            builder.Append('[');

            for (int i = 0; i < shape.Rank; i++)
            {
                int lowerBound = 0;

                if (i < shape.LowerBounds.Length)
                {
                    lowerBound = shape.LowerBounds[i];
                    builder.Append(lowerBound);
                }

                builder.Append("...");

                if (i < shape.Sizes.Length)
                {
                    builder.Append(lowerBound + shape.Sizes[i] - 1);
                }

                if (i < shape.Rank - 1)
                {
                    builder.Append(',');
                }
            }

            builder.Append(']');
            return(builder.ToString());
        }
 public TypeDesc GetArrayType(TypeDesc elementType, ArrayShape shape)
 {
     if (elementType == null)
     {
         return(null);
     }
     return(elementType.MakeArrayType(shape.Rank));
 }
        IrisType ITypeProvider <IrisType> .GetArrayType(IrisType elementType, ArrayShape shape)
        {
            if (shape.Rank != 1)
            {
                return(IrisType.Invalid);
            }

            return(elementType.MakeArrayType());
        }
Ejemplo n.º 13
0
            public AQName GetArrayType(AQName elementType, ArrayShape shape)
            {
                var pooled = PooledStringBuilder.GetInstance();
                var sb     = pooled.Builder;

                sb.Append(elementType.TypeName);
                sb.Append('[');
                if (shape.Rank == 1)
                {
                    sb.Append('*');
                }

                sb.Append(',', shape.Rank - 1);
                sb.Append(']');

                return(elementType.WithTypeName(pooled.ToStringAndFree()));
            }
            public Name GetArrayType(Name elementType, ArrayShape shape)
            {
                var sb = elementType.BuilderOpt;

                if (sb == null)
                {
                    return(default(Name));
                }

                sb.Append('[');

                if (shape.Rank == 1)
                {
                    sb.Append('*');
                }

                sb.Append(',', shape.Rank - 1);

                sb.Append(']');
                return(elementType);
            }
Ejemplo n.º 15
0
        internal ArrayType(TypeReference elementsType, ArrayShape shape) : base(elementsType)
        {
            m_dimensions = new ArrayDimensionCollection(this);
            for (int i = 0; i < shape.Rank; i++)
            {
                int lower = 0, upper = 0;
                if (i < shape.NumSizes)
                {
                    if (i < shape.NumLoBounds)
                    {
                        lower = shape.LoBounds [i];
                        upper = shape.LoBounds [i] + shape.Sizes [i] - 1;
                    }
                    else
                    {
                        upper = shape.Sizes [i] - 1;
                    }
                }

                m_dimensions.Add(new ArrayDimension(lower, upper));
            }
        }
Ejemplo n.º 16
0
        public virtual MrType GetArrayType(MrType elementType, ArrayShape shape)
        {
            var newType = MrType.Clone(elementType, arrayRankOverride: shape.Rank);

            return(newType);

            //var builder = new StringBuilder();

            //builder.Append(elementType);
            //builder.Append('[');

            //for (int i = 0; i < shape.Rank; i++)
            //{
            //    int lowerBound = 0;

            //    if (i < shape.LowerBounds.Length)
            //    {
            //        lowerBound = shape.LowerBounds[i];
            //        builder.Append(lowerBound);
            //    }

            //    builder.Append("...");

            //    if (i < shape.Sizes.Length)
            //    {
            //        builder.Append(lowerBound + shape.Sizes[i] - 1);
            //    }

            //    if (i < shape.Rank - 1)
            //    {
            //        builder.Append(',');
            //    }
            //}

            //builder.Append(']');
            //return builder.ToString();
        }
Ejemplo n.º 17
0
        public NetType GetArrayType(NetType elementType, ArrayShape shape)
        {
            var builder = new StringBuilder();

            var elementTypeKey = elementType.GetKey();

            builder.Append(elementTypeKey.Name);
            builder.Append('[');

            for (var i = 0; i < shape.Rank; i++)
            {
                var lowerBound = 0;

                if (i < shape.LowerBounds.Length)
                {
                    lowerBound = shape.LowerBounds[i];
                    builder.Append(lowerBound);
                }

                builder.Append("...");

                if (i < shape.Sizes.Length)
                {
                    builder.Append(lowerBound + shape.Sizes[i] - 1);
                }

                if (i < shape.Rank - 1)
                {
                    builder.Append(',');
                }
            }

            builder.Append(']');

            return(_factory.CreateTypeModel(new TypeKey(elementType.Namespace, builder.ToString())));
        }
Ejemplo n.º 18
0
 public string GetArrayType(string elementType, ArrayShape shape)
 {
     return(string.Empty);
 }
Ejemplo n.º 19
0
 public FullTypeName GetArrayType(FullTypeName elementType, ArrayShape shape)
 {
     return(elementType);
 }
Ejemplo n.º 20
0
            // These methods are required by the interface, but it is otherwise uninteresting for our purpose here

            public DummyType GetArrayType(DummyType elementType, ArrayShape shape)
            {
                return(DummyType.Instance);
            }
 public EntityHandle GetArrayType(EntityHandle elementType, ArrayShape shape) =>
 elementType;
Ejemplo n.º 22
0
 public DummyTypeInfo GetArrayType(DummyTypeInfo elementType, ArrayShape shape)
 {
     return(DummyTypeInfo.Instance);
 }
Ejemplo n.º 23
0
 public string GetArrayType(string elementType, ArrayShape shape) => elementType + Helpers.ComputeArraySuffix(shape.Rank, multiDim: true);
Ejemplo n.º 24
0
 public string GetArrayType(string elementType, ArrayShape shape) => "";
Ejemplo n.º 25
0
 public bool GetArrayType(bool elementType, ArrayShape shape) => elementType;
Ejemplo n.º 26
0
 public object GetArrayType(object elementType, ArrayShape shape) => null;
Ejemplo n.º 27
0
 public ParameterTypeInfo GetArrayType(ParameterTypeInfo elementType, ArrayShape shape) => ComplexInfo;
Ejemplo n.º 28
0
 public string GetArrayType(string elementType, ArrayShape shape)
 => elementType + "[" + new string(',', shape.Rank) + "]";
Ejemplo n.º 29
0
 public TypeMetadata GetArrayType(TypeMetadata elementType, ArrayShape shape)
 {
     return(ArrayTypeMetadata.CreateArrayFromType(elementType, shape));
 }
Ejemplo n.º 30
0
 public Type GetArrayType(Type elementType, ArrayShape shape)
 {
     return(elementType.MakeArrayType());
 }