Example #1
0
        internal override TypeSymbol GetMDArrayTypeSymbol(PEModuleSymbol moduleSymbol, int rank, TypeSymbol elementType, ImmutableArray <ModifierInfo <TypeSymbol> > customModifiers,
                                                          ImmutableArray <int> sizes, ImmutableArray <int> lowerBounds)
        {
            if (elementType is UnsupportedMetadataTypeSymbol)
            {
                return(elementType);
            }

            return(ArrayTypeSymbol.CreateMDArray(moduleSymbol.ContainingAssembly, CreateType(elementType, customModifiers), rank, sizes, lowerBounds));
        }
            public override Symbol VisitArrayType(ArrayTypeSymbol symbol)
            {
                var translatedElementType = (TypeSymbol)this.Visit(symbol.ElementType);
                var translatedModifiers   = VisitCustomModifiers(symbol.CustomModifiers);

                if (symbol.IsSZArray)
                {
                    return(ArrayTypeSymbol.CreateSZArray(symbol.BaseTypeNoUseSiteDiagnostics.ContainingAssembly, translatedElementType, translatedModifiers));
                }

                return(ArrayTypeSymbol.CreateMDArray(symbol.BaseTypeNoUseSiteDiagnostics.ContainingAssembly, translatedElementType, symbol.Rank, symbol.Sizes, symbol.LowerBounds, translatedModifiers));
            }
Example #3
0
        private ArrayTypeSymbol DecodeArrayType(ArrayTypeSymbol type)
        {
            var decodedElementType = DecodeType(type.ElementType);

            return(ReferenceEquals(decodedElementType, type)
                ? type
                : type.IsSZArray
                    ? ArrayTypeSymbol.CreateSZArray(_containingAssembly,
                                                    decodedElementType,
                                                    type.CustomModifiers)
                    : ArrayTypeSymbol.CreateMDArray(_containingAssembly,
                                                    decodedElementType,
                                                    type.Rank,
                                                    type.Sizes,
                                                    type.LowerBounds,
                                                    type.CustomModifiers));
        }
            public override Symbol VisitArrayType(ArrayTypeSymbol symbol)
            {
                var otherElementType = (TypeSymbol)this.Visit(symbol.ElementType);

                if ((object)otherElementType == null)
                {
                    // For a newly added type, there is no match in the previous generation, so it could be null.
                    return(null);
                }
                var otherModifiers = VisitCustomModifiers(symbol.CustomModifiers);

                if (symbol.IsSZArray)
                {
                    return(ArrayTypeSymbol.CreateSZArray(_otherAssembly, otherElementType, otherModifiers));
                }

                return(ArrayTypeSymbol.CreateMDArray(_otherAssembly, otherElementType, symbol.Rank, symbol.Sizes, symbol.LowerBounds, otherModifiers));
            }
Example #5
0
        private ArrayTypeSymbol TransformArrayType(ArrayTypeSymbol arrayType)
        {
            var flag = ConsumeFlag();

            Debug.Assert(!flag);

            if (!HandleCustomModifiers(arrayType.ElementTypeWithAnnotations.CustomModifiers.Length))
            {
                return(null);
            }

            TypeSymbol transformedElementType = TransformType(arrayType.ElementType);

            if ((object)transformedElementType == null)
            {
                return(null);
            }

            return(TypeSymbol.Equals(
                       transformedElementType,
                       arrayType.ElementType,
                       TypeCompareKind.ConsiderEverything2
                       )
              ? arrayType
              : arrayType.IsSZArray
                  ? ArrayTypeSymbol.CreateSZArray(
                       _containingAssembly,
                       arrayType.ElementTypeWithAnnotations.WithTypeAndModifiers(
                           transformedElementType,
                           arrayType.ElementTypeWithAnnotations.CustomModifiers
                           )
                       )
                  : ArrayTypeSymbol.CreateMDArray(
                       _containingAssembly,
                       arrayType.ElementTypeWithAnnotations.WithTypeAndModifiers(
                           transformedElementType,
                           arrayType.ElementTypeWithAnnotations.CustomModifiers
                           ),
                       arrayType.Rank,
                       arrayType.Sizes,
                       arrayType.LowerBounds
                       ));
        }
        private ArrayTypeSymbol TransformArrayType(ArrayTypeSymbol arrayType)
        {
            var flag = ConsumeFlag();

            Debug.Assert(!flag);

            if (!HandleCustomModifiers(arrayType.CustomModifiers.Length))
            {
                return(null);
            }

            TypeSymbol transformedElementType = TransformType(arrayType.ElementType);

            if ((object)transformedElementType == null)
            {
                return(null);
            }

            return(transformedElementType == arrayType.ElementType ?
                   arrayType :
                   arrayType.IsSZArray?
                   ArrayTypeSymbol.CreateSZArray(_containingAssembly, transformedElementType, arrayType.CustomModifiers) :
                       ArrayTypeSymbol.CreateMDArray(_containingAssembly, transformedElementType, arrayType.Rank, arrayType.Sizes, arrayType.LowerBounds, arrayType.CustomModifiers));
        }