Ejemplo n.º 1
0
        /*-------------------- 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));
            }
        }
Ejemplo n.º 2
0
 internal MethodDef(Class paren, MethSig mSig, Param[] pars)
     : base(mSig.name)
 {
     sig     = mSig;
     parList = pars;
     parent  = paren;
     tabIx   = MDTable.Method;
 }
Ejemplo n.º 3
0
        /*-------------------- 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);
        }
Ejemplo n.º 4
0
 internal MethSig GetSig(PEReader buff)
 {
     if (sig == null)
     {
         sig = buff.ReadMethSig(this, this.sigIx);
     }
     return(sig);
 }
Ejemplo n.º 5
0
 /*-------------------- 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);
 }
Ejemplo n.º 6
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)
        {
            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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
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);
         }
     }
 }
Ejemplo n.º 10
0
 internal MethodRef GetMethod(MethSig mSig)
 {
     Contract.Requires(mSig != null);
     return (MethodRef)defaultClass.GetMethod(mSig);
 }
Ejemplo n.º 11
0
 internal MethodDef(Class paren, MethSig mSig, Param[] pars)
     : base(mSig.name)
 {
     sig = mSig;
     parList = pars;
     parent = paren;
     tabIx = MDTable.Method;
 }
Ejemplo n.º 12
0
 internal void SetSig(MethSig sig)
 {
     this.sig = sig;
     this.sig.name = name;
 }
Ejemplo n.º 13
0
 internal MethSig GetSig(PEReader buff)
 {
     if (sig == null)
     sig = buff.ReadMethSig(this, this.sigIx);
       return sig;
 }
Ejemplo n.º 14
0
 internal MethodRef(MethSig sig)
     : base(sig.name)
 {
     this.sig = sig;
 }
Ejemplo n.º 15
0
 internal void SetSig(MethSig sig)
 {
     this.sig      = sig;
     this.sig.name = name;
 }
Ejemplo n.º 16
0
 internal Method GetMethod(MethSig mSig)
 {
     Contract.Requires(mSig != null);
     return(GetMethodDesc(mSig.name, mSig.parTypes, mSig.optParTypes));
 }
Ejemplo n.º 17
0
 internal MethodRef(MethSig sig)
     : base(sig.name)
 {
     this.sig = sig;
 }
Ejemplo n.º 18
0
 internal Method GetMethod(MethSig mSig)
 {
     Contract.Requires(mSig != null);
     return GetMethodDesc(mSig.name, mSig.parTypes, mSig.optParTypes);
 }
Ejemplo n.º 19
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)
 {
     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;
 }
Ejemplo n.º 20
0
 internal MethodRef GetMethod(MethSig mSig)
 {
     Contract.Requires(mSig != null);
     return((MethodRef)defaultClass.GetMethod(mSig));
 }
Ejemplo n.º 21
0
 /// <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;
 }
Ejemplo n.º 22
0
 internal MethPtrType(MethSig msig)
     : base((byte)ElementType.FnPtr)
 {
     mSig = msig;
 }
Ejemplo n.º 23
0
 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;
 }
Ejemplo n.º 24
0
 internal MethPtrType(MethSig msig)
     : base((byte)ElementType.FnPtr)
 {
     mSig = msig;
 }