Author: jbevain
Date: 2006-09-24 08:29:04 -0400 (Sun, 24 Sep 2006)
New Revision: 65848

Modified:
   trunk/cecil/pdb/ChangeLog
   trunk/cecil/pdb/Mono.Cecil.Pdb/PdbReader.cs
   trunk/cecil/pdb/Mono.Cecil.Pdb/PdbWriter.cs
Log:
2006-09-24  Jb Evain  <[EMAIL PROTECTED]>

        * Handle the fact that a scope end points outside the cil stream.


Modified: trunk/cecil/pdb/ChangeLog
===================================================================
--- trunk/cecil/pdb/ChangeLog   2006-09-24 12:20:48 UTC (rev 65847)
+++ trunk/cecil/pdb/ChangeLog   2006-09-24 12:29:04 UTC (rev 65848)
@@ -1,3 +1,7 @@
+2006-09-24  Jb Evain  <[EMAIL PROTECTED]>
+
+       * Handle the fact that a scope end points outside the cil stream.
+
 2006-09-20  Jb Evain  <[EMAIL PROTECTED]>
 
        * implement somes bits of the writing stuff.

Modified: trunk/cecil/pdb/Mono.Cecil.Pdb/PdbReader.cs
===================================================================
--- trunk/cecil/pdb/Mono.Cecil.Pdb/PdbReader.cs 2006-09-24 12:20:48 UTC (rev 
65847)
+++ trunk/cecil/pdb/Mono.Cecil.Pdb/PdbReader.cs 2006-09-24 12:29:04 UTC (rev 
65848)
@@ -65,11 +65,20 @@
                        return instructions;
                }
 
+               Cil.Instruction GetInstruction (Cil.MethodBody body, Hashtable 
instructions, int offset)
+               {
+                       Cil.Instruction instr = (Cil.Instruction) instructions 
[offset];
+                       if (instr != null)
+                               return instr;
+
+                       return body.Instructions.Outside;
+               }
+
                void ReadScopeAndLocals (ISymbolScope scope, Cil.Scope parent, 
Cil.MethodBody body, Hashtable instructions)
                {
                        Cil.Scope s = new Cil.Scope ();
-                       s.Start = (Cil.Instruction) instructions 
[scope.StartOffset];
-                       s.End = (Cil.Instruction) instructions 
[scope.EndOffset];
+                       s.Start = GetInstruction (body, instructions, 
scope.StartOffset);
+                       s.End = GetInstruction (body, instructions, 
scope.EndOffset);
 
                        if (parent != null)
                                parent.Scopes.Add (s);

Modified: trunk/cecil/pdb/Mono.Cecil.Pdb/PdbWriter.cs
===================================================================
--- trunk/cecil/pdb/Mono.Cecil.Pdb/PdbWriter.cs 2006-09-24 12:20:48 UTC (rev 
65847)
+++ trunk/cecil/pdb/Mono.Cecil.Pdb/PdbWriter.cs 2006-09-24 12:29:04 UTC (rev 
65848)
@@ -60,10 +60,17 @@
                        foreach (Scope s in scopes) {
                                m_writer.OpenScope (s.Start.Offset);
 
+                               int start = body.Instructions.IndexOf (s.Start);
+                               int end = s.End == body.Instructions.Outside ?
+                                       body.Instructions.Count - 1 :
+                                       body.Instructions.IndexOf (s.End);
+
                                ArrayList instructions = new ArrayList ();
-                               for (Instruction current = s.Start; 
current.Offset <= s.End.Offset; current = current.Next)
-                                       instructions.Add (current);
+                               for (int i = start; i <= end; i++)
+                                       instructions.Add (body.Instructions 
[i]);
 
+                               Document doc = null;
+
                                int [] offsets = new int [instructions.Count];
                                int [] startRows = new int [instructions.Count];
                                int [] startCols = new int [instructions.Count];
@@ -73,13 +80,19 @@
                                for (int i = 0; i < instructions.Count; i++) {
                                        Instruction instr = (Instruction) 
instructions [i];
                                        offsets [i] = instr.Offset;
+                                       if (instr.SequencePoint == null)
+                                               continue;
+
+                                       if (doc == null)
+                                               doc = 
instr.SequencePoint.Document;
+
                                        startRows [i] = 
instr.SequencePoint.StartLine;
                                        startCols [i] = 
instr.SequencePoint.StartColumn;
                                        endRows [i] = 
instr.SequencePoint.EndLine;
                                        endCols [i] = 
instr.SequencePoint.EndColumn;
                                }
 
-                               m_writer.DefineSequencePoints (GetDocument 
(s.Start.SequencePoint.Document),
+                               m_writer.DefineSequencePoints (GetDocument 
(doc),
                                        offsets, startRows, startCols, endRows, 
endCols);
 
                                // TODO: local variables

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to