internal override int ParentToken(int token)
        {
            RuntimeType declaringType = null;
            object      obj2          = this.m_scope[token];

            if (obj2 is RuntimeMethodHandle)
            {
                declaringType = RuntimeMethodHandle.GetDeclaringType(((RuntimeMethodHandle)obj2).GetMethodInfo());
            }
            else if (obj2 is RuntimeFieldHandle)
            {
                declaringType = RuntimeFieldHandle.GetApproxDeclaringType(((RuntimeFieldHandle)obj2).GetRuntimeFieldInfo());
            }
            else if (obj2 is DynamicMethod)
            {
                DynamicMethod method = (DynamicMethod)obj2;
                declaringType = RuntimeMethodHandle.GetDeclaringType(method.m_methodHandle);
            }
            else if (obj2 is GenericMethodInfo)
            {
                GenericMethodInfo info = (GenericMethodInfo)obj2;
                declaringType = info.m_context.GetRuntimeType();
            }
            else if (obj2 is GenericFieldInfo)
            {
                GenericFieldInfo info2 = (GenericFieldInfo)obj2;
                declaringType = info2.m_context.GetRuntimeType();
            }
            else if (obj2 is VarArgMethod)
            {
                VarArgMethod  method2       = (VarArgMethod)obj2;
                DynamicMethod dynamicMethod = method2.m_dynamicMethod;
                if (dynamicMethod != null)
                {
                    dynamicMethod.GetMethodDescriptor();
                    declaringType = RuntimeMethodHandle.GetDeclaringType(dynamicMethod.m_methodHandle);
                }
                else
                {
                    RuntimeMethodInfo info3 = method2.m_method;
                    if (info3.DeclaringType == null)
                    {
                        declaringType = RuntimeMethodHandle.GetDeclaringType(info3);
                    }
                    else
                    {
                        declaringType = info3.DeclaringType.TypeHandle.GetRuntimeType();
                    }
                }
            }
            if (declaringType == null)
            {
                return(-1);
            }
            return(this.m_scope.GetTokenFor(declaringType.GetTypeHandleInternal()));
        }
        internal override unsafe void *GetInstantiationInfo(int token)
        {
            GenericMethodInfo gmi = m_scope[token] as GenericMethodInfo;

            if (gmi != null)
            {
                return((void *)gmi.m_context.Value);
            }
            return(null);
        }
        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));
        }
        internal override unsafe void *ResolveToken(int token)
        {
            object obj2 = this.m_scope[token];

            if (obj2 is RuntimeTypeHandle)
            {
                RuntimeTypeHandle handle = (RuntimeTypeHandle)obj2;
                return((void *)handle.Value);
            }
            if (obj2 is RuntimeMethodHandle)
            {
                RuntimeMethodHandle handle2 = (RuntimeMethodHandle)obj2;
                return((void *)handle2.Value);
            }
            if (obj2 is RuntimeFieldHandle)
            {
                RuntimeFieldHandle handle3 = (RuntimeFieldHandle)obj2;
                return((void *)handle3.Value);
            }
            if (obj2 is DynamicMethod)
            {
                DynamicMethod method = (DynamicMethod)obj2;
                return((void *)method.GetMethodDescriptor().Value);
            }
            if (obj2 is GenericMethodInfo)
            {
                GenericMethodInfo info = (GenericMethodInfo)obj2;
                return((void *)info.m_methodHandle.Value);
            }
            if (obj2 is GenericFieldInfo)
            {
                GenericFieldInfo info2 = (GenericFieldInfo)obj2;
                return((void *)info2.m_fieldHandle.Value);
            }
            if (!(obj2 is VarArgMethod))
            {
                return(null);
            }
            VarArgMethod method2 = (VarArgMethod)obj2;

            if (method2.m_dynamicMethod == null)
            {
                return((void *)method2.m_method.MethodHandle.Value);
            }
            return((void *)method2.m_dynamicMethod.GetMethodDescriptor().Value);
        }
        internal override unsafe void *ResolveToken(int token)
        {
            Object handle = m_scope[token];

            if (handle is RuntimeTypeHandle)
            {
                RuntimeTypeHandle typeHandle = (RuntimeTypeHandle)handle;
                return((void *)typeHandle.Value);
            }
            else if (handle is RuntimeMethodHandle)
            {
                RuntimeMethodHandle methodHandle = (RuntimeMethodHandle)handle;
                return((void *)methodHandle.Value);
            }
            else if (handle is RuntimeFieldHandle)
            {
                RuntimeFieldHandle fieldHandle = (RuntimeFieldHandle)handle;
                return((void *)fieldHandle.Value);
            }
            else if (handle is DynamicMethod)
            {
                DynamicMethod       dynMeth      = (DynamicMethod)handle;
                RuntimeMethodHandle methodHandle = dynMeth.GetMethodDescriptor();
                return((void *)methodHandle.Value);
            }
            else if (handle is GenericMethodInfo)
            {
                GenericMethodInfo gmi = (GenericMethodInfo)handle;
                return((void *)gmi.m_method.Value);
            }
            else if (handle is VarArgMethod)
            {
                VarArgMethod  vaMeth = (VarArgMethod)handle;
                DynamicMethod dm     = vaMeth.m_method as DynamicMethod;
                if (dm == null)
                {
                    return((void *)vaMeth.m_method.MethodHandle.Value);
                }
                else
                {
                    return((void *)dm.GetMethodDescriptor().Value);
                }
            }

            return(null);
        }
