Beispiel #1
0
        internal override Member ResolveParent(PEReader buff)
        {
            if (parent != null)
            {
                return(this);
            }
            buff.currentMethodScope = this;
            MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent, parentIx);

            buff.currentMethodScope = null;
            if (paren is MethodDef)
            {
                parent       = null;
                varArgParent = (MethodDef)paren;
                //this.sig = buff.ReadMethSig(this,name,sigIx);
                ((MethodDef)paren).AddVarArgSig(this);
                return(this);
            }
            else if (paren is ClassSpec)
            {
                ((ClassSpec)paren).AddMethod(this);
                return(this);
            }
            else if (paren is PrimitiveType)
            {
                paren = MSCorLib.mscorlib.GetDefaultClass();
            }
            else if (paren is ClassDef)
            {
                this.sig = buff.ReadMethSig(this, name, sigIx);
                return(((ClassDef)paren).GetMethod(this.sig));
            }
            else if (paren is TypeSpec)
            {
                paren = new ConstructedTypeSpec((TypeSpec)paren);
                //Console.WriteLine("Got TypeSpec as parent of Member");
                //return this;
                //throw new Exception("Got TypeSpec as parent of Member");
                //((TypeSpec)paren).AddMethod(buff,this);
            }
            if (paren is ReferenceScope)
            {
                parent = ((ReferenceScope)paren).GetDefaultClass();
            }
            parent = (Class)paren;
            //if ((MethodRef)parent.GetMethodDesc(name) != null) throw new PEFileException("Existing method!!");
            //sig = buff.ReadMethSig(this,name,sigIx);
            //MethodRef existing = (MethodRef)parent.GetMethod(sig);
            //if (existing != null)
            //  return existing;
            parent.AddToMethodList(this);
            return(this);
        }
Beispiel #2
0
        internal override Member ResolveParent(PEReader buff)
        {
            if (parent != null)
            {
                return(this);
            }
            MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent, parentIx);

            //Console.WriteLine("parentIx = " + parentIx);
            //Console.WriteLine("paren = " + paren);
            if (paren is ClassDef)
            {
                return(((ClassDef)paren).GetField(this.name));
            }
            //if (paren is ClassSpec)
            // paren = ((ClassSpec)paren).GetParent();
            if (paren is ReferenceScope)
            {
                parent = ((ReferenceScope)paren).GetDefaultClass();
            }
            if (paren is TypeSpec)
            {
                parent = new ConstructedTypeSpec((TypeSpec)paren);
            }
            else
            {
                parent = (Class)paren;
            }
            if (parent != null)
            {
                Field existing = (Field)((Class)parent).GetFieldDesc(name);
                if (existing != null)
                {
                    return(existing);
                }
            }
            parent.AddToFieldList(this);
            return(this);
        }
Beispiel #3
0
 internal override Member ResolveParent(PEReader buff)
 {
     if (parent != null) return this;
     buff.currentMethodScope = this;
     MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent, parentIx);
     buff.currentMethodScope = null;
     if (paren is MethodDef)
     {
         parent = null;
         varArgParent = (MethodDef)paren;
         //this.sig = buff.ReadMethSig(this,name,sigIx);
         ((MethodDef)paren).AddVarArgSig(this);
         return this;
     }
     else if (paren is ClassSpec)
     {
         ((ClassSpec)paren).AddMethod(this);
         return this;
     }
     else if (paren is PrimitiveType)
     {
         paren = MSCorLib.mscorlib.GetDefaultClass();
     }
     else if (paren is ClassDef)
     {
         this.sig = buff.ReadMethSig(this, name, sigIx);
         return ((ClassDef)paren).GetMethod(this.sig);
     }
     else if (paren is TypeSpec)
     {
         paren = new ConstructedTypeSpec((TypeSpec)paren);
         //Console.WriteLine("Got TypeSpec as parent of Member");
         //return this;
         //throw new Exception("Got TypeSpec as parent of Member");
         //((TypeSpec)paren).AddMethod(buff,this);
     }
     if (paren is ReferenceScope)
         parent = ((ReferenceScope)paren).GetDefaultClass();
     parent = (Class)paren;
     //if ((MethodRef)parent.GetMethodDesc(name) != null) throw new PEFileException("Existing method!!");
     //sig = buff.ReadMethSig(this,name,sigIx);
     //MethodRef existing = (MethodRef)parent.GetMethod(sig);
     //if (existing != null)
     //  return existing;
     parent.AddToMethodList(this);
     return this;
 }
Beispiel #4
0
 internal override Member ResolveParent(PEReader buff)
 {
     if (parent != null) return this;
     MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent, parentIx);
     //Console.WriteLine("parentIx = " + parentIx);
     //Console.WriteLine("paren = " + paren);
     if (paren is ClassDef)
         return ((ClassDef)paren).GetField(this.name);
     //if (paren is ClassSpec)
     // paren = ((ClassSpec)paren).GetParent();
     if (paren is ReferenceScope)
         parent = ((ReferenceScope)paren).GetDefaultClass();
     if (paren is TypeSpec)
         parent = new ConstructedTypeSpec((TypeSpec)paren);
     else
         parent = (Class)paren;
     if (parent != null)
     {
         Field existing = (Field)((Class)parent).GetFieldDesc(name);
         if (existing != null)
         {
             return existing;
         }
     }
     parent.AddToFieldList(this);
     return this;
 }