public PEAPI.ClassRef GetType(string full_name, bool is_valuetype) { PEAPI.ClassRef klass = class_table[full_name] as PEAPI.ClassRef; if (klass != null) { return(klass); } string name_space, name; ExternTable.GetNameAndNamespace(full_name, out name_space, out name); if (is_valuetype) { klass = (PEAPI.ClassRef)GetExternRef().AddValueClass(name_space, name); } else { klass = (PEAPI.ClassRef)GetExternRef().AddClass(name_space, name); } class_table [full_name] = klass; return(klass); }
/// <summary> /// Add a value class to this external assembly /// </summary> /// <param name="nsName">name space name</param> /// <param name="name">class name</param> /// <returns></returns> public override ClassRef AddValueClass(string nsName, string name) { if (nsName.CompareTo(systemName) == 0) { int hash = name.GetHashCode(); if ((hash == specialNames[valueTypeIx]) || (hash == specialNames[valueTypeIx+1])) { return GetValueClass(name,hash); } } ClassRef aClass = new ClassRef(nsName,name,metaData); metaData.AddToTable(MDTable.TypeRef,aClass); aClass.SetParent(this); aClass.MakeValueClass(ValueClass.ValueType); return aClass; }
internal Class EnumType() { /* Called by both mscorlib & !mscorlib, so can be either ClassRef or ClassDef */ //systemClasses [ valueTypeIx + 1] -> System.Enum if (systemClasses[valueTypeIx + 1] == null && !PEFile.IsMSCorlib) { ClassRef valType = new ClassRef("System","Enum",metaData); valType.SetParent(this); valType.MakeValueClass(ValueClass.Enum); metaData.AddToTable(MDTable.TypeRef,valType); systemClasses[valueTypeIx + 1] = valType; } return systemClasses[valueTypeIx + 1]; }
internal Class ValueType() { if (systemClasses[valueTypeIx] == null && !PEFile.IsMSCorlib) { ClassRef valType = new ClassRef("System","ValueType",metaData); valType.SetParent(this); valType.MakeValueClass(ValueClass.ValueType); metaData.AddToTable(MDTable.TypeRef,valType); systemClasses[valueTypeIx] = valType; } return systemClasses[valueTypeIx]; }
private ClassRef GetValueClass(string name, int hash) { /* Called by MSCorLib.AddValueClass, which is called by !mscorlib, for adding ref to value class INTO mscorlib, so this should be classref */ int ix = valueTypeIx; if (hash != specialNames[valueTypeIx]) ix++; if (systemClasses[ix] == null) { systemClasses[ix] = new ClassRef(systemName,name,metaData); ((ClassRef) systemClasses[ix]).SetParent(this); ((ClassRef) systemClasses[ix]).MakeValueClass(ValueClass.ValueType); metaData.AddToTable(MDTable.TypeRef,systemClasses[ix]); } return (ClassRef) systemClasses[ix]; }
private Class GetSpecialClass(string nsName,string name) { if (nsName.CompareTo(systemName) != 0) return null; int hash = name.GetHashCode(); for (int i=0; i < specialNames.Length; i++) { if (hash != specialNames[i]) continue; if (systemClasses[i] == null) { if (i < valueTypeIx) { systemClasses[i] = new SystemClass(systemTypes[i],this,metaData); if ((systemTypes[i] != PrimitiveType.Object) && (systemTypes[i] != PrimitiveType.String)) { systemClasses[i].MakeValueClass(ValueClass.ValueType); } } else { systemClasses[i] = new ClassRef(nsName,name,metaData); ((ClassRef) systemClasses[i]).SetParent(this); if (!ClassDef.IsValueType (nsName, name) && !ClassDef.IsEnum (nsName, name)) systemClasses[i].MakeValueClass(ValueClass.ValueType); } metaData.AddToTable(MDTable.TypeRef,systemClasses[i]); } return systemClasses[i]; } return null; }
/// <summary> /// Add a class to the mscorlib assembly /// </summary> /// <param name="nsName">name space name</param> /// <param name="name">class name</param> /// <returns></returns> public override ClassRef AddClass(string nsName, string name) { /* This gets called by !mscorlib, for adding references INTO mscorlib, so it should be returning ClassRef ..*/ Class aClass = GetSpecialClass(nsName,name); if (aClass == null) { aClass = new ClassRef(nsName,name,metaData); metaData.AddToTable(MDTable.TypeRef,aClass); if (aClass is ClassRef) ((ClassRef) aClass).SetParent(this); } //FIXME: Check for !ClassRef here? return (ClassRef) aClass; }
/// <summary> /// Add a value class to this external assembly /// </summary> /// <param name="nsName">name space name</param> /// <param name="name">class name</param> /// <returns></returns> public virtual ClassRef AddValueClass(string nsName, string name) { ClassRef aClass = new ClassRef(nsName,name,metaData); metaData.AddToTable(MDTable.TypeRef,aClass); aClass.SetParent(this); aClass.MakeValueClass(ValueClass.ValueType); return aClass; }
/// <summary> /// Add a class to this external module. This is a class declared in /// another module of THIS assembly. /// </summary> /// <param name="nsName">name space name</param> /// <param name="name">class name</param> /// <returns>a descriptor for this class in another module</returns> public ClassRef AddClass(string nsName, string name) { ClassRef aClass = new ClassRef(nsName,name,metaData); metaData.AddToTable(MDTable.TypeRef,aClass); aClass.SetParent(this); return aClass; }
internal ClassRef EnumType() { //systemClasses [ valueTypeIx + 1] -> System.Enum if (systemClasses[valueTypeIx + 1] == null) { ClassRef valType = new ClassRef("System","Enum",metaData); valType.SetParent(this); valType.MakeValueClass(ValueClass.Enum); metaData.AddToTable(MDTable.TypeRef,valType); systemClasses[valueTypeIx + 1] = valType; } return systemClasses[valueTypeIx + 1]; }
private ClassRef GetValueClass(string name, int hash) { int ix = valueTypeIx; if (hash != specialNames[valueTypeIx]) ix++; if (systemClasses[ix] == null) { systemClasses[ix] = new ClassRef(systemName,name,metaData); systemClasses[ix].SetParent(this); systemClasses[ix].MakeValueClass(ValueClass.ValueType); metaData.AddToTable(MDTable.TypeRef,systemClasses[ix]); } return systemClasses[ix]; }
/// <summary> /// Add a class to the mscorlib assembly /// </summary> /// <param name="nsName">name space name</param> /// <param name="name">class name</param> /// <returns></returns> public override ClassRef AddClass(string nsName, string name) { ClassRef aClass = GetSpecialClass(nsName,name); if (aClass == null) { aClass = new ClassRef(nsName,name,metaData); metaData.AddToTable(MDTable.TypeRef,aClass); aClass.SetParent(this); } return aClass; }