Hashtable method_hash;
Hashtable source_file_hash;
+ Hashtable method_token_hash;
Hashtable method_name_hash;
Hashtable source_name_hash;
}
}
+ public MethodIndexEntry GetMethodIndexEntry (int index)
+ {
+ int old_pos = (int) reader.BaseStream.Position;
+ reader.BaseStream.Position = ot.MethodTableOffset +
+ MethodIndexEntry.Size * (index - 1);
+ MethodIndexEntry ie = new MethodIndexEntry (reader);
+ reader.BaseStream.Position = old_pos;
+ return ie;
+ }
+
+ public MethodEntry GetMethodByToken (int token)
+ {
+ if (reader == null)
+ throw new InvalidOperationException ();
+
+ if (method_token_hash == null) {
+ method_token_hash = new Hashtable ();
+
+ for (int i = 0; i < MethodCount; i++) {
+ MethodIndexEntry ie = GetMethodIndexEntry (i);
+
+ method_token_hash.Add (ie.Token, i);
+ }
+ }
+
+ object value = method_token_hash [token];
+ if (value == null)
+ return null;
+
+ return GetMethod ((int) value);
+ }
+
public MethodEntry GetMethod (int index)
{
if ((index < 1) || (index > ot.MethodCount))
if (entry != null)
return entry;
- reader.BaseStream.Position = ot.MethodTableOffset + 8 * (index - 1);
- reader.BaseStream.Position = reader.ReadInt32 ();
+ MethodIndexEntry ie = GetMethodIndexEntry (index);
+ reader.BaseStream.Position = ie.FileOffset;
entry = new MethodEntry (this, reader, index);
method_hash.Add (index, entry);
method_name_hash = new Hashtable ();
for (int i = 0; i < ot.MethodCount; i++) {
- reader.BaseStream.Position = ot.MethodTableOffset + 8 * i;
-
- int offset = reader.ReadInt32 ();
- int name_offset = reader.ReadInt32 ();
- string name = ReadString (name_offset);
+ MethodIndexEntry ie = GetMethodIndexEntry (i);
+ string name = ReadString (ie.FullNameOffset);
method_name_hash.Add (name, i + 1);
}
{
public struct OffsetTable
{
- public const int Version = 31;
+ public const int Version = 32;
public const long Magic = 0x45e82623fd7fa614;
public int TotalFileSize;
int namespace_count, nstable_offset;
bool creating;
- internal static int Size {
+ public static int Size {
get { return 24; }
}
EndRow = reader.ReadInt32 ();
}
- public static int Size
- {
- get {
- return 16;
- }
+ public static int Size {
+ get { return 16; }
}
internal void Write (BinaryWriter bw)
}
}
+ public struct MethodIndexEntry
+ {
+ public readonly int FileOffset;
+ public readonly int FullNameOffset;
+ public readonly int Token;
+
+ public static int Size {
+ get { return 12; }
+ }
+
+ public MethodIndexEntry (int offset, int name_offset, int token)
+ {
+ this.FileOffset = offset;
+ this.FullNameOffset = name_offset;
+ this.Token = token;
+ }
+
+ internal MethodIndexEntry (BinaryReader reader)
+ {
+ FileOffset = reader.ReadInt32 ();
+ FullNameOffset = reader.ReadInt32 ();
+ Token = reader.ReadInt32 ();
+ }
+
+ internal void Write (BinaryWriter bw)
+ {
+ bw.Write (FileOffset);
+ bw.Write (FullNameOffset);
+ bw.Write (Token);
+ }
+
+ public override string ToString ()
+ {
+ return String.Format ("MethodIndexEntry ({0}:{1}:{2:x})",
+ FileOffset, FullNameOffset, Token);
+ }
+ }
+
public class MethodEntry
{
#region This is actually written to the symbol file
int file_offset;
string name;
string full_name;
+ MethodIndexEntry index_entry;
public readonly SourceFileEntry SourceFile;
public readonly LineNumberEntry[] LineNumbers;
public readonly MonoSymbolFile SymbolFile;
- public static int Size
- {
- get {
- return 52;
- }
+ public static int Size {
+ get { return 52; }
}
public string Name {
file_offset = (int) bw.BaseStream.Position;
+ index_entry = new MethodIndexEntry (file_offset, FullNameOffset, Token);
+
bw.Write (SourceFileIndex);
bw.Write (Token);
bw.Write (StartRow);
internal void WriteIndex (BinaryWriter bw)
{
- bw.Write (file_offset);
- bw.Write (FullNameOffset);
+ index_entry.Write (bw);
}
public override string ToString ()