/*-------------------- Constructors ---------------------------------*/ internal ClassSpec(Class clType, Type[] gPars) { Contract.Requires(clType != null); Contract.Requires(gPars != null); 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(); fields.Add(new FieldRef(this, ((Field)classFields[i]).Name(), fType)); } }
internal MethodDef(Class paren, MethSig mSig, Param[] pars) : base(mSig.name) { sig = mSig; parList = pars; parent = paren; tabIx = MDTable.Method; }
/*-------------------- Constructors ---------------------------------*/ internal Method(string methName, Type rType, Class paren) : base(methName, paren) { Contract.Requires(methName != null); Contract.Requires(rType != null); Contract.Requires(paren != null); sig = new MethSig(methName, rType); }
internal MethSig GetSig(PEReader buff) { if (sig == null) { sig = buff.ReadMethSig(this, this.sigIx); } return(sig); }
/// <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) { Contract.Requires(optPars != null); MethSig mSig = new MethSig(name); mSig.parTypes = sig.parTypes; mSig.retType = sig.retType; varArgSig = new MethodRef(sig); varArgSig.MakeVarArgMethod(this, optPars); return(varArgSig); }
internal MethSig InstantiateGenTypes(Class classType, Type[] genTypes) { Contract.Requires(classType != null); Contract.Requires(genTypes != null); MethSig newSig = new MethSig(name); newSig.callConv = callConv; newSig.numPars = numPars; newSig.numOptPars = numOptPars; newSig.numGenPars = numGenPars; newSig.parTypes = ReplaceGenPars(parTypes, classType, genTypes); newSig.optParTypes = ReplaceGenPars(optParTypes, classType, genTypes); newSig.retType = SubstituteType(retType, classType, genTypes); return(newSig); }
internal sealed override 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; } }
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); } } }
internal MethodRef GetMethod(MethSig mSig) { Contract.Requires(mSig != null); return (MethodRef)defaultClass.GetMethod(mSig); }
internal void SetSig(MethSig sig) { this.sig = sig; this.sig.name = name; }
internal MethSig GetSig(PEReader buff) { if (sig == null) sig = buff.ReadMethSig(this, this.sigIx); return sig; }
internal MethodRef(MethSig sig) : base(sig.name) { this.sig = sig; }
internal Method GetMethod(MethSig mSig) { Contract.Requires(mSig != null); return(GetMethodDesc(mSig.name, mSig.parTypes, mSig.optParTypes)); }
internal Method GetMethod(MethSig mSig) { Contract.Requires(mSig != null); return GetMethodDesc(mSig.name, mSig.parTypes, mSig.optParTypes); }
/// <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) { Contract.Requires(optPars != null); MethSig mSig = new MethSig(name); mSig.parTypes = sig.parTypes; mSig.retType = sig.retType; varArgSig = new MethodRef(sig); varArgSig.MakeVarArgMethod(this, optPars); return varArgSig; }
internal MethodRef GetMethod(MethSig mSig) { Contract.Requires(mSig != null); return((MethodRef)defaultClass.GetMethod(mSig)); }
/// <summary> /// Add a method to this class /// </summary> /// <param name="name">method name</param> /// <param name="retType">return type</param> /// <param name="pars">parameters</param> /// <returns>a descriptor for this new method</returns> public MethodDef AddMethod(string name, Type retType, Param[] pars) { MethSig mSig = new MethSig(name); Contract.Requires(methodName != null); Contract.Requires(retType != null); Contract.Requires(pars != null); mSig.SetParTypes(pars); MethodDef meth = (MethodDef)GetMethod(mSig); if (meth != null) throw new DescriptorException("Method " + meth.NameString()); mSig.retType = retType; meth = new MethodDef(this, mSig, pars); methods.Add(meth); return meth; }
internal MethPtrType(MethSig msig) : base((byte)ElementType.FnPtr) { mSig = msig; }
internal MethSig InstantiateGenTypes(Class classType, Type[] genTypes) { Contract.Requires(classType != null); Contract.Requires(genTypes != null); MethSig newSig = new MethSig(name); newSig.callConv = callConv; newSig.numPars = numPars; newSig.numOptPars = numOptPars; newSig.numGenPars = numGenPars; newSig.parTypes = ReplaceGenPars(parTypes, classType, genTypes); newSig.optParTypes = ReplaceGenPars(optParTypes, classType, genTypes); newSig.retType = SubstituteType(retType, classType, genTypes); return newSig; }