예제 #1
0
 internal static void GetMethodRefs(PEReader buff, uint num, ClassRef parent)
 {
     for (int i = 0; i < num; i++)
     {
         uint rva = buff.ReadUInt32();
         ushort implFlags = buff.ReadUInt16();
         ushort methFlags = buff.ReadUInt16();
         string name = buff.GetString();
         uint sigIx = buff.GetBlobIx();
         uint parIx = buff.GetIndex(MDTable.Param);
         if (IsPublicOrProtected(methFlags))
         {
             MethodRef mRef = new MethodRef(parIx, name, sigIx);  // changed
             mRef.SetParent(parent);
             //Console.WriteLine(parent.NameString());
             MethSig mSig = buff.ReadMethSig(mRef, name, sigIx);
             //mSig.name = name;
             mRef.SetSig(mSig); // changed
             parent.AddToMethodList(mRef);
         }
     }
 }
예제 #2
0
 internal MethSig GetSig(PEReader buff)
 {
     if (sig == null)
     sig = buff.ReadMethSig(this, this.sigIx);
       return sig;
 }
예제 #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;
 }
예제 #4
0
 internal override void Resolve(PEReader buff)
 {
     if (sig == null)
     {
         buff.currentMethodScope = this;
         buff.currentClassScope = parent;
         sig = buff.ReadMethSig(this, name, sigIx);
         buff.currentMethodScope = null;
         buff.currentClassScope = null;
     }
 }
예제 #5
0
 private void DoPars(PEReader buff, bool resolvePars)
 {
     if (sig == null) sig = buff.ReadMethSig(this, sigIx);
     sig.name = name;
     parList = new Param[sig.numPars];
     if (parIx > buff.GetTableSize(MDTable.Param))
     {
         // EXPERIMENTAL kjg 19 November 2007
         //  It is actually allowed that a method def does not
         //  have corresponding Param metadata, provided the
         //  parameter types may be constructed from the sig.
         for (uint i = 0; i < sig.numPars; i++)
         {
             parList[i] = Param.DefaultParam();
             parList[i].SetParType(sig.parTypes[i]);
         }
     }
     else
     {
         for (uint i = 0; i < sig.numPars; i++)
         {
             parList[i] = (Param)buff.GetElement(MDTable.Param, i + parIx);
             if (resolvePars) parList[i].Resolve(buff, i + parIx, sig.parTypes[i]);
             else parList[i].SetParType(sig.parTypes[i]);
         }
     }
 }
예제 #6
0
 internal override sealed void Resolve(PEReader buff)
 {
     MethSig mSig = buff.ReadMethSig(null, sigIx);
     callConv = mSig.callConv;
     retType = mSig.retType;
     parTypes = mSig.parTypes;
     if (parTypes != null) numPars = (uint)parTypes.Length;
     optParTypes = mSig.optParTypes;
     if (optParTypes != null) numOptPars = (uint)optParTypes.Length;
 }