use Appendable rather than StringBuffer for toJava()
[sbp.git] / src / edu / berkeley / sbp / Tree.java
index 62dfa9d..cce7bfe 100644 (file)
@@ -45,7 +45,7 @@ public class Tree<NodeType>
     public Tree(Input.Region loc, NodeType head, List<Tree<NodeType>> kids){
         location = loc;
         ihead = head;
-        if (children.size() == 0)
+        if (kids.size() == 0)
             children = emptyTree;
         else {
             children = new Tree[kids.size()];
@@ -88,7 +88,9 @@ public class Tree<NodeType>
         if (head()==null) return null;
         if (head() instanceof ToJava) {
             StringBuffer sb = new StringBuffer();
-            ((ToJava)head()).toJava(sb);
+            try {
+                ((ToJava)head()).toJava(sb);
+            } catch (IOException e) { throw new RuntimeException(e); }
             return sb.toString();
         }
         return (head()==null?"null":("\""+StringUtil.toJavaString(head().toString())+"\""));