Author: jbevain
Date: 2006-01-16 18:53:31 -0500 (Mon, 16 Jan 2006)
New Revision: 55662

Modified:
   trunk/cecil/lib/ChangeLog
   trunk/cecil/lib/Mono.Cecil/ArrayDimension.cs
   trunk/cecil/lib/Mono.Cecil/ArrayType.cs
   trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs
   trunk/cecil/lib/TODO
Log:
2006-01-17  Jb Evain  <[EMAIL PROTECTED]>

        * Mono.Cecil/ArrayType.cs
          Mono.Cecil/ArrayDimension.cs
          Mono.Cecil/ReflectionWriter.cs:
                End arrays support.


Modified: trunk/cecil/lib/ChangeLog
===================================================================
--- trunk/cecil/lib/ChangeLog   2006-01-16 23:20:29 UTC (rev 55661)
+++ trunk/cecil/lib/ChangeLog   2006-01-16 23:53:31 UTC (rev 55662)
@@ -1,3 +1,10 @@
+2006-01-17  Jb Evain  <[EMAIL PROTECTED]>
+
+       * Mono.Cecil/ArrayType.cs
+         Mono.Cecil/ArrayDimension.cs
+         Mono.Cecil/ReflectionWriter.cs:
+               End arrays support.
+
 2006-01-03  Jb Evain  <[EMAIL PROTECTED]>
 
        * Mono.Cecil/GenericParameter.cs

Modified: trunk/cecil/lib/Mono.Cecil/ArrayDimension.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ArrayDimension.cs        2006-01-16 23:20:29 UTC 
(rev 55661)
+++ trunk/cecil/lib/Mono.Cecil/ArrayDimension.cs        2006-01-16 23:53:31 UTC 
(rev 55662)
@@ -51,7 +51,7 @@
 
                public override string ToString ()
                {
-                       if (m_lowerBound == 0 && m_upperBound == 0)
+                       if (m_upperBound == 0)
                                return string.Empty;
                        return string.Concat (m_lowerBound, "...", 
m_upperBound);
                }

Modified: trunk/cecil/lib/Mono.Cecil/ArrayType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ArrayType.cs     2006-01-16 23:20:29 UTC (rev 
55661)
+++ trunk/cecil/lib/Mono.Cecil/ArrayType.cs     2006-01-16 23:53:31 UTC (rev 
55662)
@@ -50,7 +50,7 @@
                                if (this.Rank != 1)
                                        return false;
                                IArrayDimension dim = m_dimensions [0];
-                               return dim.LowerBound == 0 && dim.UpperBound == 
0;
+                               return dim.UpperBound == 0;
                        }
                }
 
@@ -76,14 +76,16 @@
 
                internal ArrayType (TypeReference elementsType, ArrayShape 
shape) : this (elementsType)
                {
-                       for (int i = 0; i < shape.Rank; i++) { // TODO
-                               ArrayDimension dim;
+                       for (int i = 0; i < shape.Rank; i++) {
+                               int lower = 0, upper = 0;
                                if (i < shape.NumSizes)
-                                       dim = new ArrayDimension 
(shape.LoBounds [i], shape.LoBounds [i] + shape.Sizes [i] - 1);
-                               else
-                                       dim = new ArrayDimension (0, 0);
+                                       if (i < shape.NumLoBounds) {
+                                               lower = shape.LoBounds [i];
+                                               upper = shape.LoBounds [i] + 
shape.Sizes [i] - 1;
+                                       } else
+                                               upper = shape.Sizes [i] - 1;
 
-                               m_dimensions.Add (dim);
+                               m_dimensions.Add (new ArrayDimension (lower, 
upper));
                        }
                }
 

Modified: trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs      2006-01-16 23:20:29 UTC 
(rev 55661)
+++ trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs      2006-01-16 23:53:31 UTC 
(rev 55662)
@@ -931,7 +931,22 @@
                                        return szary;
                                }
 
-                               throw new NotImplementedException ("Complex 
arrays are not implemented"); // TODO
+                               // not optimized
+                               ArrayShape shape = new ArrayShape ();
+                               shape.Rank = aryType.Dimensions.Count;
+                               shape.Sizes = new int [shape.Rank];
+                               shape.LoBounds = new int [shape.Rank];
+
+                               for (int i = 0; i < shape.Rank; i++) {
+                                       ArrayDimension dim = aryType.Dimensions 
[i];
+                                       shape.LoBounds [i] = dim.LowerBound;
+                                       shape.Sizes [i] = dim.UpperBound - 
dim.LowerBound + 1;
+                               }
+
+                               ARRAY ary = new ARRAY ();
+                               ary.Shape = shape;
+                               ary.Type = GetSigType (aryType.ElementType);
+                               return ary;
                        } else if (type is IPointerType) {
                                PTR p = new PTR ();
                                ITypeReference elementType = (type as 
IPointerType).ElementType;

Modified: trunk/cecil/lib/TODO
===================================================================
--- trunk/cecil/lib/TODO        2006-01-16 23:20:29 UTC (rev 55661)
+++ trunk/cecil/lib/TODO        2006-01-16 23:53:31 UTC (rev 55662)
@@ -4,10 +4,6 @@
 
        For sure, bugs remains in the generic suppport.
 
-* array types
-
-       Arrays support is buggy.
-
 * debugs infos
 
        Cecil should be able to emit debug infos along with assemblies.

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

Reply via email to