X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FResultNode.java;h=655b85a01e9740a4c8076522ecadd977c152999b;hp=579a86874726b882293402f841e57f8701dcbe26;hb=HEAD;hpb=d96df56ee69e62c4d4d6dfe3786ea4853e5120eb diff --git a/src/edu/berkeley/sbp/ResultNode.java b/src/edu/berkeley/sbp/ResultNode.java index 579a868..655b85a 100644 --- a/src/edu/berkeley/sbp/ResultNode.java +++ b/src/edu/berkeley/sbp/ResultNode.java @@ -9,19 +9,22 @@ import java.util.*; final class ResultNode extends Node { - private Forest.Many f = new Forest.Many(); private Pos reduction; + private Forest.Many f = new Forest.Many(); public void merge(Forest newf) { this.f.merge(newf); } public Pos reduction() { return reduction; } public boolean isDoomedState() { /* this is irrelevant */ return false; } public Forest getForest() { return f; } public String toString() { return super.toString()+"->"+phase(); } + public boolean hasPathToRoot() { + if (predecessorPhase()==null) return true; + return super.hasPathToRoot(); + } public void check() { if (destroyed) return; - if (successors.size()==0) destroy(); - else if (predecessors.size()==0) destroy(); + if (!hasSuccessors() || !hasPredecessors()) destroy(); } protected void destroy() { if (destroyed) return; @@ -29,10 +32,10 @@ final class ResultNode super.destroy(); } - public void addPred(StateNode pred) { + protected void addPred(StateNode pred) { super.addPred(pred); - // results have only one predecessor - if (predecessors.size() > 1) throw new Error(); + // results should have at most one predecessor + //if (predecessors.size() > 1) throw new Error(); } public ResultNode() { this(null, null, null); }