本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}