Пример #1
0
        private void ScanArrayType(QueuedArrayType aType, EcmaCil.ArrayTypeMeta arrayTypeMeta)
        {
            arrayTypeMeta.Dimensions = aType.ArrayType.Dimensions.Count;
// todo: fix?
            foreach (ArrayDimension xDimension in aType.ArrayType.Dimensions)
            {
                if (xDimension.LowerBound != 0 || xDimension.UpperBound != 0)
                {
                    throw new Exception("Arrays with limited dimensions not supported");
                }
            }


#if DEBUG
            var xSB = new StringBuilder();
            xSB.Append(arrayTypeMeta.ElementType.ToString());
            xSB.Append("[");
            xSB.Append(new String(',', arrayTypeMeta.Dimensions - 1));
            xSB.Append("]");
            arrayTypeMeta.Data[EcmaCil.DataIds.DebugMetaId] = xSB.ToString();
#endif
        }
Пример #2
0
        private EcmaCil.TypeMeta EnqueueType(TypeReference aTypeRef, object aSource, string aSourceType)
        {
            if (mLogEnabled)
            {
                LogMapPoint(aSource, aSourceType, aTypeRef);
            }
            List <TypeReference> xTypeArgs = null;
            TypeDefinition       xTypeDef;

            var xArrayType = aTypeRef as ArrayType;

            if (xArrayType != null)
            {
                var xQueuedArrayType = new QueuedArrayType(xArrayType);
                EcmaCil.ArrayTypeMeta xArrayMeta;
                if (mArrayTypes.TryGetValue(xQueuedArrayType, out xArrayMeta))
                {
                    return(xArrayMeta);
                }
                var xElemMeta = EnqueueType(xQueuedArrayType.ArrayType.ElementType, aTypeRef, "Array element type");
                xArrayMeta = new EcmaCil.ArrayTypeMeta {
                    ElementType = xElemMeta
                };
                mArrayTypes.Add(xQueuedArrayType, xArrayMeta);
                mQueue.Enqueue(xQueuedArrayType);
                return(xArrayMeta);
            }
            var xPointerType = aTypeRef as PointerType;

            if (xPointerType != null)
            {
                var xQueuedPointerType = new QueuedPointerType(xPointerType);
                EcmaCil.PointerTypeMeta xPointerMeta;
                if (mPointerTypes.TryGetValue(xQueuedPointerType, out xPointerMeta))
                {
                    return(xPointerMeta);
                }
                var xElemMeta = EnqueueType(xQueuedPointerType.PointerType.ElementType, aTypeRef, "Array element type");
                xPointerMeta = new EcmaCil.PointerTypeMeta {
                    ElementType = xElemMeta
                };
                mPointerTypes.Add(xQueuedPointerType, xPointerMeta);
                mQueue.Enqueue(xQueuedPointerType);
                return(xPointerMeta);
            }
            var xGenSpec = aTypeRef as GenericInstanceType;

            if (xGenSpec != null)
            {
                xTypeDef  = ResolveType(xGenSpec.ElementType);
                xTypeArgs = new List <TypeReference>();
                foreach (TypeReference xArg in xGenSpec.GenericArguments)
                {
                    xTypeArgs.Add(xArg);
                }
            }
            else
            {
                xTypeDef = ResolveType(aTypeRef);
            }
            var xQueuedType = new QueuedType(xTypeDef, (xTypeArgs == null ? null : xTypeArgs.ToArray()));

            EcmaCil.TypeMeta xTypeMeta;
            if (mTypes.TryGetValue(xQueuedType, out xTypeMeta))
            {
                return(xTypeMeta);
            }
            xTypeMeta = new EcmaCil.TypeMeta();
            if (xTypeDef.BaseType != null)
            {
                xTypeMeta.BaseType = EnqueueType(xTypeDef.BaseType, aTypeRef, "Base type");
            }
            mTypes.Add(xQueuedType, xTypeMeta);
            mQueue.Enqueue(xQueuedType);
            return(xTypeMeta);
        }