X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FTree.java;h=5f7f73d22fd306303d10fa49f96274a37c59d892;hp=1f55a906b8fea822ade0410bb6c751f7ff27f12d;hb=584cef55d8811e3215858fde22e708d2a3d1cf70;hpb=eeb3a8b49bdbf753b5a70734fbae7f2c1ac06702 diff --git a/src/edu/berkeley/sbp/Tree.java b/src/edu/berkeley/sbp/Tree.java index 1f55a90..5f7f73d 100644 --- a/src/edu/berkeley/sbp/Tree.java +++ b/src/edu/berkeley/sbp/Tree.java @@ -35,32 +35,27 @@ public class Tree /** get the input region that this tree was parsed from */ public Input.Region getRegion() { return location; } - public Tree(Input.Region loc, NodeType head) { this(loc, head, null); } - public Tree(Input.Region loc, NodeType head, Tree[] children) { this(loc, head, children, false); } + public Tree(Input.Region loc, NodeType head) { this(loc, head, new Tree[0]); } + public Tree(Input.Region loc, NodeType head, Tree[] children) { this(loc, head, children, new boolean[children==null?0:children.length]); } // 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) { + Tree(Input.Region loc, NodeType head, Tree[] children, boolean[] lifts) { this.location = loc; this.ihead = head; - // 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); - if (last.children.length > 0) - System.arraycopy(last.children, 0, this.children, children.length-1, last.children.length); - } else { - this.children = ArrayUtil.clone(children, Tree.class); + + int count = 0; + for(int i=0; i