/// <summary> /// Initializes a new instance of the <see cref="CilRuntimeMethod"/> class. /// </summary> /// <param name="token">The token.</param> /// <param name="module">The module.</param> /// <param name="method">The method.</param> /// <param name="maxParam">The max param.</param> /// <param name="declaringType">Type of the declaring.</param> public CilRuntimeMethod(int token, IMetadataModule module, ref MethodDefRow method, TokenTypes maxParam, RuntimeType declaringType) : base((int)token, module, declaringType) { this.nameIdx = method.NameStringIdx; this.signatureBlobIdx = method.SignatureBlobIdx; base.Attributes = method.Flags; base.ImplAttributes = method.ImplFlags; base.Rva = method.Rva; if (method.ParamList < maxParam) { int count = maxParam - method.ParamList; int p = (int)(method.ParamList & TokenTypes.RowIndexMask) - 1 + RuntimeBase.Instance.TypeLoader.GetModuleOffset(module).ParameterOffset; base.Parameters = new ReadOnlyRuntimeParameterListView(p, count); } else { base.Parameters = ReadOnlyRuntimeParameterListView.Empty; } }
/// <summary> /// Initializes a new instance of the <see cref="CilRuntimeMethod"/> class. /// </summary> /// <param name="moduleTypeSystem">The module type system.</param> /// <param name="token">The token.</param> /// <param name="method">The method.</param> /// <param name="maxParam">The max param.</param> /// <param name="declaringType">Type of the declaring.</param> public CilRuntimeMethod(IModuleTypeSystem moduleTypeSystem, int token, MethodDefRow method, TokenTypes maxParam, RuntimeType declaringType) : base(moduleTypeSystem, (int)token, declaringType) { this.nameIdx = method.NameStringIdx; this.signatureBlobIdx = method.SignatureBlobIdx; base.Attributes = method.Flags; base.ImplAttributes = method.ImplFlags; base.Rva = method.Rva; if (method.ParamList < maxParam) { int count = maxParam - method.ParamList; int start = (int)(method.ParamList & TokenTypes.RowIndexMask) - 1; base.Parameters = new ReadOnlyRuntimeParameterListView((IModuleTypeSystemInternalList)moduleTypeSystem, start, count); } else { base.Parameters = ReadOnlyRuntimeParameterListView.Empty; } }
void IMetadataProvider.Read(TokenTypes token, out MethodDefRow result) { TableHeap theap = (TableHeap)_streams[(int)HeapType.Tables]; theap.Read(token, out result); }
/// <summary> /// Reads the specified token. /// </summary> /// <param name="token">The token.</param> /// <param name="result">The result.</param> public void Read(TokenTypes token, out MethodDefRow result) { if ((token & TokenTypes.TableMask) != TokenTypes.MethodDef) throw new ArgumentException ("Invalid token type for MethodDefRow.", "token"); using (BinaryReader reader = CreateReaderForToken (token)) { result = new MethodDefRow (reader.ReadUInt32 (), (MethodImplAttributes)reader.ReadUInt16 (), (MethodAttributes)reader.ReadUInt16 (), ReadIndexValue (reader, IndexType.StringHeap), ReadIndexValue (reader, IndexType.BlobHeap), ReadIndexValue (reader, TokenTypes.Param)); } }
public MethodDefRowExt(IMetadataProvider metadata, MethodDefRow row) : base(metadata) { this.row = row; }
/// <summary> /// Loads all methods from the given metadata module. /// </summary> /// <param name="declaringType">The type, which declared the method.</param> /// <param name="first">The first method token to load.</param> /// <param name="last">The last method token to load (non-inclusive.)</param> /// <param name="offset">The offset into the method table to start loading methods From.</param> private void LoadMethods(RuntimeType declaringType, TokenTypes first, TokenTypes last, ref int offset) { if (first >= last) return; MethodDefRow methodDef, nextMethodDef = new MethodDefRow(); TokenTypes maxParam, maxMethod = metadata.GetMaxTokenValue(TokenTypes.MethodDef); methodDef = metadata.ReadMethodDefRow(first); for (TokenTypes token = first; token < last; token++) { if (token < maxMethod) { nextMethodDef = metadata.ReadMethodDefRow(token + 1); maxParam = nextMethodDef.ParamList; } else { maxParam = metadata.GetMaxTokenValue(TokenTypes.Param) + 1; } Debug.Assert(offset < methods.Length, @"Invalid method index."); methods[offset++] = new CilRuntimeMethod(this, offset, methodDef, maxParam, declaringType); //Debug.Write("-> " + ((uint)token).ToString("X") + ": "); //Debug.Write(methodDef.NameStringIdx.ToString("X") + ": "); //Debug.Write(metadata.ReadString(methodDef.NameStringIdx)); //Debug.WriteLine(" - " + methodDef.SignatureBlobIdx.ToString()); methodDef = nextMethodDef; } }