示例#1
0
 public ArrayType VisitArrayType(ArrayType array)
 {
     Debug.Assert(false, "An array type exists only at runtime. It should be referred to, but never visited.");
     return null;
 }
示例#2
0
 public virtual ArrayType/*!*/ GetArrayType(int rank, bool lowerBoundIsUnknown)
 {
     if(rank > 1 || lowerBoundIsUnknown)
         return this.GetArrayType(rank, 0, 0, new int[0], new int[0]);
     if(this.szArrayTypes == null)
         this.szArrayTypes = new TrivialHashtable();
     ArrayType result = (ArrayType)this.szArrayTypes[rank];
     if(result != null)
         return result;
     lock(this)
     {
         result = (ArrayType)this.szArrayTypes[rank];
         if(result != null)
             return result;
         this.szArrayTypes[rank] = result = new ArrayType(this, 1);
         result.Flags &= ~TypeFlags.VisibilityMask;
         result.Flags |= this.Flags & TypeFlags.VisibilityMask;
         return result;
     }
 }
示例#3
0
 internal ArrayType/*!*/ GetArrayType(int rank, int numSizes, int numLoBounds, int[]/*!*/ sizes, int[]/*!*/ loBounds)
 {
     if(this.arrayTypes == null)
         this.arrayTypes = new TrivialHashtable();
     StringBuilder sb = new StringBuilder(rank * 5);
     for(int i = 0; i < rank; i++)
     {
         if(i < numLoBounds)
             sb.Append(loBounds[i]);
         else
             sb.Append('0');
         if(i < numSizes) { sb.Append(':'); sb.Append(sizes[i]); }
         sb.Append(',');
     }
     Identifier id = Identifier.For(sb.ToString());
     ArrayType result = (ArrayType)this.arrayTypes[id.UniqueIdKey];
     if(result != null)
         return result;
     lock(this)
     {
         result = (ArrayType)this.arrayTypes[id.UniqueIdKey];
         if(result != null)
             return result;
         if(loBounds == null)
             loBounds = new int[0];
         this.arrayTypes[id.UniqueIdKey] = result = new ArrayType(this, rank, sizes, loBounds);
         result.Flags &= ~TypeFlags.VisibilityMask;
         result.Flags |= this.Flags & TypeFlags.VisibilityMask;
         return result;
     }
 }
示例#4
0
 /// <summary>
 /// Gets the array literal in arrayValue coercing TypeNode[] and EnumNode[] as needed.
 /// </summary>
 /// <param name="arrayType">A TypeNode representing the array type</param>
 /// <param name="arrayValue">The value of the array literal to coerce</param>
 /// <returns>An Array object that has been coerced to the appropriate runtime type</returns>
 protected Array GetCoercedArrayLiteral(ArrayType arrayType, Array arrayValue)
 {
     if(arrayType == null)
         return null;
     if(arrayValue == null)
         return null;
     // Multi-dimensional arrays are not legal in attribute instances according section 17.1.3 of the C# 1.0 spec
     if(arrayValue.Rank != 1)
         return null;
     TypeNode elemType = arrayType.ElementType;
     if(elemType.typeCode != ElementType.ValueType && elemType.typeCode != ElementType.Class)
         return arrayValue;
     int arraySize = arrayValue.GetLength(0);
     Type et = elemType.GetRuntimeType();
     if(et == null)
         return null;
     Array val = Array.CreateInstance(et, arraySize);
     for(int i = 0; i < arraySize; i++)
         val.SetValue(this.GetCoercedLiteralValue(elemType, arrayValue.GetValue(i)), i);
     return val;
 }