[Nice-commit] Nice/src/bossa/syntax analyse.nice,1.65,1.66 LoopStmt.java,1.10,1.11 Expression.java,1
Brought to you by:
bonniot
From: <bo...@us...> - 2003-05-09 11:31:44
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv1948/src/bossa/syntax Modified Files: analyse.nice LoopStmt.java Expression.java Log Message: Started support for flow analysis of loops with constant test. For this to really work, the booleans true and false will need to be considered as true constants, instead of the current global variables. This will be done after 0.8 is released. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** analyse.nice 8 May 2003 23:25:14 -0000 1.65 --- analyse.nice 9 May 2003 11:31:40 -0000 1.66 *************** *** 598,606 **** { info.beginInner(); if (l.isTestFirst()) ! l.whileExp = analyse(l.whileExp, info); ?LoopStmt save = info.currentLoop; info.currentLoop = l; analyse(l.loopBody, info); info.currentLoop = save; --- 598,614 ---- { info.beginInner(); + if (l.isTestFirst()) ! { ! l.whileExp = analyse(l.whileExp, info); ! if (notNull(l.whileExp).isFalse()) ! info.setUnreachable(); ! } ! ?LoopStmt save = info.currentLoop; info.currentLoop = l; + analyse(l.loopBody, info); + info.currentLoop = save; *************** *** 616,619 **** --- 624,630 ---- info.endInner(); + + if (notNull(l.whileExp).isTrue() && ! l.isBreakTarget()) + info.setUnreachable(); } *************** *** 622,626 **** ?LoopStmt loop = info.currentLoop; if (loop == null) ! throw error(b, "continue must only occur inside loops"); loop.createBlock(); --- 633,637 ---- ?LoopStmt loop = info.currentLoop; if (loop == null) ! throw error(b, "break must only occur inside loops"); loop.createBlock(); Index: LoopStmt.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/LoopStmt.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LoopStmt.java 11 Mar 2003 17:14:38 -0000 1.10 --- LoopStmt.java 9 May 2003 11:31:41 -0000 1.11 *************** *** 109,112 **** --- 109,118 ---- } + /** + Returns true iff there exists a break statement that target this loop. + This means that the loop can complete abruptly because of that break. + */ + boolean isBreakTarget() { return mustCreateBlock; } + private boolean mustCreateBlock = false; Index: Expression.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Expression.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** Expression.java 30 Apr 2003 18:55:31 -0000 1.46 --- Expression.java 9 May 2003 11:31:41 -0000 1.47 *************** *** 88,91 **** --- 88,101 ---- } + boolean isFalse() + { + return false; + } + + boolean isTrue() + { + return false; + } + /** * Resolves overloading, taking into account the parameters |