public FieldDefOptions(FieldDef field) { this.Attributes = field.Attributes; this.Name = field.Name; this.FieldSig = field.FieldSig; this.FieldOffset = field.FieldOffset; this.MarshalType = field.MarshalType; this.RVA = field.RVA; this.InitialValue = field.InitialValue; this.ImplMap = field.ImplMap; this.Constant = field.Constant; this.CustomAttributes.AddRange(field.CustomAttributes); }
public FieldDefOptions(FieldDef field) { Attributes = field.Attributes; Name = field.Name; FieldSig = field.FieldSig; FieldOffset = field.FieldOffset; MarshalType = field.MarshalType; RVA = field.RVA; InitialValue = field.InitialValue; ImplMap = field.ImplMap; Constant = field.Constant; CustomAttributes.AddRange(field.CustomAttributes); }
public static FieldDefOptions Create(UTF8String name, FieldSig fieldSig) { return new FieldDefOptions { Attributes = FieldAttributes.Public, Name = name, FieldSig = fieldSig, FieldOffset = null, MarshalType = null, RVA = 0, InitialValue = null, ImplMap = null, Constant = null, }; }
public FieldDef create(byte[] data) { var arrayType = getArrayType(data.LongLength); var fieldSig = new FieldSig(new ValueTypeSig(arrayType)); var attrs = FieldAttributes.Assembly | FieldAttributes.Static; var field = new FieldDefUser(string.Format("field_{0}", unique++), fieldSig, attrs); module.UpdateRowId(field); field.HasFieldRVA = true; ourType.Fields.Add(field); var iv = new byte[data.Length]; Array.Copy(data, iv, data.Length); field.InitialValue = iv; return field; }
bool ContainsGenericParameterInternal(FieldSig fs) { if (fs == null) return false; if (!recursionCounter.Increment()) return false; bool res = ContainsGenericParameterInternal(fs.Type); recursionCounter.Decrement(); return res; }
/// <summary> /// Constructor /// </summary> /// <param name="name">Name</param> /// <param name="signature">Signature</param> /// <param name="attributes">Flags</param> public FieldDefUser(UTF8String name, FieldSig signature, FieldAttributes attributes) { this.name = name; this.signature = signature; this.attributes = (int)attributes; }
void Hash(FieldSig sig) { if (sig == null) return; hasher.Hash((byte)sig.GetCallingConvention()); Hash(sig.GetFieldType()); }
/// <summary> /// Returns the full name of a field /// </summary> /// <param name="declaringType">Declaring type full name or <c>null</c> if none</param> /// <param name="name">Name of field</param> /// <param name="fieldSig">Field signature</param> /// <param name="typeGenArgs">Type generic arguments or <c>null</c> if none</param> /// <returns>Field full name</returns> public static string FieldFullName(string declaringType, string name, FieldSig fieldSig, IList<TypeSig> typeGenArgs) { var fnc = new FullNameCreator(false, null); if (typeGenArgs != null) { fnc.genericArguments = new GenericArguments(); fnc.genericArguments.PushTypeArgs(typeGenArgs); } fnc.CreateFieldFullName(declaringType, name, fieldSig); return fnc.Result; }
/// <summary> /// Gets the size of this field in bytes or <c>0</c> if unknown. /// </summary> /// <param name="declaringType">The declaring type of <c>this</c></param> /// <param name="fieldSig">The field signature of <c>this</c></param> /// <param name="ptrSize">Size of a pointer</param> /// <param name="size">Updated with size</param> /// <returns><c>true</c> if <paramref name="size"/> is valid, <c>false</c> otherwise</returns> protected bool GetFieldSize(TypeDef declaringType, FieldSig fieldSig, int ptrSize, out uint size) { size = 0; if (fieldSig == null) return false; return GetClassSize(declaringType, fieldSig.Type, ptrSize, out size); }
/// <summary> /// Constructor /// </summary> /// <param name="module">Owner module</param> /// <param name="name">Name of field ref</param> /// <param name="sig">Field sig</param> public MemberRefUser(ModuleDef module, UTF8String name, FieldSig sig) : this(module, name, sig, null) { }
/// <summary> /// Constructor /// </summary> /// <param name="name">Name</param> /// <param name="signature">Signature</param> /// <param name="flags">Flags</param> public FieldDefUser(UTF8String name, FieldSig signature, FieldAttributes flags) { this.name = name; this.signature = signature; this.flags = flags; }
/// <summary> /// Constructor /// </summary> /// <param name="name">Name</param> /// <param name="signature">Signature</param> public FieldDefUser(UTF8String name, FieldSig signature) : this(name, signature, 0) { }
FieldSig ResolveGenericArgs(FieldSig sig) { return(new FieldSig(ResolveGenericArgs(sig.Type))); }
/// <summary> /// Gets the size of this field in bytes or <c>0</c> if unknown. /// </summary> /// <param name="declaringType">The declaring type of <c>this</c></param> /// <param name="fieldSig">The field signature of <c>this</c></param> /// <param name="size">Updated with size</param> /// <returns><c>true</c> if <paramref name="size"/> is valid, <c>false</c> otherwise</returns> protected bool GetFieldSize(TypeDef declaringType, FieldSig fieldSig, out uint size) { return(GetFieldSize(declaringType, fieldSig, GetPointerSize(declaringType), out size)); }
public static FieldSig Create(FieldSig sig, IList<TypeSig> genericArgs) { if (sig == null || genericArgs == null || genericArgs.Count == 0) return sig; return new GenericArgsSubstitutor(genericArgs).Create(sig); }
public static FieldSig Create(FieldSig sig, GenericInstSig git) { if (git == null) return sig; return Create(sig, git.GenericArguments); }
FieldSig Create(FieldSig sig) { var newSig = new FieldSig(Create2(sig.Type)); return updated ? newSig : sig; }
/// <summary> /// Checks whether <paramref name="fieldSig"/> contains a <see cref="GenericVar"/> or a /// <see cref="GenericMVar"/>. /// </summary> /// <param name="fieldSig">Field signature</param> /// <returns><c>true</c> if <paramref name="fieldSig"/> contains a <see cref="GenericVar"/> /// or a <see cref="GenericMVar"/>.</returns> public static bool ContainsGenericParameter(FieldSig fieldSig) { return new TypeHelper().ContainsGenericParameterInternal(fieldSig); }
/// <summary> /// Returns the full name of a field /// </summary> /// <param name="declaringType">Declaring type full name or <c>null</c> if none</param> /// <param name="name">Name of field</param> /// <param name="fieldSig">Field signature</param> /// <returns>Field full name</returns> public static string FieldFullName(string declaringType, UTF8String name, FieldSig fieldSig) { return FieldFullName(declaringType, UTF8String.ToSystemString(name), fieldSig, null); }
void Add(FieldSig sig) { if (sig == null) return; Add(sig.Type); }
/// <summary> /// Returns the full name of a field /// </summary> /// <param name="declaringType">Declaring type full name or <c>null</c> if none</param> /// <param name="name">Name of field</param> /// <param name="fieldSig">Field signature</param> /// <returns>Field full name</returns> public static string FieldFullName(string declaringType, string name, FieldSig fieldSig) { return FieldFullName(declaringType, name, fieldSig, null); }
/// <summary> /// Constructor /// </summary> /// <param name="module">Owner module</param> /// <param name="name">Name of field ref</param> /// <param name="sig">Field sig</param> /// <param name="class">Owner of field</param> public MemberRefUser(ModuleDef module, UTF8String name, FieldSig sig, IMemberRefParent @class) { this.module = module; this.name = name; this.@class = @class; this.signature = sig; }
/// <summary> /// Returns the full name of a field /// </summary> /// <param name="declaringType">Declaring type full name or <c>null</c> if none</param> /// <param name="name">Name of field</param> /// <param name="fieldSig">Field signature</param> /// <param name="typeGenArgs">Type generic arguments or <c>null</c> if none</param> /// <returns>Field full name</returns> public static string FieldFullName(string declaringType, UTF8String name, FieldSig fieldSig, IList<TypeSig> typeGenArgs) { return FieldFullName(declaringType, UTF8String.ToSystemString(name), fieldSig, typeGenArgs); }
void CreateFieldFullName(string declaringType, string name, FieldSig fieldSig) { CreateFullName(fieldSig == null ? null : fieldSig.Type); sb.Append(' '); if (declaringType != null) { sb.Append(declaringType); sb.Append("::"); } if (name != null) sb.Append(name); }
/// <summary> /// Gets the field type /// </summary> /// <param name="sig">this</param> /// <returns>Field type or <c>null</c> if none</returns> public static TypeSig GetFieldType(this FieldSig sig) { return(sig == null ? null : sig.Type); }
/// <summary> /// Gets the size of this field in bytes or <c>0</c> if unknown. /// </summary> /// <param name="declaringType">The declaring type of <c>this</c></param> /// <param name="fieldSig">The field signature of <c>this</c></param> /// <param name="size">Updated with size</param> /// <returns><c>true</c> if <paramref name="size"/> is valid, <c>false</c> otherwise</returns> protected bool GetFieldSize(TypeDef declaringType, FieldSig fieldSig, out uint size) { return GetFieldSize(declaringType, fieldSig, GetPointerSize(declaringType), out size); }
/// <summary> /// Checks whether <paramref name="fieldSig" /> contains a <see cref="GenericVar" /> or a /// <see cref="GenericMVar" />. /// </summary> /// <param name="fieldSig">Field signature</param> /// <returns> /// <c>true</c> if <paramref name="fieldSig" /> contains a <see cref="GenericVar" /> /// or a <see cref="GenericMVar" />. /// </returns> public static bool ContainsGenericParameter(FieldSig fieldSig) { return(new TypeHelper().ContainsGenericParameterInternal(fieldSig)); }
/// <summary> /// Returns the full name of a field /// </summary> /// <param name="declaringType">Declaring type full name or <c>null</c> if none</param> /// <param name="name">Name of field</param> /// <param name="fieldSig">Field signature</param> /// <param name="typeGenArgs">Type generic arguments or <c>null</c> if none</param> /// <param name="sb">String builder to use or null</param> /// <returns>Field full name</returns> public static string FieldFullName(string declaringType, string name, FieldSig fieldSig, IList<TypeSig> typeGenArgs, StringBuilder sb) { return FieldFullNameSB(declaringType, name, fieldSig, typeGenArgs, sb).ToString(); }
private static void ReFieldSig(FieldSig sig, ModuleDef module) { var ts = ReferenceType(sig.Type, module); if (ts != null) sig.Type = ts; }
/// <summary> /// Returns the full name of a field /// </summary> /// <param name="declaringType">Declaring type full name or <c>null</c> if none</param> /// <param name="name">Name of field</param> /// <param name="fieldSig">Field signature</param> /// <param name="typeGenArgs">Type generic arguments or <c>null</c> if none</param> /// <param name="sb">String builder to use or null</param> /// <returns>Field full name</returns> public static StringBuilder FieldFullNameSB(string declaringType, string name, FieldSig fieldSig, IList<TypeSig> typeGenArgs, StringBuilder sb) { var fnc = new FullNameCreator(false, null, sb); if (typeGenArgs != null) { fnc.genericArguments = new GenericArguments(); fnc.genericArguments.PushTypeArgs(typeGenArgs); } fnc.CreateFieldFullName(declaringType, name, fieldSig); return fnc.sb ?? new StringBuilder(); }