[Nice-commit] Nice/src/bossa/syntax typecheck.nice,1.126,1.127 return.nice,1.4,1.5 enum.nice,1.19,1.
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-03-07 17:11:37
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18310/src/bossa/syntax Modified Files: typecheck.nice return.nice enum.nice Log Message: Allow value returns in void methods. We don't need to distinguish between real and "fake" (sugared) returns. Index: return.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/return.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** return.nice 1 Dec 2004 02:00:32 -0000 1.4 --- return.nice 7 Mar 2005 17:10:51 -0000 1.5 *************** *** 22,26 **** { Expression value; - boolean fake = false; mlsub.typing.Polytype returnType() --- 22,25 ---- *************** *** 61,77 **** public Statement createReturnStmt(?Expression value) { - return createReturnStmt(value, false); - } - - /** - @param fake This return was not explicitely written, but is the result - of syntactic sugar. - */ - public Statement createReturnStmt(?Expression value, boolean fake) - { if (value == null) return new VoidReturnStmt(); ! let res = new ReturnStmt(value: value, fake: fake); res.setLocation(value.location()); return res; --- 60,67 ---- public Statement createReturnStmt(?Expression value) { if (value == null) return new VoidReturnStmt(); ! let res = new ReturnStmt(value: value); res.setLocation(value.location()); return res; Index: enum.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/enum.nice,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** enum.nice 6 Mar 2005 01:34:26 -0000 1.19 --- enum.nice 7 Mar 2005 17:10:51 -0000 1.20 *************** *** 82,86 **** globalDefs.add(createMethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( ! elements.map(createIdentExp)), true))); //generate the prettyprint string --- 82,86 ---- globalDefs.add(createMethodBodyDefinition(impl, new LocatedString("family"), null, new LinkedList(), createReturnStmt(createLiteralArrayExp( ! elements.map(createIdentExp))))); //generate the prettyprint string Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** typecheck.nice 7 Mar 2005 08:16:53 -0000 1.126 --- typecheck.nice 7 Mar 2005 17:10:50 -0000 1.127 *************** *** 914,923 **** r.value = r.value.noOverloading(); else ! { ! if (! r.fake && nice.tools.typing.Types.isVoid(expectedType)) ! throw bossa.util.User.error(r, "Cannot return a value here"); ! ! r.value = r.value.resolveOverloading(new mlsub.typing.Polytype(expectedType)); ! } try { typecheck(r.value); } --- 914,918 ---- r.value = r.value.noOverloading(); else ! r.value = r.value.resolveOverloading(new mlsub.typing.Polytype(expectedType)); try { typecheck(r.value); } *************** *** 925,929 **** try{ ! if (! (r.fake && expectedType != null && nice.tools.typing.Types.isVoid(expectedType))) function.checkReturnedType(r.returnType()); } --- 920,924 ---- try{ ! if (! (expectedType != null && nice.tools.typing.Types.isVoid(expectedType))) function.checkReturnedType(r.returnType()); } |