* flowanalysis.cs (VariableInfo.SetAssigned): When noting a
authorRaja R Harinath <harinath@hurrynot.org>
Wed, 23 May 2007 13:46:29 +0000 (13:46 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Wed, 23 May 2007 13:46:29 +0000 (13:46 -0000)
variable as assigned, note also that all its components are assigned too.
(MyBitVector.SetRange): New.  Function to set multiple bits to true.

svn path=/trunk/mcs/; revision=77833

mcs/mcs/ChangeLog
mcs/mcs/flowanalysis.cs

index e27c886cf93e06715fe9e32ff900da08609fac00..37720e650efd7012f3cf7e814cbbdd7b183f1ced 100644 (file)
@@ -1,3 +1,10 @@
+2007-05-23  Raja R Harinath  <rharinath@novell.com>
+
+       * flowanalysis.cs (VariableInfo.SetAssigned): When noting a
+       variable as assigned, note also that all its components are
+       assigned too.
+       (MyBitVector.SetRange): New.  Function to set multiple bits to true.
+
 2007-05-19  Marek Safar  <marek.safar@gmail.com>
 
        * anonymous.cs, class.cs: Emit Compiler generated attribute when
index 2c4ab9445331a1a1885f1a2de9bb0ccb5e0aee8b..5388d0afc061a3503c9662b41d1ecbe42a4493db 100644 (file)
@@ -1343,9 +1343,14 @@ namespace Mono.CSharp
                        if (vector [Offset])
                                return true;
 
-                       for (VariableInfo parent = Parent; parent != null; parent = parent.Parent)
-                               if (vector [parent.Offset])
+                       // FIXME: Fix SetFieldAssigned to set the whole range like SetAssigned below. Then, get rid of this stanza
+                       for (VariableInfo parent = Parent; parent != null; parent = parent.Parent) {
+                               if (vector [parent.Offset]) {
+                                       // 'parent' is assigned, but someone forgot to note that all its components are assigned too
+                                       parent.SetAssigned (vector);
                                        return true;
+                               }
+                       }
 
                        // Return unless this is a struct.
                        if (!TypeInfo.IsStruct)
@@ -1379,7 +1384,10 @@ namespace Mono.CSharp
 
                public void SetAssigned (MyBitVector vector)
                {
-                       vector [Offset] = true;
+                       if (Length == 1)
+                               vector [Offset] = true;
+                       else
+                               vector.SetRange (Offset, Length);
                }
 
                public bool IsFieldAssigned (EmitContext ec, string name, Location loc)
@@ -1631,6 +1639,30 @@ namespace Mono.CSharp
                        return Count == 0 ? Empty : new MyBitVector (this, Count);
                }
 
+               public void SetRange (int offset, int length)
+               {
+                       if (offset > Count || offset + length > Count)
+                               throw new ArgumentOutOfRangeException ();
+
+                       if (shared == null && vector == null)
+                               return;
+
+                       int i = 0;
+                       if (shared != null) {
+                               if (offset + length <= shared.Count) {
+                                       for (; i < length; ++i)
+                                               if (!shared [i+offset])
+                                                   break;
+                                       if (i == length)
+                                               return;
+                               }
+                               initialize_vector ();
+                       }
+                       for (; i < length; ++i)
+                               vector [i+offset] = true;
+
+               }
+
                public void SetAll (bool value)
                {
                        // Don't clobber Empty