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; }
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; }
/*-------------------- Constructors ---------------------------------*/ internal CILInstructions(MethodDef meth) { thisMeth = meth; }
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); } } }
public void AddMethod(MethodDef meth, MethodType mType) { AddMethod(new MethodSemantics(mType, meth, this)); }
internal Scope(Scope parent, MethodDef thisMeth) { _thisMeth = thisMeth; _parent = parent; }
internal void Resolve(PEReader buff, MethodDef meth) { if (resolved) return; }
/// <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 void CheckParent(MethodDef paren, PEReader buff) { Contract.Requires(buff != null); if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx)) { parent = paren; paren.InsertGenericParam(this); } }
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; }
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); }
/*-------------------- 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 ")); }
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; } }
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; }
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; }
/// <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); }
internal Scope(MethodDef thisMeth) : this(null, thisMeth) { }
/// <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); }
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; }