Beispiel #1
0
 private TypeReference LookupSystemValueType(ref TypeReference typeRef, string name, ElementType element_type)
 {
     lock (module.SyncRoot)
     {
         if (typeRef != null)
         {
             return(typeRef);
         }
         TypeReference typeReference = LookupType("System", name);
         typeReference.etype = element_type;
         typeReference.KnownValueType();
         return(typeRef = typeReference);
     }
 }
Beispiel #2
0
        private TypeReference ReadTypeSignature(ElementType etype)
        {
            switch (etype)
            {
            case ElementType.ValueType:
            {
                TypeReference typeDefOrRef2 = GetTypeDefOrRef(ReadTypeTokenSignature());
                typeDefOrRef2.KnownValueType();
                return(typeDefOrRef2);
            }

            case ElementType.Class:
                return(GetTypeDefOrRef(ReadTypeTokenSignature()));

            case ElementType.Ptr:
                return(new PointerType(ReadTypeSignature()));

            case ElementType.FnPtr:
            {
                FunctionPointerType functionPointerType = new FunctionPointerType();
                ReadMethodSignature(functionPointerType);
                return(functionPointerType);
            }

            case ElementType.ByRef:
                return(new ByReferenceType(ReadTypeSignature()));

            case ElementType.Pinned:
                return(new PinnedType(ReadTypeSignature()));

            case ElementType.SzArray:
                return(new ArrayType(ReadTypeSignature()));

            case ElementType.Array:
                return(ReadArrayTypeSignature());

            case ElementType.CModOpt:
                return(new OptionalModifierType(GetTypeDefOrRef(ReadTypeTokenSignature()), ReadTypeSignature()));

            case ElementType.CModReqD:
                return(new RequiredModifierType(GetTypeDefOrRef(ReadTypeTokenSignature()), ReadTypeSignature()));

            case ElementType.Sentinel:
                return(new SentinelType(ReadTypeSignature()));

            case ElementType.Var:
                return(GetGenericParameter(GenericParameterType.Type, base.ReadCompressedUInt32()));

            case ElementType.MVar:
                return(GetGenericParameter(GenericParameterType.Method, base.ReadCompressedUInt32()));

            case ElementType.GenericInst:
            {
                bool                num                 = base.ReadByte() == 17;
                TypeReference       typeDefOrRef        = GetTypeDefOrRef(ReadTypeTokenSignature());
                GenericInstanceType genericInstanceType = new GenericInstanceType(typeDefOrRef);
                ReadGenericInstanceSignature(typeDefOrRef, genericInstanceType);
                if (num)
                {
                    genericInstanceType.KnownValueType();
                    typeDefOrRef.GetElementType().KnownValueType();
                }
                return(genericInstanceType);
            }

            case ElementType.Object:
                return(TypeSystem.Object);

            case ElementType.Void:
                return(TypeSystem.Void);

            case ElementType.TypedByRef:
                return(TypeSystem.TypedReference);

            case ElementType.I:
                return(TypeSystem.IntPtr);

            case ElementType.U:
                return(TypeSystem.UIntPtr);

            default:
                return(GetPrimitiveType(etype));
            }
        }