remove Node from GSS.hash when destroyed
[sbp.git] / src / edu / berkeley / sbp / Node.java
index ccc2516..6fe6a74 100644 (file)
@@ -40,6 +40,8 @@ final class Node
         dead |= results.size()==0;
         if (!dead) return;
         destroyed = true;
+        if (phase() != null && phase().hash != null)
+            phase().hash.remove(state, predPhase);
         while(successors.size()>0)
             for(Result r : successors) {
                 successors.remove(r);
@@ -74,7 +76,7 @@ final class Node
         if (r.numPops()!=0)  reduce(r, r.numPops()-1, phase(), only);
         else {
             Input.Region region = phase().getLocation().createRegion(phase().getLocation());
-            new Result(r.rewrite(region), this, r, phase());
+            Result.newResult(r.rewrite(region), this, r, phase());
         }
     }
 
@@ -95,13 +97,13 @@ final class Node
         holder[pos] = old;
     }
 
-    Node(GSS.Phase phase, Result result, State state, boolean fromEmptyReduction) {
+    Node(GSS.Phase phase, Result pred, State state, boolean fromEmptyReduction) {
         this.phase = phase;
         this.state = state;
         this.fromEmptyReduction = fromEmptyReduction;
-        if (phase.hash.get(state, result.phase()) != null) throw new Error("severe problem!");
-        phase.hash.put(state, result.phase(), this);
-        addResult(result);
+        if (phase.hash.get(state, pred.phase()) != null) throw new Error("severe problem!");
+        phase.hash.put(state, pred.phase(), this);
+        addResult(pred);
         state.invokeEpsilonReductions(phase().token, this);
     }