throw error when Forest created with head()
authoradam <adam@megacz.com>
Mon, 26 Mar 2007 05:43:10 +0000 (01:43 -0400)
committeradam <adam@megacz.com>
Mon, 26 Mar 2007 05:43:10 +0000 (01:43 -0400)
darcs-hash:20070326054310-5007d-9ce12658982503cec80723b8b849f38103526abd.gz

src/edu/berkeley/sbp/Forest.java

index b2f4a22..1730f60 100644 (file)
@@ -23,7 +23,7 @@ public abstract class Forest<NodeType> implements GraphViz.ToGraphViz {
     public void expand(HashSet<Tree<NodeType>> ht) { expand(ht, new HashSet<Forest<NodeType>>(), null); }
 
     static <NodeType> Forest<NodeType> create(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
     public void expand(HashSet<Tree<NodeType>> ht) { expand(ht, new HashSet<Forest<NodeType>>(), null); }
 
     static <NodeType> Forest<NodeType> create(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
-        if (loc == null) throw new Error();
+        if (loc == null) throw new RuntimeException("invoked Forest.create(null,,,,) -- this should never happen");
         return new One<NodeType>(loc, head, children, lift);
     }
 
         return new One<NodeType>(loc, head, children, lift);
     }
 
@@ -57,6 +57,7 @@ public abstract class Forest<NodeType> implements GraphViz.ToGraphViz {
         private One(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
             this.location = loc;
             this.head = head;
         private One(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
             this.location = loc;
             this.head = head;
+            if (head==null) throw new RuntimeException("invoked Forest.create(,null,,,) -- this should never happen");
             this.children = children==null ? emptyForestArray : new Forest[children.length];
             if (children != null) System.arraycopy(children, 0, this.children, 0, children.length);
             if (children != null) for(int i=0; i<children.length; i++) if (children[i]==null) throw new Error(i+"");
             this.children = children==null ? emptyForestArray : new Forest[children.length];
             if (children != null) System.arraycopy(children, 0, this.children, 0, children.length);
             if (children != null) for(int i=0; i<children.length; i++) if (children[i]==null) throw new Error(i+"");