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(); }
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(); }
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); }
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}]"); }
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); }
public Name GetArrayType(Name elementType, ArrayShape shape) { var sb = elementType.Builder; if (sb == null) { return(default);
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[])); }
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()); }
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); }
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)); } }
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(); }
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()))); }
public string GetArrayType(string elementType, ArrayShape shape) { return(string.Empty); }
public FullTypeName GetArrayType(FullTypeName elementType, ArrayShape shape) { return(elementType); }
// 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;
public DummyTypeInfo GetArrayType(DummyTypeInfo elementType, ArrayShape shape) { return(DummyTypeInfo.Instance); }
public string GetArrayType(string elementType, ArrayShape shape) => elementType + Helpers.ComputeArraySuffix(shape.Rank, multiDim: true);
public string GetArrayType(string elementType, ArrayShape shape) => "";
public bool GetArrayType(bool elementType, ArrayShape shape) => elementType;
public object GetArrayType(object elementType, ArrayShape shape) => null;
public ParameterTypeInfo GetArrayType(ParameterTypeInfo elementType, ArrayShape shape) => ComplexInfo;
public string GetArrayType(string elementType, ArrayShape shape) => elementType + "[" + new string(',', shape.Rank) + "]";
public TypeMetadata GetArrayType(TypeMetadata elementType, ArrayShape shape) { return(ArrayTypeMetadata.CreateArrayFromType(elementType, shape)); }
public Type GetArrayType(Type elementType, ArrayShape shape) { return(elementType.MakeArrayType()); }