/*-------------------- 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); }
/*-------------------- Constructors ---------------------------------*/ internal ClassDef(PEFile scope, TypeAttr attrSet, string nsName, string name) : base(nsName, name) { Contract.Requires(scope != null); this.scope = scope; superType = MSCorLib.mscorlib.ObjectClass; flags = (uint)attrSet; tabIx = MDTable.TypeDef; }
/*-------------------- Constructors ---------------------------------*/ /// <summary> /// Create a new catch clause /// </summary> /// <param name="except">the exception to be caught</param> /// <param name="handlerStart">start of the handler code</param> /// <param name="handlerEnd">end of the handler code</param> public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd) : base(handlerStart, handlerEnd) { exceptType = except; }
internal override void Resolve(PEReader buff) { theClass = (ClassDef)buff.GetElement(MDTable.TypeDef, classIx); theInterface = (Class)buff.GetCodedElement(CIx.TypeDefOrRef, interfacesIndex); theClass.AddImplementedInterface(this); }
internal MethodDef(Class paren, MethSig mSig, Param[] pars) : base(mSig.name) { sig = mSig; parList = pars; parent = paren; tabIx = MDTable.Method; }
// FIXME: need a Setter for interfaces too! public void SetInterfaces(Class[] iFaces) { Contract.Requires(iFaces != null); interfaces = new ArrayList(iFaces.Length); foreach (Class iFace in iFaces) interfaces.Add(iFace); }
/*-------------------- 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)); } }
/// <summary> /// Add a nested class to this class /// </summary> /// <param name="attrSet">attributes for this nested class</param> /// <param name="name">nested class name</param> /// <param name="sType">super type of this nested class</param> /// <returns>a descriptor for this new nested class</returns> public NestedClassDef AddNestedClass(TypeAttr attrSet, string name, Class sType) { NestedClassDef nClass = AddNestedClass(attrSet, name); nClass.superType = sType; return (nClass); }
public override void MakeSpecial() { special = true; superType = null; flags = (uint)TypeAttr.Private; }
internal override void AddToClassList(Class aClass) { ((ClassDef)aClass).SetScope((PEFile)this); classes.Add(aClass); }
internal override void Resolve(PEReader buff) { buff.currentClassScope = this; superType = (Class)buff.GetCodedElement(CIx.TypeDefOrRef, extendsIx); if ((superType != null) && superType.isValueType()) typeIndex = (byte)ElementType.ValueType; for (int i = 0; fieldIx < fieldEndIx; i++, fieldIx++) { FieldDef field = (FieldDef)buff.GetElement(MDTable.Field, fieldIx); field.SetParent(this); fields.Add(field); } for (int i = 0; methodIx < methodEndIx; i++, methodIx++) { MethodDef meth = (MethodDef)buff.GetElement(MDTable.Method, methodIx); if (Diag.DiagOn) Console.WriteLine("Adding method " + meth.Name() + " to class " + Name); meth.SetParent(this); methods.Add(meth); } buff.currentClassScope = null; }
internal void SetClassParam(Class paren, int ix) { typeIndex = VAR; parent = paren; index = (ushort)ix; }
/// <summary> /// Mark this position as the end of the last started block and /// make it a catch block. This catch block is associated with the /// specified try block. /// </summary> /// <param name="exceptType">the exception type to be caught</param> /// <param name="tryBlock">the try block associated with this catch block</param> public void EndCatchBlock(Class exceptType, TryBlock tryBlock) { Catch catchBlock = new Catch(exceptType, (CILLabel)blockStack.Pop(), NewCodedLabel()); tryBlock.AddHandler(catchBlock); }
public void SetModifingType(Class mod) { cmodType = mod; }
/*-------------------- Constructors ---------------------------------*/ /// <summary> /// Create a new custom modifier for a type /// </summary> /// <param name="type">the type to be modified</param> /// <param name="cmod">the modifier</param> /// <param name="cmodType">the type reference to be associated with the type</param> public CustomModifiedType(Type type, CustomModifier cmod, Class cmodType) : base((byte)cmod) { Contract.Requires(type != null); Contract.Requires(cmodType != null); this.type = type; this.cmodType = cmodType; }
internal void ReplaceClass(Class aClass) { Contract.Requires(aClass != null); bool found = false; for (int i = 0; (i < classes.Count) && !found; i++) { if (((Class)classes[i]).Name == aClass.Name) { found = true; } } if (!found) classes.Add(aClass); }
internal virtual void AddToClassList(Class aClass) { Contract.Requires(aClass != null); classes.Add(aClass); }
/// <summary> /// Delete a class from this module /// </summary> /// <param name="aClass">The name of the class to be deleted</param> public void RemoveClass(Class aClass) { Contract.Requires(aClass != null); classes.Remove(aClass); }
/// <summary> /// Add a class to this PE File /// </summary> /// <param name="attrSet">attributes of this class</param> /// <param name="nsName">name space name</param> /// <param name="name">class name</param> /// <param name="superType">super type of this class (extends)</param> /// <returns>a descriptor for this new class</returns> public ClassDef AddClass(TypeAttr attrSet, string nsName, string name, Class superType) { ClassDef aClass = AddClass(attrSet, nsName, name); aClass.SuperType = superType; return aClass; }
/*-------------------- Constructors ---------------------------------*/ internal FieldDef(string name, Type fType, Class paren) : base(name, fType, paren) { tabIx = MDTable.Field; }
/// <summary> /// Add an interface that is implemented by this class /// </summary> /// <param name="iFace">the interface that is implemented</param> public void AddImplementedInterface(Class iFace) { interfaces.Add(new InterfaceImpl(this, iFace)); //metaData.AddToTable(MDTable.InterfaceImpl,new InterfaceImpl(this,iFace)); }
internal FieldDef(FieldAttr attrSet, string name, Type fType, Class paren) : base(name, fType, paren) { flags = (ushort)attrSet; tabIx = MDTable.Field; }
/// <summary> /// Get the interfaces implemented by this class /// </summary> /// <returns>List of implemented interfaces</returns> public Class[] GetInterfaces() { Class[] iFaces = new Class[interfaces.Count]; for (int i = 0; i < iFaces.Length; i++) { iFaces[i] = ((InterfaceImpl)interfaces[i]).TheInterface(); } return iFaces; }
/*-------------------- Constructors ---------------------------------*/ internal Field(string pfName, Type pfType, Class paren) : base(pfName, paren) { type = pfType; }
/*-------------------- Constructors ---------------------------------*/ internal FieldRef(Class paren, string name, Type fType) : base(name, fType, paren) { parent = paren; }
/*-------------------- Constructors ---------------------------------*/ internal MethodRef(Class paren, string name, Type retType, Type[] pars) : base(name, retType, paren) { sig.parTypes = pars; if (pars != null) sig.numPars = (uint)pars.Length; }
internal void AddToClassList(Class nClass) { Contract.Requires(nClass != null); nestedClasses.Add(nClass); }
/*-------------------- Constructors ---------------------------------*/ internal MethodDef(string name, Type retType, Param[] pars, Class paren) : base(name, retType, paren) { Contract.Requires(name != null); Contract.Requires(retType != null); Contract.Requires(pars != null); Contract.Requires(paren != null); sig.SetParTypes(pars); parList = pars; parent = paren; tabIx = MDTable.Method; }
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 InterfaceImpl(ClassDef theClass, TableRow theInterface) { Contract.Requires(theClass != null); Contract.Requires(theInterface != null); this.theClass = theClass; this.theInterface = (Class)theInterface; tabIx = MDTable.InterfaceImpl; }