X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FTree.java;fp=src%2Fedu%2Fberkeley%2Fsbp%2FTree.java;h=1f55a906b8fea822ade0410bb6c751f7ff27f12d;hp=bc450fbcca15295294d2deb8ec58a0512e70588e;hb=2afdfe14e78fa0597186614937c679a09d74ecdf;hpb=c78e4efbba69fc058bbe487319b3abf5d94df3cb diff --git a/src/edu/berkeley/sbp/Tree.java b/src/edu/berkeley/sbp/Tree.java index bc450fb..1f55a90 100644 --- a/src/edu/berkeley/sbp/Tree.java +++ b/src/edu/berkeley/sbp/Tree.java @@ -41,9 +41,19 @@ public class Tree // FIXME: fairly inefficient because we keep copying arrays /** package-private constructor, allows setting the "lift" bit */ Tree(Input.Region loc, NodeType head, Tree[] children, boolean lift) { + this(loc, head, children, lift, false); + } + Tree(Input.Region loc, NodeType head, Tree[] children, boolean lift, boolean liftLeft) { this.location = loc; this.ihead = head; - if (lift && children != null && children.length > 0) { + // FIXME: lift+liftLeft togheter + if (liftLeft && children != null && children.length > 0) { + Tree last = children[0]; + this.children = new Tree[(children.length-1)+last.children.length]; + System.arraycopy(children, 1, this.children, last.children.length, children.length-1); + if (last.children.length > 0) + System.arraycopy(last.children, 0, this.children, 0, last.children.length); + } else if (lift && children != null && children.length > 0) { Tree last = children[children.length-1]; this.children = new Tree[(children.length-1)+last.children.length]; System.arraycopy(children, 0, this.children, 0, children.length-1);