rename Node->StateNode
[sbp.git] / src / edu / berkeley / sbp / Reduction.java
index 676097e..0266782 100644 (file)
@@ -1,7 +1,7 @@
-// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+// Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
 
 package edu.berkeley.sbp;
-import edu.berkeley.sbp.Sequence.Position;
+import edu.berkeley.sbp.Sequence.Pos;
 import edu.berkeley.sbp.Sequence.Pos;
 
 final class Reduction implements Comparable<Reduction> {
@@ -9,22 +9,22 @@ final class Reduction implements Comparable<Reduction> {
     private Pos reduction;
     private GSS.Phase phase;
     private Forest forest;
-    private Node parent;
+    private StateNode pred;
     
-    public Reduction(Node parent, Pos reduction, Forest forest, GSS.Phase target) {
+    public Reduction(StateNode pred, Pos reduction, Forest forest, GSS.Phase target) {
         this.reduction = reduction;
         this.forest = forest;
         this.phase = target;
-        this.parent = parent;
+        this.pred = pred;
         target.addReduction(this);
     }
 
     public int compareTo(Reduction r) {
-        if (parent.phase()!=null || r.parent.phase()!=null) {
-            if (parent.phase()==null) return 1;
-            if (r.parent.phase()==null) return -1;
-            if (parent.phase().pos < r.parent.phase().pos) return 1;
-            if (parent.phase().pos > r.parent.phase().pos) return -1;
+        if (pred.phase()!=null || r.pred.phase()!=null) {
+            if (pred.phase()==null) return 1;
+            if (r.pred.phase()==null) return -1;
+            if (pred.phase().pos < r.pred.phase().pos) return 1;
+            if (pred.phase().pos > r.pred.phase().pos) return -1;
         }
         /*
         int master = Parser.mastercache.comparePositions(reduction(), r.reduction());
@@ -40,9 +40,12 @@ final class Reduction implements Comparable<Reduction> {
         return 1;
     }
 
-    public void perform() { new Result(forest, parent, reduction, phase); }
-    public GSS.Phase parentPhase() { return parent.phase(); }
+    public void perform() {
+        if (reduction==null) return;
+        phase.newNodeFromReduction(forest, reduction, pred);
+    }
+    public GSS.Phase predPhase() { return pred.phase(); }
     public Pos reduction() { return reduction; }
     public GSS.Phase targetPhase() { return phase; }
-    public String toString() { return (parent.phase()==null ? 0 : parent.phase().pos) + ":"+reduction; }
+    public String toString() { return (pred.phase()==null ? 0 : pred.phase().pos) + ":"+reduction; }
 }