void Write(FieldSig sig) { if (sig == null) { helper.Error("sig is null"); return; } if (!recursionCounter.Increment()) { helper.Error("Infinite recursion"); return; } writer.Write((byte)sig.GetCallingConvention()); Write(sig.Type); recursionCounter.Decrement(); }
public virtual void VisitFieldSig (FieldSig field) { }
FieldSig ResolveGenericArgs(FieldSig sig) { return(new FieldSig(ResolveGenericArgs(sig.Type))); }
public IRType PresolveType(FieldSig pFieldSig) { return(PresolveType(pFieldSig.Type)); }
/// <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; }
FieldSig ResolveGenericArgs(FieldSig sig) => new FieldSig(ResolveGenericArgs(sig.Type));
/// <summary> /// Constructor /// </summary> /// <param name="name">Name</param> /// <param name="signature">Signature</param> public FieldDefUser(UTF8String name, FieldSig signature) : this(name, signature, 0) { }
void Write(BinaryWriter writer, FieldSig sig) { writer.Write((byte)ObjectType.FieldSig); writer.Write((byte)(sig == null ? 0 : sig.GetCallingConvention())); Write(writer, sig.GetFieldType()); }
public virtual void VisitFieldSig(FieldSig field) { }
public MemberReference GetMemberRefAt(uint rid, GenericContext context) { int index = (int)rid - 1; MemberReference member = m_memberRefs [rid - 1]; if (member != null) { return(member); } MemberRefTable mrTable = m_tableReader.GetMemberRefTable(); MemberRefRow mrefRow = mrTable [index]; Signature sig = m_sigReader.GetMemberRefSig(mrefRow.Class.TokenType, mrefRow.Signature); switch (mrefRow.Class.TokenType) { case TokenType.TypeDef: case TokenType.TypeRef: case TokenType.TypeSpec: TypeReference declaringType = GetTypeDefOrRef(mrefRow.Class, context); GenericContext nc = context.Clone(); if (declaringType is GenericInstanceType) { TypeReference ct = declaringType; while (ct is GenericInstanceType) { ct = (ct as GenericInstanceType).ElementType; } nc.Type = ct; nc.AllowCreation = ct.GetType() == typeof(TypeReference); } if (sig is FieldSig) { FieldSig fs = sig as FieldSig; member = new FieldReference( m_root.Streams.StringsHeap [mrefRow.Name], declaringType, GetTypeRefFromSig(fs.Type, nc)); } else { string name = m_root.Streams.StringsHeap [mrefRow.Name]; MethodSig ms = (MethodSig)sig; MethodReference methref = new MethodReference( name, ms.HasThis, ms.ExplicitThis, ms.MethCallConv); methref.DeclaringType = declaringType; if (sig is MethodDefSig) { int arity = (sig as MethodDefSig).GenericParameterCount; for (int i = 0; i < arity; i++) { methref.GenericParameters.Add(new GenericParameter(i, methref)); } } if (methref.GenericParameters.Count > 0) { nc.Method = methref; } methref.ReturnType = GetMethodReturnType(ms, nc); methref.ReturnType.Method = methref; for (int j = 0; j < ms.ParamCount; j++) { Param p = ms.Parameters [j]; ParameterDefinition pdef = BuildParameterDefinition( string.Concat("A_", j), j, new ParameterAttributes(), p, nc); pdef.Method = methref; methref.Parameters.Add(pdef); } member = methref; } break; case TokenType.Method: // really not sure about this MethodDefinition methdef = GetMethodDefAt(mrefRow.Class.RID); MethodReference methRef = new MethodReference( methdef.Name, methdef.HasThis, methdef.ExplicitThis, methdef.CallingConvention); methRef.DeclaringType = methdef.DeclaringType; methRef.ReturnType = methdef.ReturnType; foreach (ParameterDefinition param in methdef.Parameters) { methRef.Parameters.Add(param); } member = methRef; break; case TokenType.ModuleRef: break; // TODO, implement that, or not } member.MetadataToken = MetadataToken.FromMetadataRow(TokenType.MemberRef, index); m_module.MemberReferences.Add(member); m_memberRefs [index] = member; return(member); }
FieldSig Create(FieldSig sig) { var newSig = new FieldSig(Create2(sig.Type)); return(updated ? newSig : sig); }