示例#1
0
        public MethodSig GetMethodSig()
        {
            var mod = Module;
            var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();

            if (mdi == null)
            {
                return(null);
            }
            return(MetaDataUtils.GetMethodSignature(mdi, Token));
        }
示例#2
0
文件: CorFrame.cs 项目: ottrur/dnSpy
        /// <summary>
        /// Gets all argument and local types
        /// </summary>
        /// <param name="argTypes">Gets updated with all argument types. If there's a hidden this
        /// parameter, it's the first type. This type can be null. If it's not null, ignore any
        /// <see cref="ClassSig"/> since it might still be a value type</param>
        /// <param name="localTypes">Gets updated with all local types</param>
        /// <returns></returns>
        public bool GetArgAndLocalTypes(out List <TypeSig> argTypes, out List <TypeSig> localTypes)
        {
            argTypes   = new List <TypeSig>();
            localTypes = new List <TypeSig>();

            var func = Function;

            if (func == null)
            {
                return(false);
            }
            var module = func.Module;

            if (module == null)
            {
                return(false);
            }

            var mdi = module.GetMetaDataInterface <IMetaDataImport>();

            var methodSig = MetaDataUtils.GetMethodSignature(mdi, func.Token);

            if (methodSig != null)
            {
                if (methodSig.HasThis)
                {
                    argTypes.Add(GetThisType(func));
                }
                argTypes.AddRange(methodSig.Params);
                if (methodSig.ParamsAfterSentinel != null)
                {
                    argTypes.AddRange(methodSig.ParamsAfterSentinel);
                }
            }

            uint localVarSigTok = func.LocalVarSigToken;

            if ((localVarSigTok & 0x00FFFFFF) != 0)
            {
                var localSig = MetaDataUtils.ReadCallingConventionSig(mdi, localVarSigTok) as LocalSig;
                if (localSig != null)
                {
                    localTypes.AddRange(localSig.Locals);
                }
            }

            return(true);
        }
示例#3
0
 public MethodSig GetMethodSig() => MetaDataUtils.GetMethodSignature(Module?.GetMetaDataInterface <IMetaDataImport>(), Token);