< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java

Print this page

 726         }
 727     }
 728 
 729     public void visitSkip(JCSkip tree) {
 730         try {
 731             print(";");
 732         } catch (IOException e) {
 733             throw new UncheckedIOException(e);
 734         }
 735     }
 736 
 737     public void visitBlock(JCBlock tree) {
 738         try {
 739             printFlags(tree.flags);
 740             printBlock(tree.stats);
 741         } catch (IOException e) {
 742             throw new UncheckedIOException(e);
 743         }
 744     }
 745 









 746     public void visitDoLoop(JCDoWhileLoop tree) {
 747         try {
 748             print("do ");
 749             printStat(tree.body);
 750             align();
 751             print(" while ");
 752             if (tree.cond.hasTag(PARENS)) {
 753                 printExpr(tree.cond);
 754             } else {
 755                 print("(");
 756                 printExpr(tree.cond);
 757                 print(")");
 758             }
 759             print(";");
 760         } catch (IOException e) {
 761             throw new UncheckedIOException(e);
 762         }
 763     }
 764 
 765     public void visitWhileLoop(JCWhileLoop tree) {
 766         try {
 767             print("while ");
 768             if (tree.cond.hasTag(PARENS)) {
 769                 printExpr(tree.cond);
 770             } else {
 771                 print("(");
 772                 printExpr(tree.cond);
 773                 print(")");
 774             }
 775             print(" ");
 776             printStat(tree.body);
 777         } catch (IOException e) {
 778             throw new UncheckedIOException(e);
 779         }
 780     }
 781 












 782     public void visitForLoop(JCForLoop tree) {
 783         try {
 784             print("for (");
 785             if (tree.init.nonEmpty()) {
 786                 if (tree.init.head.hasTag(VARDEF)) {
 787                     printExpr(tree.init.head);
 788                     for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
 789                         JCVariableDecl vdef = (JCVariableDecl)l.head;
 790                         print(", " + vdef.name);
 791                         if (vdef.init != null) {
 792                             print(" = ");
 793                             printExpr(vdef.init);
 794                         }
 795                     }
 796                 } else {
 797                     printExprs(tree.init);
 798                 }
 799             }
 800             print("; ");
 801             if (tree.cond != null) printExpr(tree.cond);

 726         }
 727     }
 728 
 729     public void visitSkip(JCSkip tree) {
 730         try {
 731             print(";");
 732         } catch (IOException e) {
 733             throw new UncheckedIOException(e);
 734         }
 735     }
 736 
 737     public void visitBlock(JCBlock tree) {
 738         try {
 739             printFlags(tree.flags);
 740             printBlock(tree.stats);
 741         } catch (IOException e) {
 742             throw new UncheckedIOException(e);
 743         }
 744     }
 745 
 746     public void visitDefaultValue(JCDefaultValue tree) {
 747         try {
 748             printExpr(tree.clazz, TreeInfo.postfixPrec);
 749             print(".default");
 750         } catch (IOException e) {
 751             throw new UncheckedIOException(e);
 752         }
 753     }
 754 
 755     public void visitDoLoop(JCDoWhileLoop tree) {
 756         try {
 757             print("do ");
 758             printStat(tree.body);
 759             align();
 760             print(" while ");
 761             if (tree.cond.hasTag(PARENS)) {
 762                 printExpr(tree.cond);
 763             } else {
 764                 print("(");
 765                 printExpr(tree.cond);
 766                 print(")");
 767             }
 768             print(";");
 769         } catch (IOException e) {
 770             throw new UncheckedIOException(e);
 771         }
 772     }
 773 
 774     public void visitWhileLoop(JCWhileLoop tree) {
 775         try {
 776             print("while ");
 777             if (tree.cond.hasTag(PARENS)) {
 778                 printExpr(tree.cond);
 779             } else {
 780                 print("(");
 781                 printExpr(tree.cond);
 782                 print(")");
 783             }
 784             print(" ");
 785             printStat(tree.body);
 786         } catch (IOException e) {
 787             throw new UncheckedIOException(e);
 788         }
 789     }
 790 
 791     public void visitWithField(JCWithField tree) {
 792         try {
 793             print("__WithField(");
 794             printExpr(tree.field);
 795             print(", ");
 796             printExpr(tree.value);
 797             print(")");
 798         } catch (IOException e) {
 799             throw new UncheckedIOException(e);
 800         }
 801     }
 802 
 803     public void visitForLoop(JCForLoop tree) {
 804         try {
 805             print("for (");
 806             if (tree.init.nonEmpty()) {
 807                 if (tree.init.head.hasTag(VARDEF)) {
 808                     printExpr(tree.init.head);
 809                     for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
 810                         JCVariableDecl vdef = (JCVariableDecl)l.head;
 811                         print(", " + vdef.name);
 812                         if (vdef.init != null) {
 813                             print(" = ");
 814                             printExpr(vdef.init);
 815                         }
 816                     }
 817                 } else {
 818                     printExprs(tree.init);
 819                 }
 820             }
 821             print("; ");
 822             if (tree.cond != null) printExpr(tree.cond);
< prev index next >