Prechádzať zdrojové kódy

2005-09-14 Martin Baulig <[email protected]>

	* MonoSymbolTable.cs (OffsetTable): Bump version to 39.
	(LocalVariableEntry.Index): New field.

	* MonoSymbolWriter.cs
	(MonoSymbolWriter.DefineLocalVariable): Added `int index' argument.

	* MonoSymbolFile.cs
	(MonoDebuggerSupport.GetLocalIndex): New method.


svn path=/trunk/mcs/; revision=50054
Martin Baulig 20 rokov pred
rodič
commit
86c2c5d12f

+ 11 - 0
mcs/class/Mono.CompilerServices.SymbolWriter/ChangeLog

@@ -1,3 +1,14 @@
+2005-09-14  Martin Baulig  <[email protected]>
+
+	* MonoSymbolTable.cs (OffsetTable): Bump version to 39.
+	(LocalVariableEntry.Index): New field.
+
+	* MonoSymbolWriter.cs
+	(MonoSymbolWriter.DefineLocalVariable): Added `int index' argument.
+
+	* MonoSymbolFile.cs
+	(MonoDebuggerSupport.GetLocalIndex): New method.
+
 2005-09-05  Martin Baulig  <[email protected]>
 
 	* MonoSymbolFile.cs (MonoDebuggerSupport): Make this internal and

+ 12 - 0
mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs

@@ -30,6 +30,7 @@
 
 using System;
 using System.Reflection;
+using SRE = System.Reflection.Emit;
 using System.Collections;
 using System.Text;
 using System.Threading;
@@ -76,9 +77,11 @@ namespace Mono.CompilerServices.SymbolWriter
 	{
 		static GetMethodTokenFunc get_method_token;
 		static GetGuidFunc get_guid;
+		static GetLocalIndexFunc get_local_index;
 
 		delegate int GetMethodTokenFunc (MethodBase method);
 		delegate Guid GetGuidFunc (Module module);
+		delegate int GetLocalIndexFunc (SRE.LocalBuilder local);
 
 		static Delegate create_delegate (Type type, Type delegate_type, string name)
 		{
@@ -98,6 +101,10 @@ namespace Mono.CompilerServices.SymbolWriter
 
 			get_guid = (GetGuidFunc) create_delegate (
 				typeof (Module), typeof (GetGuidFunc), "Mono_GetGuid");
+
+			get_local_index = (GetLocalIndexFunc) create_delegate (
+				typeof (SRE.LocalBuilder), typeof (GetLocalIndexFunc),
+				"Mono_GetLocalIndex");
 		}
 
 		public static int GetMethodToken (MethodBase method)
@@ -109,6 +116,11 @@ namespace Mono.CompilerServices.SymbolWriter
 		{
 			return get_guid (module);
 		}
+
+		public static int GetLocalIndex (SRE.LocalBuilder local)
+		{
+			return get_local_index (local);
+		}
 	}
 
 	public class MonoSymbolFile : IDisposable

+ 6 - 2
mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs

@@ -71,7 +71,7 @@ namespace Mono.CompilerServices.SymbolWriter
 {
 	public struct OffsetTable
 	{
-		public const int  Version = 38;
+		public const int  Version = 39;
 		public const long Magic   = 0x45e82623fd7fa614;
 
 		#region This is actually written to the symbol file
@@ -234,13 +234,15 @@ namespace Mono.CompilerServices.SymbolWriter
 	public struct LocalVariableEntry
 	{
 		#region This is actually written to the symbol file
+		public readonly int Index;
 		public readonly string Name;
 		public readonly byte[] Signature;
 		public readonly int BlockIndex;
 		#endregion
 
-		public LocalVariableEntry (string Name, byte[] Signature, int BlockIndex)
+		public LocalVariableEntry (int Index, string Name, byte[] Signature, int BlockIndex)
 		{
+			this.Index = Index;
 			this.Name = Name;
 			this.Signature = Signature;
 			this.BlockIndex = BlockIndex;
@@ -248,6 +250,7 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		internal LocalVariableEntry (MyBinaryReader reader)
 		{
+			Index = reader.ReadLeb128 ();
 			Name = reader.ReadString ();
 			int sig_length = reader.ReadLeb128 ();
 			Signature = reader.ReadBytes (sig_length);
@@ -256,6 +259,7 @@ namespace Mono.CompilerServices.SymbolWriter
 
 		internal void Write (MonoSymbolFile file, MyBinaryWriter bw)
 		{
+			bw.WriteLeb128 (Index);
 			bw.Write (Name);
 			bw.WriteLeb128 ((int) Signature.Length);
 			bw.Write (Signature);

+ 4 - 4
mcs/class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs

@@ -96,12 +96,12 @@ namespace Mono.CompilerServices.SymbolWriter
 		public void CloseNamespace ()
 		{ }
 
-		public void DefineLocalVariable (string name, byte[] signature)
+		public void DefineLocalVariable (int index, string name, byte[] signature)
 		{
 			if (current_method == null)
 				return;
 
-			current_method.AddLocal (name, signature);
+			current_method.AddLocal (index, name, signature);
 		}
 
 		public void MarkSequencePoint (int offset, int line, int column)
@@ -273,12 +273,12 @@ namespace Mono.CompilerServices.SymbolWriter
 				}
 			}
 
-			public void AddLocal (string name, byte[] signature)
+			public void AddLocal (int index, string name, byte[] signature)
 			{
 				if (_locals == null)
 					_locals = new ArrayList ();
 				_locals.Add (new LocalVariableEntry (
-						     name, signature, CurrentBlock.Index));
+						     index, name, signature, CurrentBlock.Index));
 			}
 
 			public ISourceFile SourceFile {

+ 3 - 1
mcs/class/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs

@@ -46,6 +46,7 @@ namespace Mono.CompilerServices.SymbolWriter
 		delegate Guid GetGuidFunc (ModuleBuilder mb);
 		GetGuidFunc get_guid_func;
 		
+		int nextLocalIndex;
 		int currentToken;
 		string methodName;
 		Stack namespaceStack = new Stack ();
@@ -76,6 +77,7 @@ namespace Mono.CompilerServices.SymbolWriter
 		{
 			if (methodOpened) {
 				methodOpened = false;
+				nextLocalIndex = 0;
 				msw.CloseMethod ();
 			}
 		}
@@ -139,7 +141,7 @@ namespace Mono.CompilerServices.SymbolWriter
 			int startOffset,
 			int endOffset)
 		{
-			msw.DefineLocalVariable (name, signature);
+			msw.DefineLocalVariable (nextLocalIndex++, name, signature);
 		}
 		
 		public void DefineParameter (