Example #6
0
        internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
        {
            typeHandle   = new IntPtr();
            methodHandle = new IntPtr();
            fieldHandle  = new IntPtr();

            Object handle = m_scope[token];

            if (handle == null)
            {
                throw new InvalidProgramException();
            }

            if (handle is RuntimeTypeHandle)
            {
                typeHandle = ((RuntimeTypeHandle)handle).Value;
                return;
            }

            if (handle is RuntimeMethodHandle)
            {
                methodHandle = ((RuntimeMethodHandle)handle).Value;
                return;
            }

            if (handle is RuntimeFieldHandle)
            {
                fieldHandle = ((RuntimeFieldHandle)handle).Value;
                return;
            }

            DynamicMethod dm = handle as DynamicMethod;

            if (dm != null)
            {
                methodHandle = dm.GetMethodDescriptor().Value;
                return;
            }

            GenericMethodInfo gmi = handle as GenericMethodInfo;

            if (gmi != null)
            {
                methodHandle = gmi.m_methodHandle.Value;
                typeHandle   = gmi.m_context.Value;
                return;
            }

            GenericFieldInfo gfi = handle as GenericFieldInfo;

            if (gfi != null)
            {
                fieldHandle = gfi.m_fieldHandle.Value;
                typeHandle  = gfi.m_context.Value;
                return;
            }

            VarArgMethod vaMeth = handle as VarArgMethod;

            if (vaMeth != null)
            {
                if (vaMeth.m_dynamicMethod == null)
                {
                    methodHandle = vaMeth.m_method.MethodHandle.Value;
                    typeHandle   = vaMeth.m_method.GetDeclaringTypeInternal().GetTypeHandleInternal().Value;
                }
                else
                {
                    methodHandle = vaMeth.m_dynamicMethod.GetMethodDescriptor().Value;
                }

                return;
            }
        }
Example #7
0
        internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
        {
            typeHandle   = new IntPtr();
            methodHandle = new IntPtr();
            fieldHandle  = new IntPtr();
            object obj = this.m_scope[token];

            if (obj == null)
            {
                throw new InvalidProgramException();
            }
            if (obj is RuntimeTypeHandle)
            {
                typeHandle = ((RuntimeTypeHandle)obj).Value;
            }
            else if (obj is RuntimeMethodHandle)
            {
                methodHandle = ((RuntimeMethodHandle)obj).Value;
            }
            else if (obj is RuntimeFieldHandle)
            {
                fieldHandle = ((RuntimeFieldHandle)obj).Value;
            }
            else
            {
                DynamicMethod dynamicMethod = obj as DynamicMethod;
                if ((MethodInfo)dynamicMethod != (MethodInfo)null)
                {
                    methodHandle = dynamicMethod.GetMethodDescriptor().Value;
                }
                else
                {
                    GenericMethodInfo genericMethodInfo = obj as GenericMethodInfo;
                    if (genericMethodInfo != null)
                    {
                        methodHandle = genericMethodInfo.m_methodHandle.Value;
                        typeHandle   = genericMethodInfo.m_context.Value;
                    }
                    else
                    {
                        GenericFieldInfo genericFieldInfo = obj as GenericFieldInfo;
                        if (genericFieldInfo != null)
                        {
                            fieldHandle = genericFieldInfo.m_fieldHandle.Value;
                            typeHandle  = genericFieldInfo.m_context.Value;
                        }
                        else
                        {
                            VarArgMethod varArgMethod = obj as VarArgMethod;
                            if (varArgMethod == null)
                            {
                                return;
                            }
                            if ((MethodInfo)varArgMethod.m_dynamicMethod == (MethodInfo)null)
                            {
                                methodHandle = varArgMethod.m_method.MethodHandle.Value;
                                typeHandle   = varArgMethod.m_method.GetDeclaringTypeInternal().GetTypeHandleInternal().Value;
                            }
                            else
                            {
                                methodHandle = varArgMethod.m_dynamicMethod.GetMethodDescriptor().Value;
                            }
                        }
                    }
                }
            }
        }