internal override unsafe int ParentToken(int token)
{
RuntimeTypeHandle owner = RuntimeTypeHandle.EmptyHandle;
Object handle = m_scope[token];
if (handle is RuntimeMethodHandle)
{
RuntimeMethodHandle method = (RuntimeMethodHandle)handle;
owner = method.GetDeclaringType();
}
else if (handle is RuntimeFieldHandle)
{
RuntimeFieldHandle field = (RuntimeFieldHandle)handle;
owner = field.GetApproxDeclaringType();
}
else if (handle is DynamicMethod)
{
DynamicMethod dynMeth = (DynamicMethod)handle;
owner = dynMeth.m_method.GetDeclaringType();
}
else if (handle is GenericMethodInfo)
{
GenericMethodInfo gmi = (GenericMethodInfo)handle;
owner = gmi.m_context;
}
else if (handle is VarArgMethod)
{
VarArgMethod varargMeth = (VarArgMethod)handle;
if (varargMeth.m_method is DynamicMethod)
owner = ((DynamicMethod)varargMeth.m_method).m_method.GetDeclaringType();
else if (varargMeth.m_method is DynamicMethod.RTDynamicMethod)
owner = ((DynamicMethod.RTDynamicMethod)varargMeth.m_method).m_owner.m_method.GetDeclaringType();
else
owner = varargMeth.m_method.MethodHandle.GetDeclaringType();
}
if (owner.IsNullHandle())
return -1;
return m_scope.GetTokenFor(owner);
}