Exemplo n.º 1
0
 internal void AddRef(ReferenceScope refScope)
 {
     Contract.Requires(refScope != null);
     if (!externRefs.Contains(refScope))
     {
         externRefs.Add(refScope);
     }
 }
Exemplo n.º 2
0
        internal static ClassRef ReadClass(PEReader buff, ReferenceScope resScope)
        {
            uint     resScopeIx = buff.GetCodedIndex(CIx.ResolutionScope);
            string   name       = buff.GetString();
            string   nameSpace  = buff.GetString();
            ClassRef newClass   = (ClassRef)resScope.GetExistingClass(nameSpace, name);

            if (newClass == null)
            {
                newClass = new ClassRef(resScope, nameSpace, name);
            }
            return(newClass);
        }
Exemplo n.º 3
0
        internal static ClassRef ReadDef(PEReader buff, ReferenceScope resScope, uint index)
        {
            uint     junk     = buff.ReadUInt32();
            string   cName    = buff.GetString();
            string   nsName   = buff.GetString();
            ClassRef newClass = (ClassRef)resScope.GetExistingClass(nsName, cName);

            if (newClass == null)
            {
                newClass = new ClassRef(resScope, nsName, cName);
                resScope.AddToClassList(newClass);
            }
            newClass.readAsDef = true;
            newClass.Row       = index;
            junk              = buff.GetCodedIndex(CIx.TypeDefOrRef);
            newClass.fieldIx  = buff.GetIndex(MDTable.Field);
            newClass.methodIx = buff.GetIndex(MDTable.Method);
            return(newClass);
        }
Exemplo n.º 4
0
        internal virtual void ResolveParent(PEReader buff, bool isExtern)
        {
            CIx cIx = CIx.ResolutionScope;

            if (isExtern)
            {
                cIx = CIx.Implementation;
            }
            if (scope != null)
            {
                return;
            }
            MetaDataElement parentScope = buff.GetCodedElement(cIx, resScopeIx);

            if (parentScope is Module)
            {  // special code for glitch in Everett ilasm
                ClassDef newDef = new ClassDef((PEFile)parentScope, 0, NameSpace, Name);
                ((Module)parentScope).AddToClassList(newDef);
                buff.InsertInTable(MDTable.TypeRef, Row, newDef);
            }
            else
            {
                scope = (ReferenceScope)buff.GetCodedElement(cIx, resScopeIx);
                ClassRef existing = (ClassRef)scope.GetExistingClass(NameSpace, Name);
                if (existing == null)
                {
                    scope.AddToClassList(this);
                }
                else
                {
                    if (isExtern)
                    {
                        buff.InsertInTable(MDTable.ExportedType, Row, existing);
                    }
                    else
                    {
                        buff.InsertInTable(MDTable.TypeRef, Row, existing);
                    }
                }
            }
        }
Exemplo n.º 5
0
 internal void AddRef(ReferenceScope refScope)
 {
     Contract.Requires(refScope != null);
     if (!externRefs.Contains(refScope))
     {
         externRefs.Add(refScope);
     }
 }
Exemplo n.º 6
0
 internal SystemClass(ReferenceScope paren, PrimitiveType eType)
     : base(paren, "System", eType.GetName())
 {
     elemType = eType;
 }
Exemplo n.º 7
0
 internal NestedClassRef(ReferenceScope scope, string nsName, string name)
     : base(scope, nsName, name)
 {
 }
Exemplo n.º 8
0
 /*-------------------- Constructors ---------------------------------*/
 internal ClassRef(ReferenceScope scope, string nsName, string name)
     : base(nsName, name)
 {
     this.scope = scope;
     tabIx = MDTable.TypeRef;
 }
Exemplo n.º 9
0
 internal void SetScope(ReferenceScope scope)
 {
     this.scope = scope;
 }
Exemplo n.º 10
0
 internal virtual void ResolveParent(PEReader buff, bool isExtern)
 {
     CIx cIx = CIx.ResolutionScope;
     if (isExtern) cIx = CIx.Implementation;
     if (scope != null) return;
     MetaDataElement parentScope = buff.GetCodedElement(cIx, resScopeIx);
     if (parentScope is Module)
     {  // special code for glitch in Everett ilasm
         ClassDef newDef = new ClassDef((PEFile)parentScope, 0, NameSpace, Name);
         ((Module)parentScope).AddToClassList(newDef);
         buff.InsertInTable(MDTable.TypeRef, Row, newDef);
     }
     else
     {
         scope = (ReferenceScope)buff.GetCodedElement(cIx, resScopeIx);
         ClassRef existing = (ClassRef)scope.GetExistingClass(NameSpace, Name);
         if (existing == null)
         {
             scope.AddToClassList(this);
         }
         else
         {
             if (isExtern)
                 buff.InsertInTable(MDTable.ExportedType, Row, existing);
             else
                 buff.InsertInTable(MDTable.TypeRef, Row, existing);
         }
     }
 }
