* flowanalysis.cs (FlowBranching.Reachability): Prepare to be
authorRaja R Harinath <harinath@hurrynot.org>
Mon, 26 Mar 2007 09:59:52 +0000 (09:59 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Mon, 26 Mar 2007 09:59:52 +0000 (09:59 -0000)
replaced by a boolean.  Add boolean 'is_unreachable' field, check
and maintain invariants.

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

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

index a9cc9ecdab2ddabb31a13328ea7209ad4e92d645..e1b3942bd4e8684bb188f4c94f0a02de6e1e382c 100644 (file)
@@ -1,3 +1,9 @@
+2007-03-26  Raja R Harinath  <rharinath@novell.com>
+
+       * flowanalysis.cs (FlowBranching.Reachability): Prepare to be
+       replaced by a boolean.  Add boolean 'is_unreachable' field, check
+       and maintain invariants.
+
 2007-03-25  Marek Safar  <marek.safar@gmail.com>
 
        * anonymous.cs: Restored checks disabled for uninflated anonymous methods.
index 50ecd9f91eeb4235345709a96e8c55b48ad4fc92..02cd67ad8038a20adf4f1cf72bc46123a86e8e85 100644 (file)
@@ -76,11 +76,19 @@ namespace Mono.CSharp
                                Always
                        }
 
+                       bool is_unreachable;
                        TriState barrier;
 
                        Reachability (TriState barrier)
                        {
                                this.barrier = barrier;
+                               this.is_unreachable = barrier == TriState.Always;
+                       }
+
+                       void Check ()
+                       {
+                               if (is_unreachable != (barrier == TriState.Always))
+                                       throw new InternalErrorException (is_unreachable + " vs. " + barrier);
                        }
 
                        public Reachability Clone ()
@@ -105,11 +113,15 @@ namespace Mono.CSharp
                        public void Meet (Reachability b)
                        {
                                barrier = TriState_Meet (barrier, b.barrier);
+                               is_unreachable &= b.is_unreachable;
+                               Check ();
                        }
 
                        public void Or (Reachability b)
                        {
                                barrier = TriState_Max (barrier, b.barrier);
+                               is_unreachable |= b.is_unreachable;
+                               Check ();
                        }
 
                        public static Reachability Always ()
@@ -118,12 +130,13 @@ namespace Mono.CSharp
                        }
 
                        public bool IsUnreachable {
-                               get { return barrier == TriState.Always; }
+                               get { Check (); return is_unreachable; }
                        }
 
                        public void SetBarrier ()
                        {
                                barrier = TriState.Always;
+                               is_unreachable = true;
                        }
 
                        static string ShortName (TriState t)