2007-02-06 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / flowanalysis.cs
index 4b3affdd77ca59df1d25a9fcd82b530bfdadf8db..3eab67dfa3393d4917b93cdf5240f417f12eb4dc 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author:
 //   Martin Baulig (martin@ximian.com)
+//   Raja R Harinath (rharinath@novell.com)
 //
 // (C) 2001, 2002, 2003 Ximian, Inc.
 //
@@ -475,12 +476,12 @@ namespace Mono.CSharp
                                                      child.Type, child.Reachability.IsUnreachable, unreachable);
 
                                        if (!unreachable)
-                                               MyBitVector.And (ref locals, child.locals);
+                                               locals &= child.locals;
 
                                        // An `out' parameter must be assigned in all branches which do
                                        // not always throw an exception.
                                        if (!child.Reachability.AlwaysThrows)
-                                               MyBitVector.And (ref parameters, child.parameters);
+                                               parameters &= child.parameters;
 
                                        Report.Debug (2, "    MERGING SIBLING #2", parameters, locals);
                                }
@@ -494,7 +495,7 @@ namespace Mono.CSharp
                        // <summary>
                        //   Merges a child branching.
                        // </summary>
-                       public UsageVector MergeChild (UsageVector child, bool implicit_block)
+                       public UsageVector MergeChild (UsageVector child, bool overwrite)
                        {
                                Report.Debug (2, "    MERGING CHILD EFFECTS", this, child, reachability, Type);
 
@@ -516,10 +517,10 @@ namespace Mono.CSharp
                                        return child;
                                }
 
-                               MyBitVector.Or (ref locals, child.locals);
-                               MyBitVector.Or (ref parameters, child.parameters);
+                               locals |= child.locals;
+                               parameters |= child.parameters;
 
-                               if (implicit_block)
+                               if (overwrite)
                                        reachability = new_r.Clone ();
                                else
                                        reachability.Or (new_r);
@@ -543,8 +544,10 @@ namespace Mono.CSharp
 
                                for (UsageVector vector = o_vectors; vector != null; vector = vector.Next) {
                                        Report.Debug (1, "    MERGING BREAK ORIGIN", vector);
-                                       MyBitVector.And (ref locals, vector.locals);
-                                       MyBitVector.And (ref parameters, vector.parameters);
+                                       if (vector.Reachability.IsUnreachable)
+                                               continue;
+                                       locals &= vector.locals;
+                                       parameters &= vector.parameters;
                                        reachability.Meet (vector.Reachability);
                                }
 
@@ -618,13 +621,6 @@ namespace Mono.CSharp
 
                protected abstract void AddSibling (UsageVector uv);
 
-               public virtual LabeledStatement LookupLabel (string name, Location loc)
-               {
-                       return Parent.LookupLabel (name, loc);
-               }
-
-               public abstract void Label (UsageVector origin_vectors);
-
                protected abstract UsageVector Merge ();
 
                // <summary>
@@ -632,9 +628,10 @@ namespace Mono.CSharp
                // </summary>
                public UsageVector MergeChild (FlowBranching child)
                {
-                       bool implicit_block = child.Type == BranchingType.Block && child.Block.Implicit;
+                       bool overwrite = child.Type == BranchingType.Labeled ||
+                               (child.Type == BranchingType.Block && child.Block.Implicit);
                        Report.Debug (2, "  MERGING CHILD", this, child);
-                       UsageVector result = CurrentUsageVector.MergeChild (child.Merge (), implicit_block);
+                       UsageVector result = CurrentUsageVector.MergeChild (child.Merge (), overwrite);
                        Report.Debug (2, "  MERGING CHILD DONE", this, result);
                        return result;
                }
@@ -662,6 +659,12 @@ namespace Mono.CSharp
                        return Parent.AddReturnOrigin (vector, loc);
                }
 
+               // returns true if we crossed an unwind-protected region (try/catch/finally, lock, using, ...)
+               public virtual bool AddGotoOrigin (UsageVector vector, Goto goto_stmt)
+               {
+                       return Parent.AddGotoOrigin (vector, goto_stmt);
+               }
+
                public virtual void StealFinallyClauses (ref ArrayList list)
                {
                        Parent.StealFinallyClauses (ref list);
@@ -734,25 +737,16 @@ namespace Mono.CSharp
                        sibling_list = sibling;
                }
 
