/// <summary> /// Create the FieldRef equivalent to this FieldDef. If one does not /// exist then create it. /// </summary> /// <returns>FieldRef for this FieldDef</returns> public FieldRef MakeRefOf() { if (refOf != null) { return(refOf); } ClassRef parRef = ((ClassDef)parent).MakeRefOf(); refOf = parRef.GetField(name); if (refOf == null) { Type refType; if (type is ClassDef) { refType = ((ClassDef)type).MakeRefOf(); } else { refType = type; } refOf = new FieldRef(parRef, name, refType); refOf.defOf = this; } return(refOf); }
/// <summary> /// Add a field to this scope. /// </summary> /// <param name="name">field name</param> /// <param name="fType">field type</param> /// <returns>a descriptor for the field "name" in this scope</returns> public FieldRef AddField(string name, Type fType) { Contract.Requires(name != null); Contract.Requires(fType != null); FieldRef field = defaultClass.AddField(name, fType); return(field); }
/// <summary> /// Add a number of fields to this scope. /// </summary> /// <param name="flds">The fields to be added.</param> // FIXME not called internal void AddFields(ArrayList flds) { Contract.Requires(flds != null); foreach (object obj in flds) { FieldRef fld = (FieldRef)obj; defaultClass.AddField(fld); } }
/// <summary> /// Add a field to this class /// </summary> /// <param name="name">field name</param> /// <param name="fType">field type</param> /// <returns>a descriptor for this field</returns> public FieldRef AddField(string name, Type fType) { Contract.Requires(name != null); Contract.Requires(fType != null); FieldRef fld = (FieldRef)FindField(name); if (fld != null) DescriptorError(fld); fld = new FieldRef(this, name, fType); fields.Add(fld); return fld; }
/// <summary> /// Add a field to this class /// </summary> /// <param name="name">field name</param> /// <param name="fType">field type</param> /// <returns>a descriptor for this field</returns> public FieldRef AddField(string name, Type fType) { Contract.Requires(name != null); Contract.Requires(fType != null); FieldRef fld = (FieldRef)FindField(name); if (fld != null) { DescriptorError(fld); } fld = new FieldRef(this, name, fType); fields.Add(fld); return(fld); }
internal void CalcElemSize() { elemSize[(int)MDTable.Assembly] = Assembly.Size(this); elemSize[(int)MDTable.AssemblyOS] = 12; elemSize[(int)MDTable.AssemblyProcessor] = 4; elemSize[(int)MDTable.AssemblyRefOS] = 12 + TableIndexSize(MDTable.AssemblyRef); elemSize[(int)MDTable.AssemblyRefProcessor] = 4 + TableIndexSize(MDTable.AssemblyRef); elemSize[(int)MDTable.Module] = Module.Size(this); elemSize[(int)MDTable.TypeRef] = ClassRef.Size(this); elemSize[(int)MDTable.TypeDef] = ClassDef.Size(this); elemSize[(int)MDTable.Field] = FieldDef.Size(this); elemSize[(int)MDTable.Method] = MethodDef.Size(this); elemSize[(int)MDTable.Param] = Param.Size(this); elemSize[(int)MDTable.InterfaceImpl] = InterfaceImpl.Size(this); elemSize[(int)MDTable.MemberRef] = FieldRef.Size(this); elemSize[(int)MDTable.Constant] = ConstantElem.Size(this); elemSize[(int)MDTable.CustomAttribute] = CustomAttribute.Size(this); elemSize[(int)MDTable.FieldMarshal] = FieldMarshal.Size(this); elemSize[(int)MDTable.DeclSecurity] = DeclSecurity.Size(this); elemSize[(int)MDTable.ClassLayout] = ClassLayout.Size(this); elemSize[(int)MDTable.FieldLayout] = FieldLayout.Size(this); elemSize[(int)MDTable.StandAloneSig] = Signature.Size(this); elemSize[(int)MDTable.EventMap] = MapElem.Size(this, MDTable.EventMap); elemSize[(int)MDTable.Event] = Event.Size(this); elemSize[(int)MDTable.PropertyMap] = MapElem.Size(this, MDTable.PropertyMap); elemSize[(int)MDTable.Property] = Property.Size(this); elemSize[(int)MDTable.MethodSemantics] = MethodSemantics.Size(this); elemSize[(int)MDTable.MethodImpl] = MethodImpl.Size(this); elemSize[(int)MDTable.ModuleRef] = ModuleRef.Size(this); elemSize[(int)MDTable.TypeSpec] = TypeSpec.Size(this); elemSize[(int)MDTable.ImplMap] = ImplMap.Size(this); elemSize[(int)MDTable.FieldRVA] = FieldRVA.Size(this); elemSize[(int)MDTable.Assembly] = Assembly.Size(this); elemSize[(int)MDTable.AssemblyRef] = AssemblyRef.Size(this); elemSize[(int)MDTable.File] = FileRef.Size(this); elemSize[(int)MDTable.ExportedType] = ExternClass.Size(this); elemSize[(int)MDTable.ManifestResource] = ManifestResource.Size(this); elemSize[(int)MDTable.NestedClass] = MapElem.Size(this, MDTable.NestedClass); elemSize[(int)MDTable.GenericParam] = GenericParam.Size(this); elemSize[(int)MDTable.GenericParamConstraint] = GenericParamConstraint.Size(this); elemSize[(int)MDTable.MethodSpec] = MethodSpec.Size(this); }
internal static void GetFieldRefs(PEReader buff, uint num, ClassRef parent) { for (int i = 0; i < num; i++) { uint flags = buff.ReadUInt16(); string name = buff.GetString(); uint sigIx = buff.GetBlobIx(); if ((flags & (uint)FieldAttr.Public) == (uint)FieldAttr.Public) { if (parent.GetField(name) == null) { //Console.WriteLine(parent.NameString()); buff.currentClassScope = parent; FieldRef fRef = new FieldRef(parent, name, buff.GetFieldType(sigIx)); buff.currentClassScope = null; parent.AddToFieldList(fRef); } } } }
/// <summary> /// Create the FieldRef equivalent to this FieldDef. If one does not /// exist then create it. /// </summary> /// <returns>FieldRef for this FieldDef</returns> public FieldRef MakeRefOf() { if (refOf != null) return refOf; ClassRef parRef = ((ClassDef)parent).MakeRefOf(); refOf = parRef.GetField(name); if (refOf == null) { Type refType; if (type is ClassDef) { refType = ((ClassDef)type).MakeRefOf(); } else { refType = type; } refOf = new FieldRef(parRef, name, refType); refOf.defOf = this; } return refOf; }
internal void AddToFieldList(FieldRef fld) { Contract.Requires(fld != null); defaultClass.AddToFieldList(fld); }
/// <summary> /// Add a field to this scope. /// </summary> /// <param name="fld">The field to be added</param> // FIXME not called public void AddField(FieldRef fld) { Contract.Requires(fld != null); defaultClass.AddField(fld); }
internal void AddField(FieldRef fld) { Contract.Requires(fld != null); fields.Add(fld); fld.SetParent(this); }