auto-enqueue reductions
[sbp.git] / src / edu / berkeley / sbp / Reduction.java
index e845764..06ae49b 100644 (file)
@@ -22,6 +22,7 @@ final class Reduction implements Comparable<Reduction> {
         this.result = result;
         this.phase = target;
         this.node = node;
+        target.reductionQueue.add(this);
     }
 
     public void perform() {
@@ -45,13 +46,13 @@ final class Reduction implements Comparable<Reduction> {
         return -1 * ret;
     }
 
-    private boolean isRightNullable(Walk.Cache c, Position p) {
+    private static boolean isRightNullable(Walk.Cache c, Position p) {
         if (p.isLast()) return true;
         if (!c.possiblyEpsilon(p.element())) return false;
         return isRightNullable(c, p.next());
     }
 
-    public boolean canKill(Walk.Cache cache, Position mep, Position himp) {
+    public static boolean canKill(Walk.Cache cache, Position mep, Position himp) {
         if (!isRightNullable(cache, mep))  return false;
         if (!isRightNullable(cache, himp)) return false;
         Sequence me  = mep.owner();
@@ -78,7 +79,7 @@ final class Reduction implements Comparable<Reduction> {
     public int pos() { return targetPhase()==null ? 0 : targetPhase().pos; }
     public GSS.Phase targetPhase() { return node.phase(); }
 
-    public boolean canNeed(Walk.Cache cache, Position mep, Position himp) {
+    public static boolean canNeed(Walk.Cache cache, Position mep, Position himp) {
         if (!isRightNullable(cache, mep))  return false;
         if (!isRightNullable(cache, himp)) return false;
         Sequence me  = mep.owner();