< prev index next >

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

Print this page

 716         }
 717     }
 718 
 719     public void visitSkip(JCSkip tree) {
 720         try {
 721             print(";");
 722         } catch (IOException e) {
 723             throw new UncheckedIOException(e);
 724         }
 725     }
 726 
 727     public void visitBlock(JCBlock tree) {
 728         try {
 729             printFlags(tree.flags);
 730             printBlock(tree.stats);
 731         } catch (IOException e) {
 732             throw new UncheckedIOException(e);
 733         }
 734     }
 735 









 736     public void visitDoLoop(JCDoWhileLoop tree) {
 737         try {
 738             print("do ");
 739             printStat(tree.body);
 740             align();
 741             print(" while ");
 742             if (tree.cond.hasTag(PARENS)) {
 743                 printExpr(tree.cond);
 744             } else {
 745                 print("(");
 746                 printExpr(tree.cond);
 747                 print(")");
 748             }
 749             print(";");
 750         } catch (IOException e) {
 751             throw new UncheckedIOException(e);
 752         }
 753     }
 754 
 755     public void visitWhileLoop(JCWhileLoop tree) {
 756         try {
 757             print("while ");
 758             if (tree.cond.hasTag(PARENS)) {
 759                 printExpr(tree.cond);
 760             } else {
 761                 print("(");
 762                 printExpr(tree.cond);
 763                 print(")");
 764             }
 765             print(" ");
 766             printStat(tree.body);
 767         } catch (IOException e) {
 768             throw new UncheckedIOException(e);
 769         }
 770     }
 771 












 772     public void visitForLoop(JCForLoop tree) {
 773         try {
 774             print("for (");
 775             if (tree.init.nonEmpty()) {
 776                 if (tree.init.head.hasTag(VARDEF)) {
 777                     printExpr(tree.init.head);
 778                     for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
 779                         JCVariableDecl vdef = (JCVariableDecl)l.head;
 780                         print(", " + vdef.name);
 781                         if (vdef.init != null) {
 782                             print(" = ");
 783                             printExpr(vdef.init);
 784                         }
 785                     }
 786                 } else {
 787                     printExprs(tree.init);
 788                 }
 789             }
 790             print("; ");
 791             if (tree.cond != null) printExpr(tree.cond);

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