-               public override LabeledStatement LookupLabel (string name, Location loc)
+               public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt)
                {
-                       LabeledStatement stmt = Block == null ? null : Block.LookupLabel (name);
+                       LabeledStatement stmt = Block == null ? null : Block.LookupLabel (goto_stmt.Target);
                        if (stmt == null)
-                               return Parent.LookupLabel (name, loc);
-
-                       stmt.AddReference ();
-                       return stmt;
-               }
-
-               public override void Label (UsageVector origin_vectors)
-               {
-                       if (!CurrentUsageVector.Reachability.IsUnreachable) {
-                               UsageVector vector = CurrentUsageVector.Clone ();
-                               vector.Next = origin_vectors;
-                               origin_vectors = vector;
-                       }
+                               return Parent.AddGotoOrigin (vector, goto_stmt);
 
-                       CurrentUsageVector.MergeOrigins (origin_vectors);
+                       // forward jump
+                       goto_stmt.SetResolvedTarget (stmt);
+                       stmt.AddUsageVector (vector);
+                       return false;
                }
 
                protected override UsageVector Merge ()
@@ -815,24 +809,47 @@ namespace Mono.CSharp
        public class FlowBranchingLabeled : FlowBranchingBlock
        {
                LabeledStatement stmt;
+               UsageVector actual;
+
                public FlowBranchingLabeled (FlowBranching parent, LabeledStatement stmt)
                        : base (parent, BranchingType.Labeled, SiblingType.Conditional, null, stmt.loc)
                {
                        this.stmt = stmt;
+                       CurrentUsageVector.MergeOrigins (stmt.JumpOrigins);
+                       actual = CurrentUsageVector.Clone ();
+
+                       // stand-in for backward jumps
+                       CurrentUsageVector.Reachability.Meet (Reachability.Always ());
+               }
+
+               public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt)
+               {
+                       if (goto_stmt.Target != stmt.Name)
+                               return Parent.AddGotoOrigin (vector, goto_stmt);
+
+                       // backward jump
+                       goto_stmt.SetResolvedTarget (stmt);
+                       actual.MergeOrigins (vector.Clone ());
+
+                       return false;
                }
 
