Descriptor for a method defined in another assembly/module
Inheritance: Method
Exemple #1
0
 internal void AddMethod(MethodRef meth)
 {
     MethodRef m = (MethodRef)GetMethodDesc(meth.Name(),meth.GetParTypes());
     if (m == null) {
         methods.Add(meth);
         meth.SetParent(this);
     }
 }
Exemple #2
0
 /*-------------------- Constructors ---------------------------------*/
 internal ClassSpec(Class clType, Type[] gPars)
 {
     this.typeIndex = GENERICINST;
     genClass = clType;
     genericParams = new ArrayList(gPars);
     tabIx = MDTable.TypeSpec;
     typeIndex = GENERICINST;
     ArrayList classMethods = clType.GetMethodList();
     ArrayList classFields = clType.GetFieldList();
     for (int i=0; i < classMethods.Count; i++) {
         MethSig mSig = ((Method)classMethods[i]).GetSig(); //.InstantiateGenTypes(this,gPars);
         if (mSig != null) {
             MethodRef newMeth = new MethodRef(mSig);
             newMeth.SetParent(this);
             newMeth.GenericParams = ((Method)classMethods[i]).GenericParams;
             methods.Add(newMeth);
         }
     }
     for (int i=0; i < classFields.Count; i++) {
         Type fType = ((Field)classFields[i]).GetFieldType();
         //if ((fType is GenericParam) && (((GenericParam)fType).GetParent() == genClass)) {
         //  fType = gPars[((GenericParam)fType).Index];
         //}
         fields.Add(new FieldRef(this,((Field)classFields[i]).Name(),fType));
     }
 }
Exemple #3
0
 internal void AddToMethodList(MethodRef meth)
 {
     defaultClass.AddToMethodList(meth);
 }
Exemple #4
0
 /*------------------------- public set and get methods --------------------------*/
 /// <summary>
 /// Add a method to this class
 /// </summary>
 /// <param name="name">method name</param>
 /// <param name="retType">return type</param>
 /// <param name="pars">parameter types</param>
 /// <returns>a descriptor for this method</returns>
 public MethodRef AddMethod(string name, Type retType, Type[] pars)
 {
     System.Diagnostics.Debug.Assert(retType != null);
     MethodRef meth = (MethodRef)GetMethodDesc(name,pars);
     if (meth != null) DescriptorError(meth);
     meth = new MethodRef(this,name,retType,pars);
     methods.Add(meth);
     return meth;
 }
Exemple #5
0
 /// <summary>
 /// Add a method to this scope.
 /// </summary>
 /// <param name="meth">The method to be added.</param>
 public void AddMethod(MethodRef meth)
 {
     defaultClass.AddMethod(meth);
 }
Exemple #6
0
 /// <summary>
 /// Delete a method from this scope.
 /// </summary>
 /// <param name="meth">The method to be deleted.</param>
 public void RemoveMethod(MethodRef meth)
 {
     defaultClass.RemoveMethod(meth);
 }
Exemple #7
0
 internal void AddVarArgSig(MethodRef meth)
 {
     varArgSig = meth;
     //meth.MakeVarArgMethod(this,null);
 }
Exemple #8
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);
             //if (parent.GetMethod(mSig) == null) {
             //  MethodRef mRef = new MethodRef(mSig);
             //  parent.AddToMethodList(mRef);
             //}
         }
     }
 }
Exemple #9
0
 /// <summary>
 /// Make a method reference descriptor for this method to be used
 /// as a callsite signature for this vararg method
 /// </summary>
 /// <param name="optPars">the optional pars for the vararg method call</param>
 /// <returns></returns>
 public MethodRef MakeVarArgSignature(Type[] optPars)
 {
     MethSig mSig = new MethSig(name);
     mSig.parTypes = sig.parTypes;
     mSig.retType = sig.retType;
     varArgSig = new MethodRef(sig);
     varArgSig.MakeVarArgMethod(this,optPars);
     return varArgSig;
 }
Exemple #10
0
 /// <summary>
 /// Get the MethodRef equivalent to this MethodDef.  If one
 /// does not exist, then create it.
 /// </summary>
 /// <returns>MethodRef for this MethodDef</returns>
 public MethodRef MakeRefOf()
 {
     if (refOf != null) return refOf;
     ClassRef parRef = ((ClassDef)parent).MakeRefOf();
     refOf = parRef.GetMethod(name, sig.parTypes);
     if (refOf == null) {
         Type rType = sig.MakeRefRetType();
         Type[] pTypes = sig.MakeRefParTypes();
         refOf = new MethodRef(parRef, name, rType, pTypes);
         refOf.defOf = this;
         refOf.AddCallConv(this.GetCallConv());
     }
     return refOf;
 }
Exemple #11
0
 internal static void ReadMember(PEReader buff, TableRow[] members)
 {
     for (int i=0; i < members.Length; i++) {
         uint parenIx = buff.GetCodedIndex(CIx.MemberRefParent);
         string memName = buff.GetString();
         uint sigIx = buff.GetBlobIx();
         if (buff.FirstBlobByte(sigIx) == Field.FieldTag) // got a field
             members[i] = new FieldRef(parenIx,memName,sigIx);
         else
             members[i] = new MethodRef(parenIx,memName,sigIx);
     }
 }