Author: jbevain
Date: 2007-10-09 12:32:30 -0400 (Tue, 09 Oct 2007)
New Revision: 87193

Modified:
   trunk/mcs/class/Mono.Cecil/ChangeLog
   trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs
   trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs
   trunk/mcs/class/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs
Log:
2007-10-09  Jb Evain  <[EMAIL PROTECTED]>

        * Mono.Cecil.Cil/Instruction.cs
          Mono.Cecil.Cil/CodeWriter.cs:
                Move CodeWriter.GetSize (Instruction) to Instruction.


Modified: trunk/mcs/class/Mono.Cecil/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Cecil/ChangeLog        2007-10-09 16:25:24 UTC (rev 
87192)
+++ trunk/mcs/class/Mono.Cecil/ChangeLog        2007-10-09 16:32:30 UTC (rev 
87193)
@@ -1,5 +1,9 @@
 2007-10-09  Jb Evain  <[EMAIL PROTECTED]>
 
+       * Mono.Cecil.Cil/Instruction.cs
+         Mono.Cecil.Cil/CodeWriter.cs:
+               Move CodeWriter.GetSize (Instruction) to Instruction.
+
        Integration of patches from Carlo Kok <[EMAIL PROTECTED]>:
 
        * Mono.Cecil.Cil/Document.cs

Modified: trunk/mcs/class/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs
===================================================================
--- trunk/mcs/class/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs       2007-10-09 
16:25:24 UTC (rev 87192)
+++ trunk/mcs/class/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs       2007-10-09 
16:32:30 UTC (rev 87193)
@@ -43,7 +43,7 @@
 [assembly: CLSCompliant (false)]
 [assembly: ComVisible (false)]
 
-[assembly: AssemblyVersion ("0.6.8.7183")]
+[assembly: AssemblyVersion ("0.6.8.7193")]
 
 #if KEYFILE
 [assembly: AssemblyKeyFile("../../mono.snk")]

Modified: trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs
===================================================================
--- trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs     2007-10-09 
16:25:24 UTC (rev 87192)
+++ trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs     2007-10-09 
16:32:30 UTC (rev 87193)
@@ -243,46 +243,9 @@
                static int GetLength (Instruction start, Instruction end, 
InstructionCollection instructions)
                {
                        Instruction last = instructions [instructions.Count - 
1];
-                       return (end == instructions.Outside ? last.Offset + 
GetSize (last) : end.Offset) - start.Offset;
+                       return (end == instructions.Outside ? last.Offset + 
last.GetSize () : end.Offset) - start.Offset;
                }
 
-               static int GetSize (Instruction i)
-               {
-                       int size = i.OpCode.Size;
-
-                       switch (i.OpCode.OperandType) {
-                       case OperandType.InlineSwitch:
-                               size += ((Instruction []) i.Operand).Length * 4;
-                               break;
-                       case OperandType.InlineI8:
-                       case OperandType.InlineR:
-                               size += 8;
-                               break;
-                       case OperandType.InlineBrTarget:
-                       case OperandType.InlineField:
-                       case OperandType.InlineI:
-                       case OperandType.InlineMethod:
-                       case OperandType.InlineString:
-                       case OperandType.InlineTok:
-                       case OperandType.InlineType:
-                       case OperandType.ShortInlineR:
-                               size += 4;
-                               break;
-                       case OperandType.InlineParam:
-                       case OperandType.InlineVar:
-                               size += 2;
-                               break;
-                       case OperandType.ShortInlineBrTarget:
-                       case OperandType.ShortInlineI:
-                       case OperandType.ShortInlineParam:
-                       case OperandType.ShortInlineVar:
-                               size += 1;
-                               break;
-                       }
-
-                       return size;
-               }
-
                static bool IsRangeFat (Instruction start, Instruction end, 
InstructionCollection instructions)
                {
                        return GetLength (start, end, instructions) >= 256 ||

Modified: trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs
===================================================================
--- trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs    2007-10-09 
16:25:24 UTC (rev 87192)
+++ trunk/mcs/class/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs    2007-10-09 
16:32:30 UTC (rev 87193)
@@ -88,6 +88,43 @@
                {
                }
 
+               public int GetSize ()
+               {
+                       int size = m_opCode.Size;
+
+                       switch (m_opCode.OperandType) {
+                       case OperandType.InlineSwitch:
+                               size += (1 + ((Instruction []) 
m_operand).Length) * 4;
+                               break;
+                       case OperandType.InlineI8:
+                       case OperandType.InlineR:
+                               size += 8;
+                               break;
+                       case OperandType.InlineBrTarget:
+                       case OperandType.InlineField:
+                       case OperandType.InlineI:
+                       case OperandType.InlineMethod:
+                       case OperandType.InlineString:
+                       case OperandType.InlineTok:
+                       case OperandType.InlineType:
+                       case OperandType.ShortInlineR:
+                               size += 4;
+                               break;
+                       case OperandType.InlineParam:
+                       case OperandType.InlineVar:
+                               size += 2;
+                               break;
+                       case OperandType.ShortInlineBrTarget:
+                       case OperandType.ShortInlineI:
+                       case OperandType.ShortInlineParam:
+                       case OperandType.ShortInlineVar:
+                               size += 1;
+                               break;
+                       }
+
+                       return size;
+               }
+
                public void Accept (ICodeVisitor visitor)
                {
                        visitor.VisitInstruction (this);

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

Reply via email to