-               public override LabeledStatement LookupLabel (string name, Location loc)
+               protected override UsageVector Merge ()
                {
-                       if (name != stmt.Name)
-                               return Parent.LookupLabel (name, loc);
+                       UsageVector vector = base.Merge ();
+
+                       if (actual.Reachability.IsUnreachable)
+                               Report.Warning (162, 2, stmt.loc, "Unreachable code detected");
 
-                       stmt.AddReference ();
-                       return stmt;
+                       actual.MergeChild (vector, false);
+                       return actual;
                }
        }
 
        public class FlowBranchingToplevel : FlowBranchingBlock
        {
+               UsageVector return_origins;
+
                public FlowBranchingToplevel (FlowBranching parent, ToplevelBlock stmt)
                        : base (parent, BranchingType.Toplevel, SiblingType.Conditional, stmt, stmt.loc)
                {
@@ -843,6 +860,8 @@ namespace Mono.CSharp
                // </summary>
                void CheckOutParameters (UsageVector vector, Location loc)
                {
+                       if (vector.Reachability.IsUnreachable)
+                               return;
                        for (int i = 0; i < param_map.Count; i++) {
                                VariableInfo var = param_map [i];
 
@@ -876,7 +895,10 @@ namespace Mono.CSharp
 
                public override bool AddReturnOrigin (UsageVector vector, Location loc)
                {
-                       CheckOutParameters (vector, loc);
+                       vector = vector.Clone ();
+                       vector.Location = loc;
+                       vector.Next = return_origins;
+                       return_origins = vector;
                        return false;
                }
 
@@ -885,34 +907,39 @@ namespace Mono.CSharp
                        // nothing to do
                }
 
-               public override LabeledStatement LookupLabel (string name, Location loc)
+               public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt)
                {
+                       string name = goto_stmt.Target;
                        LabeledStatement s = Block.LookupLabel (name);
                        if (s != null)
                                throw new InternalErrorException ("Shouldn't get here");
 
-                       if (Parent != null) {
-                               s = Parent.LookupLabel (name, loc);
-                               if (s != null) {
-                                       Report.Error (1632, loc, "Control cannot leave the body of an anonymous method");
-                                       return null;
-                               }
+                       if (Parent == null) {
+                               Report.Error (159, goto_stmt.loc, "No such label `{0}' in this scope", name);
+                               return false;
                        }
 
-                       Report.Error (159, loc, "No such label `{0}' in this scope", name);
-                       return null;
+                       int errors = Report.Errors;
+                       Parent.AddGotoOrigin (vector, goto_stmt);
+                       if (errors == Report.Errors)
+                               Report.Error (1632, goto_stmt.loc, "Control cannot leave the body of an anonymous method");
+                       return false;
                }
 
-               public Reachability End ()
+               protected override UsageVector Merge ()
                {
-                       UsageVector result = Merge ();
+                       for (UsageVector origin = return_origins; origin != null; origin = origin.Next)
+                               CheckOutParameters (origin, origin.Location);
 
-                       Report.Debug (4, "MERGE TOP BLOCK", Location, result);
-
-                       if (!result.Reachability.AlwaysThrows && !result.Reachability.AlwaysHasBarrier)
-                               CheckOutParameters (result, Location);
+                       UsageVector vector = base.Merge ();
+                       CheckOutParameters (vector, Block.loc);
+                       // Note: we _do_not_ merge in the return origins
+                       return vector;
+               }
 
-                       return result.Reachability;
+               public Reachability End ()
+               {
+                       return Merge ().Reachability;
                }
        }
 
@@ -926,6 +953,20 @@ namespace Mono.CSharp
                UsageVector break_origins;
                UsageVector continue_origins;
                UsageVector return_origins;
+               GotoOrigin goto_origins;
+
+               class GotoOrigin {
+                       public GotoOrigin Next;
+                       public Goto GotoStmt;
+                       public UsageVector Vector;
+
+                       public GotoOrigin (UsageVector vector, Goto goto_stmt, GotoOrigin next)
+                       {
+                               Vector = vector;
+                               GotoStmt = goto_stmt;
+                               Next = next;
+                       }
+               }
 
                bool emit_finally;
 
@@ -972,10 +1013,14 @@ namespace Mono.CSharp
 
                public override bool AddBreakOrigin (UsageVector vector, Location loc)
                {
+                       vector = vector.Clone ();
                        if (finally_vector != null) {
-                               Report.Error (157, loc, "Control cannot leave the body of a finally clause");
+                               vector.MergeChild (finally_vector, false);
+                               int errors = Report.Errors;
+                               Parent.AddBreakOrigin (vector, loc);
+                               if (errors == Report.Errors)
+                                       Report.Error (157, loc, "Control cannot leave the body of a finally clause");
                        } else {
-                               vector = vector.Clone ();
                                vector.Location = loc;
                                vector.Next = break_origins;
                                break_origins = vector;
@@ -985,10 +1030,14 @@ namespace Mono.CSharp
 
                public override bool AddContinueOrigin (UsageVector vector, Location loc)
                {
+                       vector = vector.Clone ();
                        if (finally_vector != null) {
-                               Report.Error (157, loc, "Control cannot leave the body of a finally clause");
+                               vector.MergeChild (finally_vector, false);
+                               int errors = Report.Errors;
+                               Parent.AddContinueOrigin (vector, loc);
+                               if (errors == Report.Errors)
+                                       Report.Error (157, loc, "Control cannot leave the body of a finally clause");
                        } else {
-                               vector = vector.Clone ();
                                vector.Location = loc;
                                vector.Next = continue_origins;
                                continue_origins = vector;
@@ -998,10 +1047,14 @@ namespace Mono.CSharp
 
                public override bool AddReturnOrigin (UsageVector vector, Location loc)
                {
+                       vector = vector.Clone ();
                        if (finally_vector != null) {
-                               Report.Error (157, loc, "Control cannot leave the body of a finally clause");
+                               vector.MergeChild (finally_vector, false);
+                               int errors = Report.Errors;
+                               Parent.AddReturnOrigin (vector, loc);
+                               if (errors == Report.Errors)
+                                       Report.Error (157, loc, "Control cannot leave the body of a finally clause");
                        } else {
-                               vector = vector.Clone ();
                                vector.Location = loc;
                                vector.Next = return_origins;
                                return_origins = vector;
@@ -1009,6 +1062,25 @@ namespace Mono.CSharp
                        return true;
                }
 
+               public override bool AddGotoOrigin (UsageVector vector, Goto goto_stmt)
+               {
+                       LabeledStatement s = current_vector.Block == null ? null : current_vector.Block.LookupLabel (goto_stmt.Target);
+                       if (s != null)
+                               throw new InternalErrorException ("Shouldn't get here");
+
+                       vector = vector.Clone ();
+                       if (finally_vector != null) {
+                               vector.MergeChild (finally_vector, false);
+                               int errors = Report.Errors;
+                               Parent.AddGotoOrigin (vector, goto_stmt);
+                               if (errors == Report.Errors)
+                                       Report.Error (157, goto_stmt.loc, "Control cannot leave the body of a finally clause");
+                       } else {
+                               goto_origins = new GotoOrigin (vector, goto_stmt, goto_origins);
+                       }
+                       return true;
+               }
+
                public override void StealFinallyClauses (ref ArrayList list)
                {
                        if (list == null)
@@ -1022,28 +1094,6 @@ namespace Mono.CSharp
                        get { return emit_finally; }
                }
 
-               public override LabeledStatement LookupLabel (string name, Location loc)
-               {
-                       if (current_vector.Block == null)
-                               return base.LookupLabel (name, loc);
-
-                       LabeledStatement s = current_vector.Block.LookupLabel (name);
-                       if (s != null)
-                               return s;
-
-                       if (finally_vector != null) {
-                               Report.Error (157, loc, "Control cannot leave the body of a finally clause");
-                               return null;
-                       }
-
-                       return base.LookupLabel (name, loc);
-               }
-
-               public override void Label (UsageVector origin_vectors)
-               {
-                       CurrentUsageVector.MergeOrigins (origin_vectors);
-               }
-
                protected override UsageVector Merge ()
                {
                        Report.Debug (2, "  MERGING TRY/CATCH", Name);
@@ -1056,22 +1106,25 @@ namespace Mono.CSharp
                        for (UsageVector origin = break_origins; origin != null; origin = origin.Next) {
                                if (finally_vector != null)
                                        origin.MergeChild (finally_vector, false);
-                               if (!origin.Reachability.IsUnreachable)
-                                       Parent.AddBreakOrigin (origin, origin.Location);
+                               Parent.AddBreakOrigin (origin, origin.Location);
                        }
 
                        for (UsageVector origin = continue_origins; origin != null; origin = origin.Next) {
                                if (finally_vector != null)
                                        origin.MergeChild (finally_vector, false);
-                               if (!origin.Reachability.IsUnreachable)
-                                       Parent.AddContinueOrigin (origin, origin.Location);
+                               Parent.AddContinueOrigin (origin, origin.Location);
                        }
 
                        for (UsageVector origin = return_origins; origin != null; origin = origin.Next) {
                                if (finally_vector != null)
                                        origin.MergeChild (finally_vector, false);
-                               if (!origin.Reachability.IsUnreachable)
-                                       Parent.AddReturnOrigin (origin, origin.Location);
+                               Parent.AddReturnOrigin (origin, origin.Location);
+                       }
+
+                       for (GotoOrigin origin = goto_origins; origin != null; origin = origin.Next) {
+                               if (finally_vector != null)
+                                       origin.Vector.MergeChild (finally_vector, false);
+                               Parent.AddGotoOrigin (origin.Vector, origin.GotoStmt);
                        }
 
                        return vector;
@@ -1274,7 +1327,7 @@ namespace Mono.CSharp
                                        ArrayList non_public_fields = new ArrayList ();
 
                                        if (fields != null) {
-                                               foreach (FieldMember field in fields) {
+                                               foreach (FieldBase field in fields) {
                                                        if ((field.ModFlags & Modifiers.STATIC) != 0)
                                                                continue;
                                                        if ((field.ModFlags & Modifiers.PUBLIC) != 0)
@@ -1291,6 +1344,12 @@ namespace Mono.CSharp
                                        Fields = new FieldInfo [Count];
                                        public_fields.CopyTo (Fields, 0);
                                        non_public_fields.CopyTo (Fields, CountPublic);
+#if GMCS_SOURCE
+                               } else if (type is GenericTypeParameterBuilder) {
+                                       CountPublic = CountNonPublic = Count = 0;
+
+                                       Fields = new FieldInfo [0];
+#endif
                                } else {
                                        FieldInfo[] public_fields = type.GetFields (
                                                BindingFlags.Instance|BindingFlags.Public);
@@ -1700,49 +1759,53 @@ namespace Mono.CSharp
        // </summary>
        public class MyBitVector {
                public readonly int Count;
-               public MyBitVector InheritsFrom;
                public static readonly MyBitVector Empty = new MyBitVector ();
 
-               BitArray vector;
+               // Invariant: vector != null => vector.Count == Count
+               // Invariant: vector == null || shared == null
+               //            i.e., at most one of 'vector' and 'shared' can be non-null.  They can both be null -- that means all-ones
+               // The object in 'shared' cannot be modified, while 'vector' can be freely modified
+               BitArray vector, shared;
 
                MyBitVector ()
                {
-                       InheritsFrom = null;
-                       Count = 0;
+                       shared = new BitArray (0, false);
                }
 
                public MyBitVector (MyBitVector InheritsFrom, int Count)
                {
-                       if (InheritsFrom != null) {
-                               while (InheritsFrom.InheritsFrom != null)
-                                       InheritsFrom = InheritsFrom.InheritsFrom;                               
-                               if (InheritsFrom.Count >= Count && InheritsFrom.vector == null)
-                                       InheritsFrom = null;
-                       }
+                       if (InheritsFrom != null)
+                               shared = InheritsFrom.Shared;
 
-                       this.InheritsFrom = InheritsFrom;
                        this.Count = Count;
                }
 
+               // Use this accessor to get a shareable copy of the underlying BitArray representation
+               BitArray Shared {
+                       get {
+                               // Post-condition: vector == null
+                               if (shared == null) {
+                                       shared = vector;
+                                       vector = null;
+                               }
+                               return shared;
+                       }
+               }
+
                // <summary>
                //   Get/set bit `index' in the bit vector.
                // </summary>
-               public bool this [int index]
-               {
+               public bool this [int index] {
                        get {
                                if (index >= Count)
                                        throw new ArgumentOutOfRangeException ();
 
-                               // We're doing a "copy-on-write" strategy here; as long
-                               // as nobody writes to the array, we can use our parent's
-                               // copy instead of duplicating the vector.
-
                                if (vector != null)
                                        return vector [index];
-                               if (InheritsFrom == null)
+                               if (shared == null)
                                        return true;
-                               if (index < InheritsFrom.Count)
-                                       return InheritsFrom [index];
+                               if (index < shared.Count)
+                                       return shared [index];
                                return false;
                        }
 
@@ -1760,96 +1823,160 @@ namespace Mono.CSharp
                //   Performs an `or' operation on the bit vector.  The `new_vector' may have a
                //   different size than the current one.
                // </summary>
-               private void Or (MyBitVector new_vector)
+               private MyBitVector Or (MyBitVector new_vector)
                {
-                       int min = new_vector.Count;
+                       if (Count == 0 || new_vector.Count == 0)
+                               return this;
+
+                       BitArray o = new_vector.vector != null ? new_vector.vector : new_vector.shared;
+
+                       if (o == null) {
+                               int n = new_vector.Count;
+                               if (n < Count) {
+                                       for (int i = 0; i < n; ++i)
+                                               this [i] = true;
+                               } else {
+                                       SetAll (true);
+                               }
+                               return this;
+                       }
+
+                       if (Count == o.Count) {
+                               if (vector == null) {
+                                       if (shared == null)
+                                               return this;
+                                       initialize_vector ();
+                               }
+                               vector.Or (o);
+                               return this;
+                       }
+
+                       int min = o.Count;
                        if (Count < min)
                                min = Count;
 
-                       for (int i = 0; i < min; i++)
-                               this [i] |= new_vector [i];
+                       for (int i = 0; i < min; i++) {
+                               if (o [i])
+                                       this [i] = true;
+                       }
+
+                       return this;
                }
 
                // <summary>
-               //   Perfonrms an `and' operation on the bit vector.  The `new_vector' may have
+               //   Performs an `and' operation on the bit vector.  The `new_vector' may have
                //   a different size than the current one.
                // </summary>
-               private void And (MyBitVector new_vector)
+               private MyBitVector And (MyBitVector new_vector)
                {
-                       int min = new_vector.Count;
+                       if (Count == 0)
+                               return this;
+
+                       BitArray o = new_vector.vector != null ? new_vector.vector : new_vector.shared;
+
+                       if (o == null) {
+                               for (int i = new_vector.Count; i < Count; ++i)
+                                       this [i] = false;
+                               return this;
+                       }
+
+                       if (o.Count == 0) {
+                               SetAll (false);
+                               return this;
+                       }
+
+                       if (Count == o.Count) {
+                               if (vector == null) {
+                                       if (shared == null) {
+                                               shared = new_vector.Shared;
+                                               return this;
+                                       }
+                                       initialize_vector ();
+                               }
+                               vector.And (o);
+                               return this;
+                       }
+
+                       int min = o.Count;
                        if (Count < min)
                                min = Count;
 
-                       for (int i = 0; i < min; i++)
-                               this [i] &= new_vector [i];
+                       for (int i = 0; i < min; i++) {
+                               if (! o [i])
+                                       this [i] = false;
+                       }
 
                        for (int i = min; i < Count; i++)
                                this [i] = false;
+
+                       return this;
                }
 
-               public static void And (ref MyBitVector target, MyBitVector vector)
+               public static MyBitVector operator & (MyBitVector a, MyBitVector b)
                {
-                       if (vector == null)
-                               return;
-                       if (target == null)
-                               target = vector.Clone ();
+                       if (a == b)
+                               return a;
+                       if (a == null)
+                               return b.Clone ();
+                       if (b == null)
+                               return a.Clone ();
+                       if (a.Count > b.Count)
+                               return a.Clone ().And (b);
                        else
-                               target.And (vector);
+                               return b.Clone ().And (a);                                      
                }
 
-               public static void Or (ref MyBitVector target, MyBitVector vector)
+               public static MyBitVector operator | (MyBitVector a, MyBitVector b)
                {
-                       if (target == null)
-                               return;
-                       if (vector == null)
-                               target.SetAll (true);
+                       if (a == b)
+                               return a;
+                       if (a == null)
+                               return new MyBitVector (null, b.Count);
+                       if (b == null)
+                               return new MyBitVector (null, a.Count);
+                       if (a.Count > b.Count)
+                               return a.Clone ().Or (b);
                        else
-                               target.Or (vector);
+                               return b.Clone ().Or (a);
                }
 
-               // <summary>
-               //   This does a deep copy of the bit vector.
-               // </summary>
                public MyBitVector Clone ()
                {
-                       if (Count == 0)
-                               return Empty;
-                       MyBitVector retval = new MyBitVector (this, Count);
-                       retval.initialize_vector ();
-                       return retval;
+                       return Count == 0 ? Empty : new MyBitVector (this, Count);
                }
 
                public void SetAll (bool value)
                {
-                       InheritsFrom = value ? null : Empty;
+                       // Don't clobber Empty
+                       if (Count == 0)
+                               return;
+                       shared = value ? null : Empty.Shared;
                        vector = null;
                }
 
                void initialize_vector ()
                {
-                       if (InheritsFrom == null) {
+                       // Post-condition: vector != null
+                       if (shared == null) {
                                vector = new BitArray (Count, true);
                                return;
                        }
 
-                       vector = new BitArray (Count, false);
-
-                       int min = InheritsFrom.Count;
-                       if (min > Count)
-                               min = Count;
-
-                       for (int i = 0; i < min; i++)
-                               vector [i] = InheritsFrom [i];
-
-                       InheritsFrom = null;
+                       vector = new BitArray (shared);
+                       if (Count != vector.Count)
+                               vector.Length = Count;
+                       shared = null;
                }
 
                StringBuilder Dump (StringBuilder sb)
                {
-                       if (vector == null)
-                               return InheritsFrom == null ? sb.Append ("/") : InheritsFrom.Dump (sb.Append ("="));
-                       for (int i = 0; i < Count; i++)
-                               sb.Append (this [i] ? "1" : "0");
+                       BitArray dump = vector == null ? shared : vector;
+                       if (dump == null)
+                               return sb.Append ("/");
+                       if (dump == shared)
+                               sb.Append ("=");
+                       for (int i = 0; i < dump.Count; i++)
+                               sb.Append (dump [i] ? "1" : "0");
                        return sb;
                }