refactor toInt() and related machinery into Node
[sbp.git] / src / edu / berkeley / sbp / StateNode.java
index 321334d..f54e65f 100644 (file)
@@ -12,9 +12,8 @@ import java.lang.reflect.*;
 
 /** a node in the GSS */
 final class StateNode
+    extends Node
     implements Invokable<Pos, ResultNode, Object>,
-               IntegerMappable,
-               GraphViz.ToGraphViz,
                Iterable<ResultNode> {
 
     /** which GSS.Phase this StateNode belongs to */
@@ -22,8 +21,6 @@ final class StateNode
     public Iterator<ResultNode> iterator() { return results.iterator(); }
     public Parser.Table.State state() { return state; }
 
-    public int toInt() { return idx; }
-
     boolean destroyed = false;
 
     public void check() {
@@ -60,9 +57,6 @@ final class StateNode
 
     //////////////////////////////////////////////////////////////////////
 
-    private static int node_idx = 0;
-    private final int idx = node_idx++;
-
     private final GSS.Phase phase;
     private final GSS.Phase predPhase;
     private final Parser.Table.State state;
@@ -144,22 +138,4 @@ final class StateNode
         result.addSucc(this);
         if (!this.fromEmptyReduction) state.invokeReductions(phase().getToken(), this, result);
     }
-
-    // GraphViz //////////////////////////////////////////////////////////////////////////////
-
-    public GraphViz.StateNode toGraphViz(GraphViz gv) {
-        if (results.size()==0) return null;
-        if (gv.hasNode(this)) return gv.createNode(this);
-        GraphViz.StateNode n = gv.createNode(this);
-        n.label = "state["+state.toInt()+"]";
-        n.shape = "rectangle";
-        boolean haspreds = false;
-        for(ResultNode r : results) n.edge(r, "");
-        n.color = state.doomed ? "red" : "green";
-        ((GraphViz.Group)phase().toGraphViz(gv)).add(n);
-        return n;
-    }
-    public boolean isTransparent() { return false; }
-    public boolean isHidden() { return false; }
-
 }