internal void SetScope(ReferenceScope scope) { this.scope = scope; }
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; }
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); } } }
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; }
/*-------------------- Constructors ---------------------------------*/ internal ClassRef(ReferenceScope scope, string nsName, string name) : base(nsName, name) { this.scope = scope; tabIx = MDTable.TypeRef; }
internal static void GetClassRefs(PEReader buff, TableRow[] typeRefs, ReferenceScope paren, uint[] parIxs) { 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]); } } }
internal void AddRef(ReferenceScope refScope) { if (!externRefs.Contains(refScope)) { externRefs.Add(refScope); } }
internal NestedClassRef(ReferenceScope scope, string nsName, string name) : base(scope,nsName,name) { }