< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java

Print this page




 529                 Lint lintPrev = lint;
 530                 lint = lint.augment(tree.sym);
 531                 try{
 532                     scan(tree.init);
 533                 } finally {
 534                     lint = lintPrev;
 535                 }
 536             }
 537         }
 538 
 539         public void visitBlock(JCBlock tree) {
 540             scanStats(tree.stats);
 541         }
 542 
 543         public void visitDoLoop(JCDoWhileLoop tree) {
 544             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 545             pendingExits = new ListBuffer<>();
 546             scanStat(tree.body);
 547             alive = alive.or(resolveContinues(tree));
 548             scan(tree.cond);
 549             alive = alive.and(!tree.cond.type.isTrue());
 550             alive = alive.or(resolveBreaks(tree, prevPendingExits));
 551         }
 552 
 553         public void visitWhileLoop(JCWhileLoop tree) {
 554             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 555             pendingExits = new ListBuffer<>();
 556             scan(tree.cond);
 557             alive = Liveness.from(!tree.cond.type.isFalse());
 558             scanStat(tree.body);
 559             alive = alive.or(resolveContinues(tree));
 560             alive = resolveBreaks(tree, prevPendingExits).or(
 561                 !tree.cond.type.isTrue());
 562         }
 563 
 564         public void visitForLoop(JCForLoop tree) {
 565             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 566             scanStats(tree.init);
 567             pendingExits = new ListBuffer<>();
 568             if (tree.cond != null) {
 569                 scan(tree.cond);
 570                 alive = Liveness.from(!tree.cond.type.isFalse());
 571             } else {
 572                 alive = Liveness.ALIVE;
 573             }
 574             scanStat(tree.body);
 575             alive = alive.or(resolveContinues(tree));
 576             scan(tree.step);
 577             alive = resolveBreaks(tree, prevPendingExits).or(
 578                 tree.cond != null && !tree.cond.type.isTrue());
 579         }
 580 
 581         public void visitForeachLoop(JCEnhancedForLoop tree) {
 582             visitVarDef(tree.var);
 583             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 584             scan(tree.expr);
 585             pendingExits = new ListBuffer<>();
 586             scanStat(tree.body);
 587             alive = alive.or(resolveContinues(tree));
 588             resolveBreaks(tree, prevPendingExits);
 589             alive = Liveness.ALIVE;
 590         }
 591 
 592         public void visitLabelled(JCLabeledStatement tree) {
 593             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 594             pendingExits = new ListBuffer<>();
 595             scanStat(tree.body);
 596             alive = alive.or(resolveBreaks(tree, prevPendingExits));
 597         }
 598 


