示例#1
0
文件: CorFrame.cs 项目: ottrur/dnSpy
        TypeSig GetThisType(CorFunction func)
        {
            if (func == null)
            {
                return(null);
            }
            var funcClass = func.Class;
            var mod       = funcClass == null ? null : funcClass.Module;
            var mdi       = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();

            if (mdi == null)
            {
                return(null);
            }

            int numTypeGenArgs = MetaDataUtils.GetCountGenericParameters(mdi, funcClass.Token);
            var genTypeArgs    = this.TypeParameters.Take(numTypeGenArgs).ToArray();

            var td = DebugSignatureReader.CreateTypeDef(mdi, funcClass.Token);
            // Assume it's a class for now. The code should ignore ClassSig and just use the TypeDef
            var sig = new ClassSig(td);

            if (genTypeArgs.Length == 0)
            {
                return(sig);
            }

            var genArgs = new List <TypeSig>(genTypeArgs.Length);

            for (int i = 0; i < genTypeArgs.Length; i++)
            {
                genArgs.Add(new GenericVar(i));
            }
            return(new GenericInstSig(sig, genArgs));
        }
示例#2
0
        static TypeSig GetFieldTypeSig(IMetaDataImport mdi, uint token)
        {
            var buf = MDAPI.GetFieldSignatureBlob(mdi, token);

            if (buf == null)
            {
                return(null);
            }
            var sig = new DebugSignatureReader().ReadSignature(mdi, buf) as FieldSig;

            return(sig?.Type);
        }
示例#3
0
		static TypeSig GetFieldTypeSig(IMetaDataImport mdi, uint token) {
			var buf = GetFieldSignature(mdi, token);
			if (buf == null)
				return null;
			var sig = new DebugSignatureReader().ReadSignature(mdi, buf) as FieldSig;
			return sig == null ? null : sig.Type;
		}