当前位置: 首页>>代码示例>>C#>>正文


C# MosaMethod.GetUnderlyingObject方法代码示例

本文整理汇总了C#中MosaMethod.GetUnderlyingObject方法的典型用法代码示例。如果您正苦于以下问题:C# MosaMethod.GetUnderlyingObject方法的具体用法?C# MosaMethod.GetUnderlyingObject怎么用?C# MosaMethod.GetUnderlyingObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MosaMethod的用法示例。


在下文中一共展示了MosaMethod.GetUnderlyingObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddMethod

 public void AddMethod(MosaMethod method)
 {
     methodLookup.Add(method.GetUnderlyingObject<UnitDesc<MethodDef, MethodSig>>().Token, method);
 }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:4,代码来源:MetadataCache.cs

示例2: ResolveMethod

        private void ResolveMethod(MosaMethod method)
        {
            GenericArgumentResolver resolver = new GenericArgumentResolver();
            bool hasOpening = method.DeclaringType.HasOpenGenericParams;

            if (method.DeclaringType.GenericArguments.Count > 0)
            {
                foreach (var i in method.DeclaringType.GenericArguments.GetGenericArguments())
                    hasOpening |= i.HasOpenGenericParameter();
                resolver.PushTypeGenericArguments(method.DeclaringType.GenericArguments.GetGenericArguments());
            }

            if (method.GenericArguments.Count > 0)
            {
                foreach (var i in method.GenericArguments.GetGenericArguments())
                    hasOpening |= i.HasOpenGenericParameter();
                resolver.PushMethodGenericArguments(method.GenericArguments.GetGenericArguments());
            }

            using (var mosaMethod = metadata.Controller.MutateMethod(method))
            {
                var desc = method.GetUnderlyingObject<UnitDesc<MethodDef, MethodSig>>();

                MosaType returnType = metadata.Loader.GetType(resolver.Resolve(desc.Signature.RetType));
                hasOpening |= returnType.HasOpenGenericParams;
                List<MosaParameter> pars = new List<MosaParameter>();

                Debug.Assert(desc.Signature.GetParamCount() + (desc.Signature.HasThis ? 1 : 0) == desc.Definition.Parameters.Count);
                foreach (var param in desc.Definition.Parameters)
                {
                    if (!param.IsNormalMethodParameter)
                        continue;
                    var paramType = metadata.Loader.GetType(resolver.Resolve(desc.Signature.Params[param.MethodSigIndex]));
                    var parameter = metadata.Controller.CreateParameter();

                    using (var mosaParameter = metadata.Controller.MutateParameter(parameter))
                    {
                        mosaParameter.Name = param.Name;
                        mosaParameter.ParameterAttributes = (MosaParameterAttributes)param.ParamDef.Attributes;
                        mosaParameter.ParameterType = paramType;
                        mosaParameter.DeclaringMethod = method;
                        ResolveCustomAttributes(mosaParameter, param.ParamDef);
                    }

                    pars.Add(parameter);
                    hasOpening |= paramType.HasOpenGenericParams;
                }

                mosaMethod.Signature = new MosaMethodSignature(returnType, pars);

                foreach (var methodImpl in desc.Definition.Overrides)
                {
                    Debug.Assert(methodImpl.MethodBody == desc.Definition);
                    mosaMethod.Overrides.Add(ResolveMethodOperand(methodImpl.MethodDeclaration, null));
                }

                if (desc.Definition.HasBody)
                    ResolveBody(desc.Definition, mosaMethod, desc.Definition.Body, resolver);

                mosaMethod.HasOpenGenericParams = hasOpening;

                ResolveCustomAttributes(mosaMethod, desc.Definition);
            }
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:64,代码来源:MetadataResolver.cs

示例3: ResolveMethod

        private void ResolveMethod(MosaMethod method)
        {
            GenericArgumentResolver resolver = new GenericArgumentResolver();
            bool hasOpening = method.DeclaringType.HasOpenGenericParams;

            if (method.DeclaringType.GenericArguments.Count > 0)
            {
                foreach (var i in method.DeclaringType.GenericArguments.GetGenericArguments())
                    hasOpening |= i.HasOpenGenericParameter();
                resolver.PushTypeGenericArguments(method.DeclaringType.GenericArguments.GetGenericArguments());
            }

            if (method.GenericArguments.Count > 0)
            {
                foreach (var i in method.GenericArguments.GetGenericArguments())
                    hasOpening |= i.HasOpenGenericParameter();
                resolver.PushMethodGenericArguments(method.GenericArguments.GetGenericArguments());
            }
            else
                hasOpening |= method.GetMethodSig().HasOpenGenericParameter();

            using (var mosaMethod = metadata.Controller.MutateMethod(method))
            {
                var desc = method.GetUnderlyingObject<UnitDesc<MethodDef, MethodSig>>();

                MosaType returnType = metadata.Loader.GetType(resolver.Resolve(desc.Signature.RetType));
                List<MosaParameter> pars = new List<MosaParameter>();

                Debug.Assert(desc.Signature.GetParamCount() == desc.Definition.ParamDefs.Count);
                for (int i = 0; i < desc.Definition.ParamDefs.Count; i++)
                {
                    pars.Add(new MosaParameter(desc.Definition.ParamDefs[i].FullName, metadata.Loader.GetType(resolver.Resolve(desc.Signature.Params[i]))));
                }

                mosaMethod.Signature = new MosaMethodSignature(returnType, pars);

                if (desc.Definition.HasBody)
                    ResolveBody(desc.Definition, mosaMethod, desc.Definition.Body, resolver);

                mosaMethod.HasOpenGenericParams = hasOpening;

                ResolveCustomAttributes(mosaMethod, desc.Definition);
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:44,代码来源:MetadataResolver.cs


注:本文中的MosaMethod.GetUnderlyingObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。