예제 #1
0
        public CppVtableSlot ResolveMethodImplReference(CLRTableRow methodDecl)
        {
            if (methodDecl is CLRMethodDefRow)
            {
                CLRMethodDefRow mdef = (CLRMethodDefRow)methodDecl;

                CppClass cls = GetCachedClass(CreateInstanceTypeSpec(m_assemblies, mdef.Owner));
                CLRMethodSignatureInstance sig = new CLRMethodSignatureInstance(m_assemblies, mdef.Signature);

                foreach (CppMethod method in cls.Methods)
                {
                    if (method.MethodDef == mdef)
                    {
                        if (method.CreatesSlot != null)
                            return method.CreatesSlot;
                        if (method.ReplacesStandardSlot != null)
                            return method.ReplacesStandardSlot;
                        throw new ParseFailedException("Override was linked to a non-virtual method");
                    }
                }

                throw new ParseFailedException("Failed to match a MethodImpl");
            }
            else if (methodDecl is CLRMemberRefRow)
            {
                CLRMemberRefRow mref = (CLRMemberRefRow)methodDecl;
                if (mref.MethodSig == null)
                    throw new ParseFailedException("Strange method override encountered");

                CppClass declaredInClass = this.GetCachedClass(m_assemblies.InternTypeDefOrRefOrSpec(mref.Class));
                CLRMethodSignatureInstance sig = new CLRMethodSignatureInstance(m_assemblies, mref.MethodSig);

                foreach (CppVtableSlot slot in declaredInClass.OverrideVisibleVtableSlots)
                {
                    if (slot.Name == mref.Name && sig.Equals(slot.DeclaredSignature))
                        return slot;
                }
                throw new ParseFailedException("Couldn't match method reference");
            }
            else
                throw new NotSupportedException();
        }