2004-10-20 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / class / Mono.CSharp.Debugger / MonoSymbolFile.cs
index c3fc618ab1c199b6b4fed6c73d592c72ed9f54de..2a130bc92fb99a114134ee8e3f7e0ca066543c1d 100644 (file)
@@ -222,12 +222,14 @@ namespace Mono.CompilerServices.SymbolWriter
                static GetMethodFunc get_method;
                static GetLocalTypeFromSignatureFunc local_type_from_sig;
                static GetGuidFunc get_guid;
+               static CheckRuntimeVersionFunc check_runtime_version;
 
                delegate Type GetTypeFunc (Assembly assembly, int token);
                delegate int GetMethodTokenFunc (Assembly assembly, MethodBase method);
                delegate MethodBase GetMethodFunc (Assembly assembly, int token);
                delegate Type GetLocalTypeFromSignatureFunc (Assembly assembly, byte[] sig);
                delegate Guid GetGuidFunc (Module module);
+               delegate string CheckRuntimeVersionFunc (string filename);
 
                static Delegate create_delegate (Type type, Type delegate_type, string name)
                {
@@ -259,6 +261,10 @@ namespace Mono.CompilerServices.SymbolWriter
 
                        get_guid = (GetGuidFunc) create_delegate (
                                typeof (Module), typeof (GetGuidFunc), "Mono_GetGuid");
+
+                       check_runtime_version = (CheckRuntimeVersionFunc) create_delegate (
+                               typeof (Assembly), typeof (CheckRuntimeVersionFunc),
+                               "MonoDebugger_CheckRuntimeVersion");
                }
 
                public static Type GetType (Assembly assembly, int token)
@@ -281,6 +287,11 @@ namespace Mono.CompilerServices.SymbolWriter
                        return local_type_from_sig (assembly, sig);
                }
 
+               public static string CheckRuntimeVersion (string filename)
+               {
+                       return check_runtime_version (filename);
+               }
+
                public static Guid GetGuid (Module module)
                {
                        return get_guid (module);
@@ -371,6 +382,13 @@ namespace Mono.CompilerServices.SymbolWriter
                        long offset_table_offset = bw.BaseStream.Position;
                        ot.Write (bw);
 
+                       //
+                       // Sort the methods according to their tokens and update their index.
+                       //
+                       methods.Sort ();
+                       for (int i = 0; i < methods.Count; i++)
+                               ((MethodEntry) methods [i]).Index = i + 1;
+
                        //
                        // Write data sections.
                        //
@@ -380,7 +398,7 @@ namespace Mono.CompilerServices.SymbolWriter
                        ot.DataSectionSize = (int) bw.BaseStream.Position - ot.DataSectionOffset;
 
                        //
-                       // Write out the method index
+                       // Write the method index table.
                        //
                        ot.MethodTableOffset = (int) bw.BaseStream.Position;
                        for (int i = 0; i < methods.Count; i++) {