Esempio n. 1
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);
 }
Esempio n. 2
0
 /*-------------------- 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;
 }
Esempio n. 3
0
 /*-------------------- 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;
 }
Esempio n. 4
0
 internal override void Resolve(PEReader buff)
 {
     theClass = (ClassDef)buff.GetElement(MDTable.TypeDef, classIx);
     theInterface = (Class)buff.GetCodedElement(CIx.TypeDefOrRef, interfacesIndex);
     theClass.AddImplementedInterface(this);
 }
Esempio n. 5
0
 internal MethodDef(Class paren, MethSig mSig, Param[] pars)
     : base(mSig.name)
 {
     sig = mSig;
     parList = pars;
     parent = paren;
     tabIx = MDTable.Method;
 }
Esempio n. 6
0
 //  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);
 }
Esempio n. 7
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));
     }
 }
Esempio n. 8
0
 /// <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);
 }
Esempio n. 9
0
 public override void MakeSpecial()
 {
     special = true;
     superType = null;
     flags = (uint)TypeAttr.Private;
 }
Esempio n. 10
0
 internal override void AddToClassList(Class aClass)
 {
     ((ClassDef)aClass).SetScope((PEFile)this);
     classes.Add(aClass);
 }
Esempio n. 11
0
 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;
 }
Esempio n. 12
0
 internal void SetClassParam(Class paren, int ix)
 {
     typeIndex = VAR;
     parent = paren;
     index = (ushort)ix;
 }
Esempio n. 13
0
 /// <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);
 }
Esempio n. 14
0
 public void SetModifingType(Class mod)
 {
     cmodType = mod;
 }
Esempio n. 15
0
 /*-------------------- 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;
 }
Esempio n. 16
0
 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);
 }
Esempio n. 17
0
 internal virtual void AddToClassList(Class aClass)
 {
     Contract.Requires(aClass != null);
     classes.Add(aClass);
 }
Esempio n. 18
0
 /// <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);
 }
Esempio n. 19
0
 /// <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;
 }
Esempio n. 20
0
 /*-------------------- Constructors ---------------------------------*/
 internal FieldDef(string name, Type fType, Class paren)
     : base(name, fType, paren)
 {
     tabIx = MDTable.Field;
 }
Esempio n. 21
0
 /// <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));
 }
Esempio n. 22
0
 internal FieldDef(FieldAttr attrSet, string name, Type fType, Class paren)
     : base(name, fType, paren)
 {
     flags = (ushort)attrSet;
     tabIx = MDTable.Field;
 }
Esempio n. 23
0
 /// <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;
 }
Esempio n. 24
0
 /*-------------------- Constructors ---------------------------------*/
 internal Field(string pfName, Type pfType, Class paren)
     : base(pfName, paren)
 {
     type = pfType;
 }
Esempio n. 25
0
 /*-------------------- Constructors ---------------------------------*/
 internal FieldRef(Class paren, string name, Type fType)
     : base(name, fType, paren)
 {
     parent = paren;
 }
Esempio n. 26
0
 /*-------------------- 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;
 }
Esempio n. 27
0
 internal void AddToClassList(Class nClass)
 {
     Contract.Requires(nClass != null);
     nestedClasses.Add(nClass);
 }
Esempio n. 28
0
 /*-------------------- 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;
 }
Esempio n. 29
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;
 }
Esempio n. 30
0
 internal InterfaceImpl(ClassDef theClass, TableRow theInterface)
 {
     Contract.Requires(theClass != null);
     Contract.Requires(theInterface != null);
     this.theClass = theClass;
     this.theInterface = (Class)theInterface;
     tabIx = MDTable.InterfaceImpl;
 }