Permalink
Browse files

[monkeydoc] When encountering an old tree, we force nodes to be re-so…

…rted as they are instantiated to make sure the later match machinery works.
  • Loading branch information...
1 parent 1c177d3 commit ba09292a918d0a65f9d1b9eb05e324c5d8aa041e @garuma garuma committed Dec 19, 2012
Showing with 12 additions and 1 deletion.
  1. +4 −1 mcs/tools/monkeydoc/MonkeyDoc/Node.cs
  2. +8 −0 mcs/tools/monkeydoc/MonkeyDoc/Tree.cs
@@ -236,10 +236,13 @@ internal void Deserialize (BinaryReader reader)
nodes = new List<Node> (count);
for (int i = 0; i < count; i++) {
int child_address = DecodeInt (reader);
-
+
Node t = new Node (this, -child_address);
nodes.Add (t);
}
+
+ if (tree.ForceResort)
+ nodes.Sort ();
}
internal void Serialize (FileStream output, BinaryWriter writer)
@@ -124,6 +124,14 @@ public void InflateNode (Node baseNode)
InputStream.Position = address;
baseNode.Deserialize (InputReader);
}
+
+ // Nodes use this value to know if they should manually re-sort their child
+ // if they come from an older generator version
+ internal bool ForceResort {
+ get {
+ return VersionNumber == 0;
+ }
+ }
}
public static class TreeDumper

0 comments on commit ba09292

Please sign in to comment.