1777             if (tree != null) {
1778                 scan(tree);
1779                 if (inits.isReset()) {
1780                     merge();
1781                 }
1782             }
1783         }
1784 
1785         /** Analyze a list of expressions.
1786          */
1787         void scanExprs(List<? extends JCExpression> trees) {
1788             if (trees != null)
1789                 for (List<? extends JCExpression> l = trees; l.nonEmpty(); l = l.tail)
1790                     scanExpr(l.head);
1791         }
1792 
1793         /** Analyze a condition. Make sure to set (un)initsWhenTrue(WhenFalse)
1794          *  rather than (un)inits on exit.
1795          */
1796         void scanCond(JCTree tree) {
1797             if (tree.type.isFalse()) {
1798                 if (inits.isReset()) merge();
1799                 initsWhenTrue.assign(inits);
1800                 initsWhenTrue.inclRange(firstadr, nextadr);
1801                 uninitsWhenTrue.assign(uninits);
1802                 uninitsWhenTrue.inclRange(firstadr, nextadr);
1803                 initsWhenFalse.assign(inits);
1804                 uninitsWhenFalse.assign(uninits);
1805             } else if (tree.type.isTrue()) {
1806                 if (inits.isReset()) merge();
1807                 initsWhenFalse.assign(inits);
1808                 initsWhenFalse.inclRange(firstadr, nextadr);
1809                 uninitsWhenFalse.assign(uninits);
1810                 uninitsWhenFalse.inclRange(firstadr, nextadr);
1811                 initsWhenTrue.assign(inits);
1812                 uninitsWhenTrue.assign(uninits);
1813             } else {
1814                 scan(tree);
1815                 if (!inits.isReset())
1816                     split(tree.type != syms.unknownType);
1817             }
1818             if (tree.type != syms.unknownType) {
1819                 resetBits(inits, uninits);
1820             }
1821         }
1822 
1823         /* ------------ Visitor methods for various sorts of trees -------------*/
1824 
1825         public void visitClassDef(JCClassDecl tree) {




 529                 Lint lintPrev = lint;
 530                 lint = lint.augment(tree.sym);
 531                 try{
 532                     scan(tree.init);
 533                 } finally {
 534                     lint = lintPrev;
 535                 }
 536             }
 537         }
 538 
 539         public void visitBlock(JCBlock tree) {
 540             scanStats(tree.stats);
 541         }
 542 
 543         public void visitDoLoop(JCDoWhileLoop tree) {
 544             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 545             pendingExits = new ListBuffer<>();
 546             scanStat(tree.body);
 547             alive = alive.or(resolveContinues(tree));
 548             scan(tree.cond);
 549             alive = alive.and(!ConstFold.isTrue(tree.cond.type.getTag(), tree.cond.type.constValue()));
 550             alive = alive.or(resolveBreaks(tree, prevPendingExits));
 551         }
 552 
 553         public void visitWhileLoop(JCWhileLoop tree) {
 554             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 555             pendingExits = new ListBuffer<>();
 556             scan(tree.cond);
 557             alive = Liveness.from(!ConstFold.isFalse(tree.cond.type.getTag(), tree.cond.type.constValue()));
 558             scanStat(tree.body);
 559             alive = alive.or(resolveContinues(tree));
 560             alive = resolveBreaks(tree, prevPendingExits).or(
 561                 !ConstFold.isTrue(tree.cond.type.getTag(), tree.cond.type.constValue()));
 562         }
 563 
 564         public void visitForLoop(JCForLoop tree) {
 565             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 566             scanStats(tree.init);
 567             pendingExits = new ListBuffer<>();
 568             if (tree.cond != null) {
 569                 scan(tree.cond);
 570                 alive = Liveness.from(!ConstFold.isFalse(tree.cond.type.getTag(), tree.cond.type.constValue()));
 571             } else {
 572                 alive = Liveness.ALIVE;
 573             }
 574             scanStat(tree.body);
 575             alive = alive.or(resolveContinues(tree));
 576             scan(tree.step);
 577             alive = resolveBreaks(tree, prevPendingExits).or(
 578                 tree.cond != null && !ConstFold.isTrue(tree.cond.type.getTag(), tree.cond.type.constValue()));
 579         }
 580 
 581         public void visitForeachLoop(JCEnhancedForLoop tree) {
 582             visitVarDef(tree.var);
 583             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 584             scan(tree.expr);
 585             pendingExits = new ListBuffer<>();
 586             scanStat(tree.body);
 587             alive = alive.or(resolveContinues(tree));
 588             resolveBreaks(tree, prevPendingExits);
 589             alive = Liveness.ALIVE;
 590         }
 591 
 592         public void visitLabelled(JCLabeledStatement tree) {
 593             ListBuffer<PendingExit> prevPendingExits = pendingExits;
 594             pendingExits = new ListBuffer<>();
 595             scanStat(tree.body);
 596             alive = alive.or(resolveBreaks(tree, prevPendingExits));
 597         }
 598 


1777             if (tree != null) {
1778                 scan(tree);
1779                 if (inits.isReset()) {
1780                     merge();
1781                 }
1782             }
1783         }
1784 
1785         /** Analyze a list of expressions.
1786          */
1787         void scanExprs(List<? extends JCExpression> trees) {
1788             if (trees != null)
1789                 for (List<? extends JCExpression> l = trees; l.nonEmpty(); l = l.tail)
1790                     scanExpr(l.head);
1791         }
1792 
1793         /** Analyze a condition. Make sure to set (un)initsWhenTrue(WhenFalse)
1794          *  rather than (un)inits on exit.
1795          */
1796         void scanCond(JCTree tree) {
1797             if (ConstFold.isFalse(tree.type.getTag(), tree.type.constValue())) {
1798                 if (inits.isReset()) merge();
1799                 initsWhenTrue.assign(inits);
1800                 initsWhenTrue.inclRange(firstadr, nextadr);
1801                 uninitsWhenTrue.assign(uninits);
1802                 uninitsWhenTrue.inclRange(firstadr, nextadr);
1803                 initsWhenFalse.assign(inits);
1804                 uninitsWhenFalse.assign(uninits);
1805             } else if (ConstFold.isTrue(tree.type.getTag(), tree.type.constValue())) {
1806                 if (inits.isReset()) merge();
1807                 initsWhenFalse.assign(inits);
1808                 initsWhenFalse.inclRange(firstadr, nextadr);
1809                 uninitsWhenFalse.assign(uninits);
1810                 uninitsWhenFalse.inclRange(firstadr, nextadr);
1811                 initsWhenTrue.assign(inits);
1812                 uninitsWhenTrue.assign(uninits);
1813             } else {
1814                 scan(tree);
1815                 if (!inits.isReset())
1816                     split(tree.type != syms.unknownType);
1817             }
1818             if (tree.type != syms.unknownType) {
1819                 resetBits(inits, uninits);
1820             }
1821         }
1822 
1823         /* ------------ Visitor methods for various sorts of trees -------------*/
1824 
1825         public void visitClassDef(JCClassDecl tree) {


< prev index next >