tentative checkpoint
[sbp.git] / src / edu / berkeley / sbp / GSS.java
index 9b091a7..3df0c21 100644 (file)
@@ -148,7 +148,6 @@ class GSS {
         }
 
         private boolean newNode2(Node p, Node parent, Forest pending, State state, boolean fromEmptyReduction) {
-            //if (p.parents().contains(parent)) return true;
             if (p.merge(parent, pending)) return true;
             p.parents().add(parent, true);
             if (p!=parent && !fromEmptyReduction && reducing) p.performReductions(parent);
@@ -273,22 +272,7 @@ class GSS {
         final class Node implements Invokable<Position, Node, Node>, IntegerMappable, GraphViz.ToGraphViz {
             public FastSet<Node> set = new FastSet<Node>();
 
-        public GraphViz.Node toGraphViz(GraphViz gv) {
-            if (gv.hasNode(this)) return gv.createNode(this);
-            GraphViz.Node n = gv.createNode(this);
-            n.label = ""+state.toStringx();
-            n.shape = "rectangle";
-            n.fill = "green";
-            //GraphViz.Node f = pending().toGraphViz(gv);
-            //n.add(f);
-            for(Forest result : results()) n.edge(result, "");
-            for(Node parent : parents()) n.edge(parent, "");
-            ((GraphViz.Group)phase().toGraphViz(gv)).add(n);
-            return n;
-        }
-        public boolean isTransparent() { return false; }
-        public boolean isHidden() { return false; }
-
+           
             private boolean allqueued = false;
 
             /** what state this node is in */
@@ -346,6 +330,7 @@ class GSS {
             }
 
             public void reduce(Position r, int pos, Phase target, Forest[] holder, Node only) {
+                holder = r.holder;
                 Forest old = holder[pos];
 
                 for(Forest result : results())
@@ -353,7 +338,7 @@ class GSS {
                         if (only != null && child!=only) continue;
                         holder[pos] = result;
                         if (pos==0) {
-                            System.arraycopy(holder, 0, r.holder, 0, holder.length);
+                            //System.arraycopy(holder, 0, r.holder, 0, holder.length);
                             for(int i=0; i<r.pos; i++) if (r.holder[i]==null) throw new Error("realbad");
                             child.finish(r, r.rewrite(phase().getLocation()), target, holder);
                         } else {
@@ -381,6 +366,23 @@ class GSS {
             }
             public int toInt() { return idx; }
             private final int idx = node_idx++;
+
+            // GraphViz //////////////////////////////////////////////////////////////////////////////
+
+            public GraphViz.Node toGraphViz(GraphViz gv) {
+                if (gv.hasNode(this)) return gv.createNode(this);
+                GraphViz.Node n = gv.createNode(this);
+                n.label = ""+state.toStringx();
+                n.shape = "rectangle";
+                n.fill = "green";
+                for(Forest result : results()) n.edge(result, "");
+                for(Node parent : parents()) n.edge(parent, "");
+                ((GraphViz.Group)phase().toGraphViz(gv)).add(n);
+                return n;
+            }
+            public boolean isTransparent() { return false; }
+            public boolean isHidden() { return false; }
+
         }
         private int node_idx = 0;