X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FReduction.java;h=4ef2013e626d1655133757e1ca172dede2c2a67c;hp=5e59a4e241668499d8172a97febf32e61230e406;hb=8cf79c4b9e5a26ef65bd4af600946b45dbf28a8a;hpb=9d727bd14c659cdc6c34153b988e8d3fdb8067f5 diff --git a/src/edu/berkeley/sbp/Reduction.java b/src/edu/berkeley/sbp/Reduction.java index 5e59a4e..4ef2013 100644 --- a/src/edu/berkeley/sbp/Reduction.java +++ b/src/edu/berkeley/sbp/Reduction.java @@ -1,36 +1,37 @@ -// 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 { - private Position reduction; + private Pos reduction; private GSS.Phase phase; private Forest forest; - private Node parent; + private Node pred; - public Reduction(Node parent, Position reduction, Forest forest, GSS.Phase target) { + public Reduction(Node 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()); - if (master != 0 && master != signum(reduction.ord - r.reduction.ord)) - throw new Error("master="+master+" and a="+reduction.ord+" and b="+r.reduction.ord+"\n"+reduction+"\n"+r.reduction); + if (master != 0 && master != signum(reduction.ord() - r.reduction.ord())) + throw new Error("master="+master+" and a="+reduction.ord()+" and b="+r.reduction.ord()+"\n"+reduction+"\n"+r.reduction); */ - return reduction.ord - r.reduction.ord; + return reduction.compareTo(r.reduction); } private int signum(int x) { @@ -39,9 +40,11 @@ final class Reduction implements Comparable { return 1; } - public void perform() { new Result(forest, parent, reduction, phase); } - public GSS.Phase parentPhase() { return parent.phase(); } - public Position reduction() { return reduction; } + public void perform() { + Result.newResult(forest, pred, reduction, phase); + } + 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.ord+":"+ reduction+" "+reduction.owner(); } + public String toString() { return (pred.phase()==null ? 0 : pred.phase().pos) + ":"+reduction; } }