Exemplo n.º 11
0
 internal static ClassRef ReadClass(PEReader buff, ReferenceScope resScope)
 {
     uint resScopeIx = buff.GetCodedIndex(CIx.ResolutionScope);
     string name = buff.GetString();
     string nameSpace = buff.GetString();
     ClassRef newClass = (ClassRef)resScope.GetExistingClass(nameSpace, name);
     if (newClass == null)
         newClass = new ClassRef(resScope, nameSpace, name);
     return newClass;
 }
Exemplo n.º 12
0
 internal SystemClass(ReferenceScope paren, PrimitiveType eType)
     : base(paren, "System", eType.GetName())
 {
     elemType = eType;
 }
Exemplo n.º 13
0
 internal NestedClassRef(ReferenceScope scope, string nsName, string name)
     : base(scope, nsName, name)
 {
 }
Exemplo n.º 14
0
        /*-------------------- Constructors ---------------------------------*/

        internal ClassRef(ReferenceScope scope, string nsName, string name)
            : base(nsName, name)
        {
            this.scope = scope;
            tabIx      = MDTable.TypeRef;
        }
Exemplo n.º 15
0
 internal void SetScope(ReferenceScope scope)
 {
     this.scope = scope;
 }
Exemplo n.º 16
0
 internal static void GetClassRefs(PEReader buff, TableRow[] typeRefs, ReferenceScope paren, uint[] parIxs)
 {
     Contract.Requires(buff != null);
     Contract.Requires(typeRefs != null);
     Contract.Requires(paren != null);
     Contract.Requires(parIxs != null);
     int num = typeRefs.Length;
     uint[] fieldStart = new uint[num + 1], methStart = new uint[num + 1], extends = new uint[num + 1];
     for (int i = 0; i < num; i++)
     {
         uint flags = buff.ReadUInt32();
         string name = buff.GetString();
         string nameSpace = buff.GetString();
         extends[i] = buff.GetCodedIndex(CIx.TypeDefOrRef);
         fieldStart[i] = buff.GetIndex(MDTable.Field);
         methStart[i] = buff.GetIndex(MDTable.Method);
         //Console.WriteLine("flags = " + Hex.Int(flags));
         if (i == 0) // ASSERT first entry is always <Module>
             typeRefs[i] = paren.GetDefaultClass();
         else if (isPublic(flags))
         {
             if (parIxs[i] != 0)
             {
                 typeRefs[i] = new NestedClassRef(paren, nameSpace, name);
             }
             else
             {
                 typeRefs[i] = paren.GetExistingClass(nameSpace, name);
                 if (typeRefs[i] == null)
                 {
                     typeRefs[i] = new ClassRef(paren, nameSpace, name);
                     paren.AddToClassList((ClassRef)typeRefs[i]);
                 }
             }
         }
     }
     fieldStart[num] = buff.GetTableSize(MDTable.Field) + 1;
     methStart[num] = buff.GetTableSize(MDTable.Method) + 1;
     // Find Nested Classes
     for (int i = 0; i < typeRefs.Length; i++)
     {
         if ((typeRefs[i] != null) && (typeRefs[i] is NestedClassRef))
         {
             NestedClassRef nRef = (NestedClassRef)typeRefs[i];
             ClassRef nPar = (ClassRef)typeRefs[parIxs[i] - 1];
             if (nPar == null)
             {  // parent is private, so ignore
                 typeRefs[i] = null;
             }
             else
             {
                 nRef.SetParent(nPar);
                 nPar.AddToClassList(nRef);
             }
         }
         if (typeRefs[i] != null)
         {
             if (buff.GetCodedElement(CIx.TypeDefOrRef, extends[i]) == MSCorLib.mscorlib.ValueType())
                 ((ClassRef)typeRefs[i]).MakeValueClass();
             buff.SetElementPosition(MDTable.Field, fieldStart[i]);
             FieldDef.GetFieldRefs(buff, fieldStart[i + 1] - fieldStart[i], (ClassRef)typeRefs[i]);
             buff.SetElementPosition(MDTable.Method, methStart[i]);
             MethodDef.GetMethodRefs(buff, methStart[i + 1] - methStart[i], (ClassRef)typeRefs[i]);
         }
     }
 }
Exemplo n.º 17
0
 internal static ClassRef ReadDef(PEReader buff, ReferenceScope resScope, uint index)
 {
     uint junk = buff.ReadUInt32();
     string cName = buff.GetString();
     string nsName = buff.GetString();
     ClassRef newClass = (ClassRef)resScope.GetExistingClass(nsName, cName);
     if (newClass == null)
     {
         newClass = new ClassRef(resScope, nsName, cName);
         resScope.AddToClassList(newClass);
     }
     newClass.readAsDef = true;
     newClass.Row = index;
     junk = buff.GetCodedIndex(CIx.TypeDefOrRef);
     newClass.fieldIx = buff.GetIndex(MDTable.Field);
     newClass.methodIx = buff.GetIndex(MDTable.Method);
     return newClass;
 }