void ReadMethodDefSig(MethodDefSig methodDef, byte [] data, int pos, out int start) { methodDef.CallingConvention = data [pos]; start = pos + 1; methodDef.HasThis = (methodDef.CallingConvention & 0x20) != 0; methodDef.ExplicitThis = (methodDef.CallingConvention & 0x40) != 0; if ((methodDef.CallingConvention & 0x5) != 0) { methodDef.MethCallConv |= MethodCallingConvention.VarArg; } else if ((methodDef.CallingConvention & 0x10) != 0) { methodDef.MethCallConv |= MethodCallingConvention.Generic; methodDef.GenericParameterCount = Utilities.ReadCompressedInteger(data, start, out start); } else { methodDef.MethCallConv |= MethodCallingConvention.Default; } methodDef.ParamCount = Utilities.ReadCompressedInteger(data, start, out start); methodDef.RetType = ReadRetType(data, start, out start); int sentpos; methodDef.Parameters = ReadParameters(methodDef.ParamCount, data, start, out start, out sentpos); methodDef.Sentinel = sentpos; }
/* * * public MarshalSig GetMarshalSig (uint index) * { * MarshalSig ms = m_signatures [index] as MarshalSig; * if (ms == null) { * byte [] data = m_root.Streams.BlobHeap.Read (index); * ms = ReadMarshalSig (data); * m_signatures [index] = ms; * } * return ms; * } * */ public MethodSig GetStandAloneMethodSig(uint index) { int start; if ((m_blobData [index] & 0x5) > 0) { MethodRefSig mrs = new MethodRefSig(index); ReadMethodRefSig(mrs, m_blobData, (int)index, out start); return(mrs); } else { MethodDefSig mds = new MethodDefSig(index); ReadMethodDefSig(mds, m_blobData, (int)index, out start); return(mds); } }
public uint AddMethodDefSig (MethodDefSig methSig) { return AddSignature (methSig); }
public override void VisitMethodDefSig (MethodDefSig methodDef) { m_sigWriter.Write (methodDef.CallingConvention); if (methodDef.GenericParameterCount > 0) Write (methodDef.GenericParameterCount); Write (methodDef.ParamCount); Write (methodDef.RetType); Write (methodDef.Parameters, methodDef.Sentinel); }
public MethodDefSig GetMethodDefSig(MethodReference meth) { MethodDefSig sig = new MethodDefSig (); CompleteMethodSig (meth, sig); if (meth.GenericParameters.Count > 0) { sig.CallingConvention |= 0x10; sig.GenericParameterCount = meth.GenericParameters.Count; } return sig; }
public MethodDefSig GetMethodDefSig(IMethodSignature meth) { MethodDefSig sig = new MethodDefSig (); CompleteMethodSig (meth, sig); MethodReference methodRef = meth as MethodReference; if (methodRef != null && methodRef.GenericParameters.Count > 0) { sig.CallingConvention |= 0x10; sig.GenericParameterCount = methodRef.GenericParameters.Count; } return sig; }
SigType ReadType(byte [] data, int pos, out int start) { start = pos; ElementType element = (ElementType) Utilities.ReadCompressedInteger (data, start, out start); switch (element) { case ElementType.ValueType : VALUETYPE vt = new VALUETYPE (); vt.Type = Utilities.GetMetadataToken(CodedIndex.TypeDefOrRef, (uint) Utilities.ReadCompressedInteger (data, start, out start)); return vt; case ElementType.Class : CLASS c = new CLASS (); c.Type = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, (uint) Utilities.ReadCompressedInteger (data, start, out start)); return c; case ElementType.Ptr : PTR p = new PTR (); int buf = start; int flag = Utilities.ReadCompressedInteger (data, start, out start); p.Void = flag == (int) ElementType.Void; if (p.Void) return p; start = buf; p.CustomMods = ReadCustomMods (data, start, out start); p.PtrType = ReadType (data, start, out start); return p; case ElementType.FnPtr : FNPTR fp = new FNPTR (); if ((data [start] & 0x5) != 0) { MethodRefSig mr = new MethodRefSig ((uint) start); ReadMethodRefSig (mr, data, start, out start); fp.Method = mr; } else { MethodDefSig md = new MethodDefSig ((uint) start); ReadMethodDefSig (md, data, start, out start); fp.Method = md; } return fp; case ElementType.Array : ARRAY ary = new ARRAY (); ary.CustomMods = ReadCustomMods (data, start, out start); ArrayShape shape = new ArrayShape (); ary.Type = ReadType (data, start, out start); shape.Rank = Utilities.ReadCompressedInteger (data, start, out start); shape.NumSizes = Utilities.ReadCompressedInteger (data, start, out start); shape.Sizes = new int [shape.NumSizes]; for (int i = 0; i < shape.NumSizes; i++) shape.Sizes [i] = Utilities.ReadCompressedInteger (data, start, out start); shape.NumLoBounds = Utilities.ReadCompressedInteger (data, start, out start); shape.LoBounds = new int [shape.NumLoBounds]; for (int i = 0; i < shape.NumLoBounds; i++) shape.LoBounds [i] = Utilities.ReadCompressedInteger (data, start, out start); ary.Shape = shape; return ary; case ElementType.SzArray : SZARRAY sa = new SZARRAY (); sa.CustomMods = ReadCustomMods (data, start, out start); sa.Type = ReadType (data, start, out start); return sa; case ElementType.Var: return new VAR (Utilities.ReadCompressedInteger (data, start, out start)); case ElementType.MVar: return new MVAR (Utilities.ReadCompressedInteger (data, start, out start)); case ElementType.GenericInst: GENERICINST ginst = new GENERICINST (); ginst.ValueType = ((ElementType) Utilities.ReadCompressedInteger ( data, start, out start)) == ElementType.ValueType; ginst.Type = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef, (uint) Utilities.ReadCompressedInteger (data, start, out start)); ginst.Signature = ReadGenericInstSignature (data, start, out start); return ginst; default : return new SigType (element); } }
void ReadMethodDefSig(MethodDefSig methodDef, byte [] data, int pos, out int start) { methodDef.CallingConvention = data [pos]; start = pos + 1; methodDef.HasThis = (methodDef.CallingConvention & 0x20) != 0; methodDef.ExplicitThis = (methodDef.CallingConvention & 0x40) != 0; if ((methodDef.CallingConvention & 0x5) != 0) methodDef.MethCallConv |= MethodCallingConvention.VarArg; else if ((methodDef.CallingConvention & 0x10) != 0) { methodDef.MethCallConv |= MethodCallingConvention.Generic; methodDef.GenericParameterCount = Utilities.ReadCompressedInteger (data, start, out start); } else methodDef.MethCallConv |= MethodCallingConvention.Default; methodDef.ParamCount = Utilities.ReadCompressedInteger (data, start, out start); methodDef.RetType = ReadRetType (data, start, out start); int sentpos; methodDef.Parameters = ReadParameters (methodDef.ParamCount, data, start, out start, out sentpos); methodDef.Sentinel = sentpos; }
public override void VisitMethodDefSig(MethodDefSig methodDef) { int start; ReadMethodDefSig (methodDef, m_root.Streams.BlobHeap.Read (methodDef.BlobIndex), 0, out start); }
public MethodSig GetStandAloneMethodSig(uint index) { byte [] data = m_root.Streams.BlobHeap.Read (index); int start; if ((data [0] & 0x5) > 0) { MethodRefSig mrs = new MethodRefSig (index); ReadMethodRefSig (mrs, data, 0, out start); return mrs; } else { MethodDefSig mds = new MethodDefSig (index); ReadMethodDefSig (mds, data, 0, out start); return mds; } }
public MethodDefSig GetMethodDefSig(uint index) { MethodDefSig m = m_signatures [index] as MethodDefSig; if (m == null) { m = new MethodDefSig (index); m.Accept (this); m_signatures [index] = m; } return m; }
public override void VisitMethodDefSig(MethodDefSig methodDef) { int start; ReadMethodDefSig(methodDef, m_blobData, (int)methodDef.BlobIndex, out start); }
public override void VisitMethodDefSig (MethodDefSig methodDef) { int start; ReadMethodDefSig (methodDef, m_blobData, (int)methodDef.BlobIndex, out start); }
/* public MarshalSig GetMarshalSig (uint index) { MarshalSig ms = m_signatures [index] as MarshalSig; if (ms == null) { byte [] data = m_root.Streams.BlobHeap.Read (index); ms = ReadMarshalSig (data); m_signatures [index] = ms; } return ms; } */ public MethodSig GetStandAloneMethodSig (uint index) { int start; if ((m_blobData [index] & 0x5) > 0) { MethodRefSig mrs = new MethodRefSig (index); ReadMethodRefSig (mrs, m_blobData, (int)index, out start); return mrs; } else { MethodDefSig mds = new MethodDefSig (index); ReadMethodDefSig (mds, m_blobData, (int)index, out start); return mds; } }