Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv7528/src/bossa/syntax
Modified Files:
typecheck.nice analyse.nice Statement.java LoopStmt.java
Added Files:
EmptyStmt.java
Log Message:
Handle for loops, when the test expression is optional and defaults to true.
Empty statements are now represented, together with their location in the
source.
--- NEW FILE: EmptyStmt.java ---
/**************************************************************************/
/* N I C E */
/* A high-level object-oriented research language */
/* (c) Daniel Bonniot 2003 */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/**************************************************************************/
package bossa.syntax;
/**
The empty statement.
@author Daniel Bonniot (bo...@us...)
*/
import bossa.util.*;
public class EmptyStmt extends Statement
{
public EmptyStmt (Location location)
{
super(location);
}
gnu.expr.Expression generateCode()
{
return gnu.expr.QuoteExp.voidExp;
}
}
Index: typecheck.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** typecheck.nice 4 May 2003 16:51:27 -0000 1.65
--- typecheck.nice 9 May 2003 13:17:03 -0000 1.66
***************
*** 537,540 ****
--- 537,543 ----
typecheck(null(Statement)) {}
+ //XXX: Now that there is an EmptyStmt class, it _might_ be possible
+ //XXX: (post 0.8) to remove the null case.
+ typecheck(@EmptyStmt) {}
typecheck(b@Block)
Index: analyse.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** analyse.nice 9 May 2003 11:31:40 -0000 1.66
--- analyse.nice 9 May 2003 13:17:03 -0000 1.67
***************
*** 599,603 ****
info.beginInner();
! if (l.isTestFirst())
{
l.whileExp = analyse(l.whileExp, info);
--- 599,603 ----
info.beginInner();
! if (l.isTestFirst() && l.whileExp != null)
{
l.whileExp = analyse(l.whileExp, info);
***************
*** 625,629 ****
info.endInner();
! if (notNull(l.whileExp).isTrue() && ! l.isBreakTarget())
info.setUnreachable();
}
--- 625,629 ----
info.endInner();
! if (l.isInfinite())
info.setUnreachable();
}
Index: Statement.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Statement.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Statement.java 20 Feb 2003 14:58:39 -0000 1.17
--- Statement.java 9 May 2003 13:17:03 -0000 1.18
***************
*** 26,29 ****
--- 26,36 ----
implements Located
{
+ Statement () {}
+
+ Statement (Location location)
+ {
+ setLocation(location);
+ }
+
/****************************************************************
* Code generation
Index: LoopStmt.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/LoopStmt.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** LoopStmt.java 9 May 2003 11:31:41 -0000 1.11
--- LoopStmt.java 9 May 2003 13:17:03 -0000 1.12
***************
*** 115,118 ****
--- 115,127 ----
boolean isBreakTarget() { return mustCreateBlock; }
+ /**
+ Returns true iff this loop never completes normally.
+ */
+ boolean isInfinite()
+ {
+ return (whileExp == null || whileExp.isTrue())
+ && ! isBreakTarget();
+ }
+
private boolean mustCreateBlock = false;
|