示例#1
0
 public void MakeVarArgMethod(MethodDef paren, Type[] optPars)
 {
     if (paren != null)
     {
         parent = null;
         varArgParent = paren;
     }
     sig.optParTypes = optPars;
     if (sig.optParTypes != null) sig.numOptPars = (uint)sig.optParTypes.Length;
     sig.callConv = CallConv.Vararg;
 }
示例#2
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;
 }
示例#3
0
 /*-------------------- Constructors ---------------------------------*/
 internal CILInstructions(MethodDef meth)
 {
     thisMeth = meth;
 }
示例#4
0
 internal void GetGenericParams(MethodDef meth)
 {
     Contract.Requires(meth != null);
     if (tables[(int)MDTable.GenericParam] != null)
     {
         for (int j = 0; j < tables[(int)MDTable.GenericParam].Length; j++)
         {
             ((GenericParam)tables[(int)MDTable.GenericParam][j]).CheckParent(meth, this);
         }
     }
 }
示例#5
0
 public void AddMethod(MethodDef meth, MethodType mType)
 {
     AddMethod(new MethodSemantics(mType, meth, this));
 }
示例#6
0
 internal Scope(Scope parent, MethodDef thisMeth)
 {
     _thisMeth = thisMeth;
       _parent = parent;
 }
示例#7
0
 internal void Resolve(PEReader buff, MethodDef meth)
 {
     if (resolved) return;
 }
示例#8
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;
 }
示例#9
0
 internal void CheckParent(MethodDef paren, PEReader buff)
 {
     Contract.Requires(buff != null);
     if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx))
     {
         parent = paren;
         paren.InsertGenericParam(this);
     }
 }
示例#10
0
 internal GenericParam GetGenericParam(MethodDef meth)
 {
     Contract.Requires(meth != null);
     if (gPar == null)
     {
         if (isClassPar)
         {
             ClassDef methClass = (ClassDef)meth.GetParent();
             gPar = methClass.GetGenericParam((int)index);
         }
         else
         {
             gPar = meth.GetGenericParam((int)index);
         }
     }
     return gPar;
 }
示例#11
0
 internal override void Resolve(PEReader buff)
 {
     meth = (MethodDef)buff.GetCodedElement(CIx.MemberForwarded, memForIndex);
     importScope = (ModuleRef)buff.GetElement(MDTable.ModuleRef, scopeIx);
     if (meth != null) meth.AddPInvokeInfo(this);
 }
示例#12
0
 /*-------------------- Constructors ---------------------------------*/
 internal ImplMap(ushort flag, MethodDef implMeth, [CanBeNull] string iName, ModuleRef mScope)
 {
     flags = flag;
     meth = implMeth;
     importName = iName;
     importScope = mScope;
     tabIx = MDTable.ImplMap;
     if (iName == null) flags |= NoMangle;
     //throw(new NotYetImplementedException("PInvoke "));
 }
示例#13
0
 public void RemoveMethod(MethodDef meth)
 {
     bool found = false;
     for (int i = 0; i < tide; i++)
     {
         if (found)
             methods[i - 1] = methods[i];
         else if (methods[i].GetMethod() == meth)
             found = true;
     }
 }
示例#14
0
 internal static void Read(PEReader buff, TableRow[] methDefs)
 {
     MethodDef prevDef = new MethodDef(buff);
     methDefs[0] = prevDef;
     for (int i = 1; i < methDefs.Length; i++)
     {
         prevDef.Row = (uint)i;
         MethodDef methDef = new MethodDef(buff);
         prevDef.numPars = methDef.parIx - prevDef.parIx;
         prevDef = methDef;
         methDefs[i] = methDef;
     }
     prevDef.Row = (uint)methDefs.Length;
     prevDef.numPars = (buff.GetTableSize(MDTable.Param) + 1) - prevDef.parIx;
 }
示例#15
0
 internal void Resolve(PEReader buff, MethodDef meth)
 {
     if (resolved) return;
     buff.currentMethodScope = meth;
     buff.currentClassScope = (Class)meth.GetParent();
     locals = buff.ReadLocalSig(sigIx);
     buff.currentMethodScope = null;
     buff.currentClassScope = null;
 }
示例#16
0
 /// <summary>
 /// Delete a method from this module
 /// </summary>
 /// <param name="meth">The method to be deleted</param>
 public void RemoveMethod(MethodDef meth)
 {
     //FIXME Contract.Requires(defaultClass != null);
     defaultClass.RemoveMethod(meth);
 }
示例#17
0
 internal Scope(MethodDef thisMeth)
     : this(null, thisMeth)
 {
 }
示例#18
0
 /// <summary>
 /// Add a method to this class
 /// </summary>
 /// <param name="meth">Descriptor for the method to be added</param>
 public void AddMethod(MethodDef meth)
 {
     Contract.Requires(meth != null);
     MethodDef m = (MethodDef)GetMethodDesc(meth.Name(), meth.GetParTypes());
     if (m != null)
         throw new DescriptorException("Method " + m.NameString());
     methods.Add(meth);
     meth.SetParent(this);
 }
示例#19
0
        private static Scope ReadPDBScope(PDBScope scope, MergeBuffer mergeBuffer, [CanBeNull] Scope parent, MethodDef thisMeth)
        {
            Contract.Requires(scope != null);
            Contract.Requires(thisMeth != null);
            Scope thisScope = new Scope(parent, thisMeth);

            if (parent != null) mergeBuffer.Add(new OpenScope(thisScope), (uint)scope.StartOffset);

            foreach (PDBVariable var in scope.Variables)
                thisScope.AddLocalBinding(var.Name, var.Address);

            foreach (PDBScope child in scope.Children)
                ReadPDBScope(child, mergeBuffer, thisScope, thisMeth);

            if (parent != null) mergeBuffer.Add(new CloseScope(thisScope), (uint)scope.EndOffset);

            return thisScope;
        }