nice-commit Mailing List for The Nice Programming Language (Page 42)
Brought to you by:
bonniot
You can subscribe to this list here.
2003 |
Jan
|
Feb
(60) |
Mar
(125) |
Apr
(183) |
May
(140) |
Jun
(227) |
Jul
(141) |
Aug
(181) |
Sep
(75) |
Oct
(89) |
Nov
(187) |
Dec
(162) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(69) |
Feb
(197) |
Mar
(98) |
Apr
(26) |
May
(10) |
Jun
(85) |
Jul
(88) |
Aug
(79) |
Sep
(80) |
Oct
(81) |
Nov
(53) |
Dec
(109) |
2005 |
Jan
(68) |
Feb
(77) |
Mar
(232) |
Apr
(79) |
May
(37) |
Jun
(37) |
Jul
(3) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(10) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(9) |
2007 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
(17) |
Dec
(6) |
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Daniel B. <bo...@us...> - 2004-07-30 15:38:57
|
Update of /cvsroot/nice/Nice/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv367/bin Modified Files: niceunit.bat nicedoc.bat nicec.bat nicec Log Message: Call 'dispatch' classes instead of 'fun', so that stack traces are printed correctly. Index: nicec.bat =================================================================== RCS file: /cvsroot/nice/Nice/bin/nicec.bat,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** nicec.bat 2 Jul 2004 21:15:00 -0000 1.17 --- nicec.bat 30 Jul 2004 15:38:45 -0000 1.18 *************** *** 15,19 **** :gotNice ! java -Xms8M -classpath %NICEPATH%\nice.jar;%CLASSPATH% nice.tools.compiler.console.fun --runtime=%NICEPATH%\nice.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 :end --- 15,19 ---- :gotNice ! java -Xms8M -classpath %NICEPATH%\nice.jar;%CLASSPATH% nice.tools.compiler.console.dispatch --runtime=%NICEPATH%\nice.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 :end Index: niceunit.bat =================================================================== RCS file: /cvsroot/nice/Nice/bin/niceunit.bat,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** niceunit.bat 20 Feb 2004 17:35:43 -0000 1.1 --- niceunit.bat 30 Jul 2004 15:38:45 -0000 1.2 *************** *** 15,19 **** :gotNice ! java -classpath %NICEPATH%\nice.jar;%CLASSPATH% nice.tools.unit.console.fun %1 %2 %3 %4 %5 %6 %7 %8 %9 :end --- 15,19 ---- :gotNice ! java -classpath %NICEPATH%\nice.jar;%CLASSPATH% nice.tools.unit.console.dispatch %1 %2 %3 %4 %5 %6 %7 %8 %9 :end Index: nicedoc.bat =================================================================== RCS file: /cvsroot/nice/Nice/bin/nicedoc.bat,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nicedoc.bat 16 Feb 2004 13:54:07 -0000 1.1 --- nicedoc.bat 30 Jul 2004 15:38:45 -0000 1.2 *************** *** 15,19 **** :gotNice ! java -classpath %NICEPATH%\nice.jar;%CLASSPATH% nice.tools.doc.fun %1 %2 %3 %4 %5 %6 %7 %8 %9 :end --- 15,19 ---- :gotNice ! java -classpath %NICEPATH%\nice.jar;%CLASSPATH% nice.tools.doc.dispatch %1 %2 %3 %4 %5 %6 %7 %8 %9 :end Index: nicec =================================================================== RCS file: /cvsroot/nice/Nice/bin/nicec,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** nicec 28 Jul 2004 14:28:09 -0000 1.40 --- nicec 30 Jul 2004 15:38:45 -0000 1.41 *************** *** 73,77 **** nicedoc) class=nice.tools.doc.dispatch ;; niceunit) class=nice.tools.unit.console.dispatch ;; ! nicec) class=nice.tools.compiler.console.fun system_args="--runtime=${NICEC_JAR}" --- 73,77 ---- nicedoc) class=nice.tools.doc.dispatch ;; niceunit) class=nice.tools.unit.console.dispatch ;; ! nicec) class=nice.tools.compiler.console.dispatch system_args="--runtime=${NICEC_JAR}" |
From: Arjan B. <ar...@us...> - 2004-07-30 13:06:30
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4100/F:/nice/src/bossa/syntax Modified Files: dispatch.java.bootstrap tools.nice Added Files: super.nice Removed Files: SuperExp.java Log Message: Converted SuperExp.java to nice. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** tools.nice 29 Jul 2004 12:11:40 -0000 1.37 --- tools.nice 30 Jul 2004 13:06:21 -0000 1.38 *************** *** 163,166 **** --- 163,167 ---- Map<VarSymbol,mlsub.typing.Polytype> types(Arguments) = native Arguments.types; <T> String map(String, String, String, T[]) = native String bossa.util.Util.map(String, String, String, Object[]); + Stack<bossa.link.Alternative> sortedAlternatives(MethodDeclaration) = native Stack bossa.link.Alternative.sortedAlternatives(MethodDeclaration); // Retypings needed since java types are not strict. --- NEW FILE: super.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.link.*; import bossa.util.*; /** A call to the next most specific implementation of a method. */ public class SuperExp extends Expression { ?List<TypeIdent> types; ?List<TypeConstructor> tc = null; ?MethodBodyDefinition currentMethod = null; ?Alternative superAlternative = null; ?gnu.bytecode.Method superMethod = null; void setCurrentMethod(MethodBodyDefinition m) { currentMethod = m; let decl = notNull(currentMethod).getDeclaration(); if (tc != null && notNull(tc).size() != decl.getArity()) User.error(this, "Number of types doesn't match the number of arguments"); superAlternative = this.getSuperAlt(decl); } private ?Alternative getSuperAlt(MethodDeclaration decl) { ?Alternative superAlt = null; Alternative current = notNull(currentMethod).getAlternative(); let ?Alternative minimumAlt; if (tc == null) minimumAlt = null; else minimumAlt = new Alternative("", notNull(tc).map(TypeConstructor tc => new Pattern(tc, false)).toArray()); // Look for the first alternative more general than the current one. for (alt : Alternative.sortedAlternatives(decl)) { if (alt == current) continue; if (minimumAlt != null) if (! Alternative.leq(alt, minimumAlt)) continue; if (Alternative.leq(current, alt)) if (superAlt == null || Alternative.leq(alt, superAlt)) superAlt = alt; else if (Alternative.leq(superAlt, alt)) {} // superAlt is a more direct parent than alt, so ignore alt. else { String message = "This call to super is ambiguous. " + "Possible parents are:\n" + superAlt + "\nand\n" + alt; throw User.error(this, message); } } if (superAlt != null) return superAlt; if (decl instanceof JavaMethod) { this.getSuper(decl); return null; } else throw User.error(this, "There is no super implementation to call"); } private void getSuper(JavaMethod decl) { gnu.bytecode.Type firstArg = nice.tools.code.Types.get(notNull(currentMethod).firstArgument()); if (! (firstArg instanceof gnu.bytecode.ClassType)) throw User.error(this, "The first argument of this method is not a class"); superMethod = getImplementationAbove(decl, firstArg); if (superMethod == null) throw User.error(this, "There is no super implementation to call"); return; } void resolveTC(TypeScope scope) { if (types != null) tc = notNull(types).map(TypeIdent ti => ti.resolveToTC(scope)); } computeType() { mlsub.typing.Polytype type = notNull(currentMethod).getDeclaration().getType(); mlsub.typing.FunType monotype; mlsub.typing.Constraint constraint; if (! type.isMonomorphic()) { // The type of super is computed by restricting the method type // to the patterns of the super implementation. type = type.cloneType(); monotype = cast(type.getMonotype()); mlsub.typing.Monotype[] m = monotype.domain(); List<mlsub.typing.AtomicConstraint> newAtoms = new ArrayList(); mlsub.typing.AtomicConstraint[?] oldAtoms = type.getConstraint().atoms(); if (oldAtoms != null) newAtoms.addAll(oldAtoms); if (superAlternative != null) { let p = notNull(superAlternative).getPatterns(); for (int i = 0; i < p.length; i++) if (p[i].tc != null) newAtoms.add(new TypeConstructorLeqMonotypeCst(p[i].tc, m[i])); } else { ?TypeConstructor superTC = null; try { superTC = nice.tools.code.Types.typeConstructor(notNull(superMethod).getDeclaringClass()); } catch(nice.tools.code.Types.NotIntroducedClassException ex ) {} if (superTC != null) newAtoms.add(new TypeConstructorLeqMonotypeCst(superTC, m[0])); else // Our safe bet is to assert that the argument is Object. newAtoms.add(new mlsub.typing.MonotypeLeqCst(bossa.syntax.Monotype.sure(mlsub.typing.TopMonotype.instance), m[0])); } constraint = new mlsub.typing.Constraint(type.getConstraint().binders(), new mlsub.typing.AtomicConstraint[newAtoms.size()].fillWith(newAtoms)); } else { monotype = cast(type.getMonotype()); constraint = mlsub.typing.Constraint.True; } this.type = new mlsub.typing.Polytype(constraint, monotype.codomain()); } compile() { gnu.expr.Expression code; if (superAlternative != null) code = notNull(superAlternative).methodExp(); else // It does not matter which method is called (the super method or // the base method), a call to super is emited. { let NiceClass nc = cast(ClassDefinition.get(notNull(currentMethod).firstArgument()).implementation); code = nc.callSuperMethod(notNull(superMethod)); } return new gnu.expr.ApplyExp(code,notNull(currentMethod).compiledArguments()); } toString() = "super" + (types == null ? "" : Util.map("(", ", ", ")", toArray(notNull(types)))); } public ?gnu.bytecode.Method getImplementationAbove(JavaMethod decl, gnu.bytecode.ClassType firstArg) { let thisMethod = decl.reflectMethod; let superClass = firstArg.getSuperclass(); if (superClass == null) return null; return superClass.getMethod(notNull(thisMethod).getName(), notNull(thisMethod).getParameterTypes(), true); } Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dispatch.java.bootstrap 28 Jul 2004 14:40:33 -0000 1.13 --- dispatch.java.bootstrap 30 Jul 2004 13:06:21 -0000 1.14 *************** *** 28,31 **** --- 28,34 ---- { return null; } + public static gnu.bytecode.Method getImplementationAbove(JavaMethod decl, gnu.bytecode.ClassType firstArg) + { return null; } + static List removeNonMinimal(List l) { return null; } --- SuperExp.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-07-30 13:06:28
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4100/F:/nice/src/bossa/link Modified Files: Alternative.java Dispatch.java Log Message: Converted SuperExp.java to nice. Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** Dispatch.java 25 Feb 2004 11:23:29 -0000 1.67 --- Dispatch.java 30 Jul 2004 13:06:20 -0000 1.68 *************** *** 276,280 **** if (firstArg != null) { ! gnu.bytecode.Method superImplementation = SuperExp.getImplementationAbove ((JavaMethod) method, firstArg); if (superImplementation != null && --- 276,280 ---- if (firstArg != null) { ! gnu.bytecode.Method superImplementation = bossa.syntax.dispatch.getImplementationAbove ((JavaMethod) method, firstArg); if (superImplementation != null && Index: Alternative.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Alternative.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Alternative.java 28 Feb 2004 20:24:16 -0000 1.49 --- Alternative.java 30 Jul 2004 13:06:20 -0000 1.50 *************** *** 39,43 **** */ ! public abstract class Alternative implements Located { /** --- 39,43 ---- */ ! public class Alternative implements Located { /** *************** *** 128,132 **** * @return the expression that represents the method body. */ ! public abstract Expression methodExp(); /** --- 128,136 ---- * @return the expression that represents the method body. */ ! public Expression methodExp() ! { ! Internal.error("methodExp called in " + getClass()); ! return null; ! } /** *************** *** 166,169 **** --- 170,175 ---- public Pattern[] getPatterns() { return patterns; } + public bossa.util.Location location() { return bossa.util.Location.nowhere(); } + /**************************************************************** * Regrouping alternatives per method |
From: Daniel B. <bo...@us...> - 2004-07-29 18:30:33
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29055/src/bossa/syntax Modified Files: overloadedsymbol.nice Log Message: Properly release cloned types when resolving overloading with overlapping Java methods. Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** overloadedsymbol.nice 28 Jul 2004 14:40:33 -0000 1.1 --- overloadedsymbol.nice 29 Jul 2004 18:30:08 -0000 1.2 *************** *** 626,629 **** --- 626,630 ---- { // We can remove either, since they lead to the same implementation + syms[i].releaseClonedType(); symbols.remove(syms[i]); // Since we removed i, we don't need to continue this loop. |
From: Daniel B. <bo...@us...> - 2004-07-29 18:30:33
|
Update of /cvsroot/nice/Nice/testsuite/compiler/overloading In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29055/testsuite/compiler/overloading Modified Files: java.testsuite Log Message: Properly release cloned types when resolving overloading with overlapping Java methods. Index: java.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/overloading/java.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** java.testsuite 10 Jun 2004 13:40:27 -0000 1.1 --- java.testsuite 29 Jul 2004 18:30:08 -0000 1.2 *************** *** 10,12 **** --- 10,13 ---- { o.flush(); + o.flush(); } |
From: Daniel B. <bo...@us...> - 2004-07-29 12:45:34
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29337/debian Added Files: watch Log Message: Added upstream watch file for Debian. --- NEW FILE: watch --- version=2 ftp://ftp2.sf.net/pub/sourceforge/n/ni/nice/Nice-(\d\.[\d+\.]+)-source\.tar\.(gz|bz2) debian uupdate |
From: Arjan B. <ar...@us...> - 2004-07-29 12:36:22
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27720/F:/nice/stdlib/nice/lang Modified Files: array.nice bigint.nice booleans.nice collections.nice numeric.nice Log Message: Removed usage of old pattern syntax. Index: collections.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/collections.nice,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** collections.nice 27 Jun 2004 17:34:34 -0000 1.70 --- collections.nice 29 Jul 2004 12:36:12 -0000 1.71 *************** *** 129,133 **** ****************************************************************/ ! <T> foreach(col...@ja...llection, action) { for (T elem : collection) --- 129,133 ---- ****************************************************************/ ! <T> foreach(java.util.Collection collection, action) { for (T elem : collection) *************** *** 162,174 **** } ! similarEmptyCollection(c#ArrayList) = new ArrayList(c.size()); ! similarEmptyCollection(c#LinkedList) = new LinkedList(); ! similarEmptyCollection(c#Vector) = new Vector(c.size()); ! similarEmptyCollection(c#Stack) = new Stack(); ! similarEmptyCollection(c#HashSet) = new HashSet(c.size()); /**************************************************************** --- 162,174 ---- } ! similarEmptyCollection(#ArrayList c) = new ArrayList(c.size()); ! similarEmptyCollection(#LinkedList c) = new LinkedList(); ! similarEmptyCollection(#Vector c) = new Vector(c.size()); ! similarEmptyCollection(#Stack c) = new Stack(); ! similarEmptyCollection(#HashSet c) = new HashSet(c.size()); /**************************************************************** Index: array.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/array.nice,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** array.nice 23 Jul 2004 23:29:00 -0000 1.36 --- array.nice 29 Jul 2004 12:36:12 -0000 1.37 *************** *** 89,95 **** // Define collection methods ! <C,T,U> map(a@Array, func) = fill(new U[a.length], int i => func(a[i])); ! <C,T,U> filter(a@Array, test) { int l = a.length; --- 89,95 ---- // Define collection methods ! <C,T,U> map(Array a, func) = fill(new U[a.length], int i => func(a[i])); ! <C,T,U> filter(Array a, test) { int l = a.length; Index: booleans.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/booleans.nice,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** booleans.nice 19 Nov 2003 16:04:46 -0000 1.15 --- booleans.nice 29 Jul 2004 12:36:12 -0000 1.16 *************** *** 32,39 **** */ ! `!`(b@boolean) = b ? false : true; ! `&`(b1@boolean,b2@boolean) = b1 ? b2 : false; ! `|`(b1@boolean,b2@boolean) = b1 ? true : b2; ! `^`(b1@boolean,b2@boolean) = b1 ? !b2 : b2; // same methods, but overloaded for better efficiency (no dispatch and no boxing). --- 32,39 ---- */ ! `!`(boolean b) = b ? false : true; ! `&`(boolean b1, boolean b2) = b1 ? b2 : false; ! `|`(boolean b1, boolean b2) = b1 ? true : b2; ! `^`(boolean b1, boolean b2) = b1 ? !b2 : b2; // same methods, but overloaded for better efficiency (no dispatch and no boxing). *************** *** 46,48 **** boolean `||`(boolean, boolean) = inline nice.lang.inline.ShortCircuitOp("||"); ! `<`(b1@boolean, b2@boolean) = b2 || !b1; --- 46,48 ---- boolean `||`(boolean, boolean) = inline nice.lang.inline.ShortCircuitOp("||"); ! `<`(boolean b1 ,boolean b2) = b2 || !b1; Index: numeric.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/numeric.nice,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** numeric.nice 19 Nov 2003 16:04:45 -0000 1.33 --- numeric.nice 29 Jul 2004 12:36:12 -0000 1.34 *************** *** 220,224 **** // Comparable interface ! `<`(n1@Number, n2@Number) = n1.doubleValue() < n2.doubleValue(); // exponential functions --- 220,224 ---- // Comparable interface ! `<`(Number n1, Number n2) = n1.doubleValue() < n2.doubleValue(); // exponential functions Index: bigint.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/bigint.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** bigint.nice 19 Nov 2003 16:04:46 -0000 1.4 --- bigint.nice 29 Jul 2004 12:36:12 -0000 1.5 *************** *** 47,49 **** implementations that use < and boolean negation. */ ! `<`(x@BigInteger, y@BigInteger) = x.compareTo(y) < 0; --- 47,49 ---- implementations that use < and boolean negation. */ ! `<`(BigInteger x, BigInteger y) = x.compareTo(y) < 0; |
From: Arjan B. <ar...@us...> - 2004-07-29 12:36:22
|
Update of /cvsroot/nice/Nice/stdlib/nice/getopt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27720/F:/nice/stdlib/nice/getopt Modified Files: getopt.nice Log Message: Removed usage of old pattern syntax. Index: getopt.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/getopt/getopt.nice,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** getopt.nice 21 May 2004 17:01:08 -0000 1.22 --- getopt.nice 29 Jul 2004 12:36:13 -0000 1.23 *************** *** 9,22 **** int optType(Option); ! optType(o@NoParamOption) = NO_ARGUMENT; ! optType(o@ParamOption) = REQUIRED_ARGUMENT; ! optType(o@OptionalParamOption) = OPTIONAL_ARGUMENT; String optSuffix(Option); ! optSuffix(o@NoParamOption) = ""; ! optSuffix(o@ParamOption) = ":"; ! optSuffix(o@OptionalParamOption) = "::"; ! parse(progName@String, args, options) { List<LongOpt> longOptions = new ArrayList(options.length); --- 9,22 ---- int optType(Option); ! optType(NoParamOption o) = NO_ARGUMENT; ! optType(ParamOption o) = REQUIRED_ARGUMENT; ! optType(OptionalParamOption o) = OPTIONAL_ARGUMENT; String optSuffix(Option); ! optSuffix(NoParamOption o) = ""; ! optSuffix(ParamOption o) = ":"; ! optSuffix(OptionalParamOption o) = "::"; ! parse(String progName, args, options) { List<LongOpt> longOptions = new ArrayList(options.length); *************** *** 68,74 **** void doAction(Option, Getopt); ! doAction(o@NoParamOption,g) = action(o)(); ! doAction(o@ParamOption,g) = actionParam(o)(notNull(g.getOptarg())); ! doAction(o@OptionalParamOption,g) { --- 68,74 ---- void doAction(Option, Getopt); ! doAction(NoParamOption o, g) = action(o)(); ! doAction(ParamOption o, g) = actionParam(o)(notNull(g.getOptarg())); ! doAction(OptionalParamOption o, g) { *************** *** 119,125 **** String paramString(Option); ! paramString(@NoParamOption) = ""; ! paramString(o@ParamOption) = " " + o.optionHint.toUpperCase(); ! paramString(o@OptionalParamOption) = "[=" + o.optionHint.toUpperCase() + "]"; String pad(String s, int len, char c) --- 119,125 ---- String paramString(Option); ! paramString(NoParamOption o) = ""; ! paramString(ParamOption o) = " " + o.optionHint.toUpperCase(); ! paramString(OptionalParamOption o) = "[=" + o.optionHint.toUpperCase() + "]"; String pad(String s, int len, char c) |
From: Arjan B. <ar...@us...> - 2004-07-29 12:11:52
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23653/F:/nice/src/bossa/syntax Modified Files: analyse.nice rewrite.nice tools.nice typecheck.nice Log Message: Removed usage of old pattern syntax. Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** tools.nice 28 Jul 2004 14:40:33 -0000 1.36 --- tools.nice 29 Jul 2004 12:11:40 -0000 1.37 *************** *** 22,28 **** ?LocatedString identString(?Expression); identString(e) = null; ! identString(e@IdentExp) = e.ident; ! identString(e@SymbolExp) = e.getName(); ! identString(e@OverloadedSymbolExp) = e.ident; boolean isCallTo(CallExp e, String name) --- 22,28 ---- ?LocatedString identString(?Expression); identString(e) = null; ! identString(IdentExp e) = e.ident; ! identString(SymbolExp e) = e.getName(); ! identString(OverloadedSymbolExp e) = e.ident; boolean isCallTo(CallExp e, String name) *************** *** 36,45 **** boolean isNullExp(Expression); ! isNullExp(e@Expression) = false; ! isNullExp(e@NullExp) = true; ?MonoSymbol localVariable(Expression); ! localVariable(e@Expression) = null; ! localVariable(e@SymbolExp) { let sym = e.getSymbol(); --- 36,45 ---- boolean isNullExp(Expression); ! isNullExp(Expression e) = false; ! isNullExp(NullExp e) = true; ?MonoSymbol localVariable(Expression); ! localVariable(Expression e) = null; ! localVariable(SymbolExp e) { let sym = e.getSymbol(); *************** *** 58,62 **** return null; } ! localVariable(e@AssignExp) = localVariable(notNull(e.to)); mlsub.typing.Monotype makeSure(mlsub.typing.Monotype m) = --- 58,62 ---- return null; } ! localVariable(AssignExp e) = localVariable(notNull(e.to)); mlsub.typing.Monotype makeSure(mlsub.typing.Monotype m) = Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** analyse.nice 28 Jul 2004 20:48:27 -0000 1.105 --- analyse.nice 29 Jul 2004 12:11:40 -0000 1.106 *************** *** 39,43 **** } ! analyse(s@Statement, varScope, typeScope, mustReturnAValue) { Info info = buildInfo(varScope, typeScope); --- 39,43 ---- } ! analyse(Statement s, varScope, typeScope, mustReturnAValue) { Info info = buildInfo(varScope, typeScope); *************** *** 51,55 **** } ! analyse(e@Expression, varScope, typeScope) = analyse(e, buildInfo(varScope, typeScope)); --- 51,55 ---- } ! analyse(Expression e, varScope, typeScope) = analyse(e, buildInfo(varScope, typeScope)); *************** *** 237,241 **** ****************************************************************/ ! analyse(e@Expression, i) = e; void setInitialized (Block.LocalVariable.Symbol v, Info info, --- 237,241 ---- ****************************************************************/ ! analyse(Expression e, i) = e; void setInitialized (Block.LocalVariable.Symbol v, Info info, *************** *** 256,261 **** Expression analyseAssigned(?Expression, Info); analyseAssigned(e, i) = notNull(analyse(e, i)); ! analyseAssigned(e@IdentExp, info) = analyseIdent(e, info, true); ! analyseAssigned(e@TupleExp, info) { Expression[] es = notNull(e.expressions); --- 256,261 ---- Expression analyseAssigned(?Expression, Info); analyseAssigned(e, i) = notNull(analyse(e, i)); ! analyseAssigned(IdentExp e, info) = analyseIdent(e, info, true); ! analyseAssigned(TupleExp e, info) { Expression[] es = notNull(e.expressions); *************** *** 266,270 **** } ! analyse(e@AssignExp, i) { e.value = analyse(e.value, i); --- 266,270 ---- } ! analyse(AssignExp e, i) { e.value = analyse(e.value, i); *************** *** 287,291 **** void markAsCallFun(Expression, boolean); markAsCallFun(e, infix) {} ! markAsCallFun(e@IdentExp, infix) { if (infix) e.setInfix(); --- 287,291 ---- void markAsCallFun(Expression, boolean); markAsCallFun(e, infix) {} ! markAsCallFun(IdentExp e, infix) { if (infix) e.setInfix(); *************** *** 295,304 **** void markAsCallFirstArg(Expression); markAsCallFirstArg(e) {} ! markAsCallFirstArg(e@IdentExp) { e.enableClassExp = true; } ! analyse(e@ExpLocalVariable, info) { e.initValue = analyse(e.initValue, info); --- 295,304 ---- void markAsCallFirstArg(Expression); markAsCallFirstArg(e) {} ! markAsCallFirstArg(IdentExp e) { e.enableClassExp = true; } ! analyse(ExpLocalVariable e, info) { e.initValue = analyse(e.initValue, info); *************** *** 307,311 **** } ! analyse(e@CallExp, info) { Arguments args = e.arguments; --- 307,311 ---- } ! analyse(CallExp e, info) { Arguments args = e.arguments; *************** *** 418,424 **** analyse(e, info); ! analyse(e@FunExp, info) = analyse(e, info, false); ! analyse(e@FunExp, info@Info, noEscape) { let savedDepth = info.anonFunDepth; --- 418,424 ---- analyse(e, info); ! analyse(FunExp e, info) = analyse(e, info, false); ! analyse(FunExp e, Info info, noEscape) { let savedDepth = info.anonFunDepth; *************** *** 454,458 **** } ! analyse(e@IdentExp, info) = analyseIdent(e, info, false); Expression analyseIdent(IdentExp e, Info info, boolean assigned) --- 454,458 ---- } ! analyse(IdentExp e, info) = analyseIdent(e, info, false); Expression analyseIdent(IdentExp e, Info info, boolean assigned) *************** *** 541,545 **** } ! analyse(e@IfExp, info) { e.condition = analyse(e.condition, info); --- 541,545 ---- } ! analyse(IfExp e, info) { e.condition = analyse(e.condition, info); *************** *** 558,562 **** } ! analyse(e@IncrementExp, info) { e.variable = analyse(e.variable, info); --- 558,562 ---- } ! analyse(IncrementExp e, info) { e.variable = analyse(e.variable, info); *************** *** 564,568 **** } ! analyse(e@LiteralArrayExp, info) { analyseExps(cast(e.elements), info); --- 564,568 ---- } ! analyse(LiteralArrayExp e, info) { analyseExps(cast(e.elements), info); *************** *** 570,574 **** } ! analyse(e@NewArrayExp, info) { e.resolveTC(info.typeMap); --- 570,574 ---- } ! analyse(NewArrayExp e, info) { e.resolveTC(info.typeMap); *************** *** 577,581 **** } ! analyse(e@NewExp, info) { e.arguments.analyse(info, noEscape: false); --- 577,581 ---- } ! analyse(NewExp e, info) { e.arguments.analyse(info, noEscape: false); *************** *** 584,588 **** } ! analyse(e@StatementExp, info) { analyse(e.statement, info); --- 584,588 ---- } ! analyse(StatementExp e, info) { analyse(e.statement, info); *************** *** 590,596 **** } ! analyse(e@NullExp, i) = e; ! analyse(c@ConstantExp, info) { if (c.type != null) --- 590,596 ---- } ! analyse(NullExp e, i) = e; ! analyse(ConstantExp c, info) { if (c.type != null) *************** *** 613,617 **** } ! analyse(e@TypeConstantExp, info) { LocatedString name = cast(e.value); --- 613,617 ---- } ! analyse(TypeConstantExp e, info) { LocatedString name = cast(e.value); *************** *** 634,638 **** } ! analyse(e@TupleExp, info) { analyseExps(cast(notNull(e.expressions)), info); --- 634,638 ---- } ! analyse(TupleExp e, info) { analyseExps(cast(notNull(e.expressions)), info); *************** *** 641,645 **** ! analyse(e@SuperExp, info) { e.resolveTC(info.outerTypeScope); --- 641,645 ---- ! analyse(SuperExp e, info) { e.resolveTC(info.outerTypeScope); *************** *** 650,657 **** ****************************************************************/ ! analyse(s@Statement, info) {} analyse(null(Statement), info) {} ! analyse(decl@Block.LocalVariable, info) { if (decl.value != null) --- 650,657 ---- ****************************************************************/ ! analyse(Statement s, info) {} analyse(null(Statement), info) {} ! analyse(Block.LocalVariable decl, info) { if (decl.value != null) *************** *** 666,670 **** } ! analyse(decl@Block.LocalConstant, info) { decl.value = analyse(decl.value, info); --- 666,670 ---- } ! analyse(Block.LocalConstant decl, info) { decl.value = analyse(decl.value, info); *************** *** 672,676 **** } ! analyse(decl@Block.LocalFunction, info) { notNull(decl.parameters).resolveCalledFromAnalyse(cast(info)); --- 672,676 ---- } ! analyse(Block.LocalFunction decl, info) { notNull(decl.parameters).resolveCalledFromAnalyse(cast(info)); *************** *** 680,684 **** } ! analyse(b@Block, info) { info.begin(); --- 680,684 ---- } ! analyse(Block b, info) { info.begin(); *************** *** 703,707 **** } ! analyse(s@ExpressionStmt, info) { s.exp = analyse(s.exp, info); --- 703,707 ---- } ! analyse(ExpressionStmt s, info) { s.exp = analyse(s.exp, info); *************** *** 712,716 **** ****************************************************************/ ! analyse(l@LoopStmt, info) { // If the test comes before the body, then the body might not execute --- 712,716 ---- ****************************************************************/ ! analyse(LoopStmt l, info) { // If the test comes before the body, then the body might not execute *************** *** 754,758 **** } ! analyse(b@BreakStmt, info) { ?LoopStmt loop = info.currentLoop; --- 754,758 ---- } ! analyse(BreakStmt b, info) { ?LoopStmt loop = info.currentLoop; *************** *** 764,768 **** } ! analyse(s@LabeledStmt, info) { mustNotFindLabel(notNull(s.getLabel()), info); --- 764,768 ---- } ! analyse(LabeledStmt s, info) { mustNotFindLabel(notNull(s.getLabel()), info); *************** *** 797,801 **** } ! analyse(b@BreakLabelStmt, info) { LabeledStmt target = b.statement = mustFindLabel(notNull(b.label), info); --- 797,801 ---- } ! analyse(BreakLabelStmt b, info) { LabeledStmt target = b.statement = mustFindLabel(notNull(b.label), info); *************** *** 816,820 **** } ! analyse(c@ContinueStmt, info) { if (c.label == null) --- 816,820 ---- } ! analyse(ContinueStmt c, info) { if (c.label == null) *************** *** 834,838 **** } ! analyse(r@ReturnStmt, info) { r.value = analyse(r.value, info); --- 834,838 ---- } ! analyse(ReturnStmt r, info) { r.value = analyse(r.value, info); *************** *** 840,849 **** } ! analyse(r@VoidReturnStmt, info) { info.setUnreachable(); } ! analyse(t@TryStmt, info) { info.beginCases(); --- 840,849 ---- } ! analyse(VoidReturnStmt r, info) { info.setUnreachable(); } ! analyse(TryStmt t, info) { info.beginCases(); *************** *** 877,881 **** } ! analyse(s@SynchronizedStmt, info) { s.object = analyse(s.object, info); --- 877,881 ---- } ! analyse(SynchronizedStmt s, info) { s.object = analyse(s.object, info); Index: rewrite.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/rewrite.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rewrite.nice 28 Jul 2004 14:40:33 -0000 1.4 --- rewrite.nice 29 Jul 2004 12:11:40 -0000 1.5 *************** *** 33,38 **** Statement rewrite(Statement); ! rewrite(s@Statement) = s; ! rewrite(s@Block) { s.statements = rewrite(s.statements); --- 33,38 ---- Statement rewrite(Statement); ! rewrite(Statement s) = s; ! rewrite(Block s) { s.statements = rewrite(s.statements); *************** *** 67,71 **** ?IfExp ifExp(?Statement); ifExp(s) = null; ! ifExp(s@ExpressionStmt) { if (s.exp instanceof bossa.syntax.IfExp) --- 67,71 ---- ?IfExp ifExp(?Statement); ifExp(s) = null; ! ifExp(ExpressionStmt s) { if (s.exp instanceof bossa.syntax.IfExp) *************** *** 76,81 **** Statement makeStatement(Expression); ! makeStatement(e@Expression) = new ExpressionStmt(e); ! makeStatement(e@StatementExp) = e.statement; Block makeBlock(Expression first, ?Statement[] rest) --- 76,81 ---- Statement makeStatement(Expression); ! makeStatement(Expression e) = new ExpressionStmt(e); ! makeStatement(StatementExp e) = e.statement; Block makeBlock(Expression first, ?Statement[] rest) Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** typecheck.nice 28 Jul 2004 20:48:28 -0000 1.103 --- typecheck.nice 29 Jul 2004 12:11:40 -0000 1.104 *************** *** 30,34 **** typecheck(null(Expression)) {} ! typecheck(e@AssignExp) { Expression to = notNull(notNull(e.to).noOverloading()); --- 30,34 ---- typecheck(null(Expression)) {} ! typecheck(AssignExp e) { Expression to = notNull(notNull(e.to).noOverloading()); *************** *** 191,195 **** } ! typecheck(e@CallExp) { typecheck(e.function); --- 191,195 ---- } ! typecheck(CallExp e) { typecheck(e.function); *************** *** 230,234 **** } ! typecheck(e@FunExp) { ?Function saved = Node.getCurrentFunction(); --- 230,234 ---- } ! typecheck(FunExp e) { ?Function saved = Node.getCurrentFunction(); *************** *** 247,251 **** } ! typecheck(e@IdentExp) { throw new Error("typecheck in IdentExp"); --- 247,251 ---- } ! typecheck(IdentExp e) { throw new Error("typecheck in IdentExp"); *************** *** 262,266 **** (?List<MonoSymbol>, ?List<MonoSymbol>) nullnessInfo(Expression test); nullnessInfo(test) = (null, null); ! nullnessInfo(test@CallExp) { if (test.isCallTo("||")) --- 262,266 ---- (?List<MonoSymbol>, ?List<MonoSymbol>) nullnessInfo(Expression test); nullnessInfo(test) = (null, null); ! nullnessInfo(CallExp test) { if (test.isCallTo("||")) *************** *** 346,350 **** (?List<(MonoSymbol, mlsub.typing.Monotype)>, ?List<(MonoSymbol, mlsub.typing.Monotype)>) instanceofInfo(Expression test); instanceofInfo(test) = (null, null); ! instanceofInfo(test@CallExp) { if (test.isCallTo("||")) --- 346,350 ---- (?List<(MonoSymbol, mlsub.typing.Monotype)>, ?List<(MonoSymbol, mlsub.typing.Monotype)>) instanceofInfo(Expression test); instanceofInfo(test) = (null, null); ! instanceofInfo(CallExp test) { if (test.isCallTo("||")) *************** *** 496,500 **** } ! typecheck(e@IfExp) { Expression condition = notNull(e.condition); --- 496,500 ---- } ! typecheck(IfExp e) { Expression condition = notNull(e.condition); *************** *** 597,601 **** } ! typecheck(e@IncrementExp) { try{ --- 597,601 ---- } ! typecheck(IncrementExp e) { try{ *************** *** 612,621 **** } ! typecheck(e@LiteralArrayExp) { typecheckExps(cast(e.elements)); } ! typecheck(e@NewArrayExp) { Expression[] knownDimensions = notNull(e.knownDimensions); --- 612,621 ---- } ! typecheck(LiteralArrayExp e) { typecheckExps(cast(e.elements)); } ! typecheck(NewArrayExp e) { Expression[] knownDimensions = notNull(e.knownDimensions); *************** *** 635,639 **** } ! typecheck(e@NewExp) { e.arguments.typecheckArgs(); --- 635,639 ---- } ! typecheck(NewExp e) { e.arguments.typecheckArgs(); *************** *** 642,646 **** } ! typecheck(e@StatementExp) { e.statement = rewrite(e.statement); --- 642,646 ---- } ! typecheck(StatementExp e) { e.statement = rewrite(e.statement); *************** *** 649,658 **** } ! typecheck(e@TupleExp) { typecheckExps(cast(notNull(e.expressions))); } ! typecheck(e@SuperExp) { if (Node.currentFunction instanceof MethodBodyDefinition) --- 649,658 ---- } ! typecheck(TupleExp e) { typecheckExps(cast(notNull(e.expressions))); } ! typecheck(SuperExp e) { if (Node.currentFunction instanceof MethodBodyDefinition) *************** *** 664,668 **** } ! typecheck(e@ExpLocalVariable) { Block.LocalVariable decl = notNull(e.variable); --- 664,668 ---- } ! typecheck(ExpLocalVariable e) { Block.LocalVariable decl = notNull(e.variable); *************** *** 703,711 **** } ! typecheck(c@ConstantExp){} ! typecheck(e@NullExp) {} ! typecheck(e@OverloadedSymbolExp) {} ! typecheck(e@PackageExp) {} ! typecheck(e@SymbolExp) {} /**************************************************************** --- 703,711 ---- } ! typecheck(ConstantExp c){} ! typecheck(NullExp e) {} ! typecheck(OverloadedSymbolExp e) {} ! typecheck(PackageExp e) {} ! typecheck(SymbolExp e) {} /**************************************************************** *************** *** 715,719 **** typecheck(null(Statement)) {} ! typecheck(b@Block) { b.statements = rewrite(b.statements); --- 715,719 ---- typecheck(null(Statement)) {} ! typecheck(Block b) { b.statements = rewrite(b.statements); *************** *** 728,732 **** } ! typecheck(decl@Block.LocalVariable) { MonoSymbol target = notNull(decl.left()); --- 728,732 ---- } ! typecheck(Block.LocalVariable decl) { MonoSymbol target = notNull(decl.left()); *************** *** 771,775 **** } ! typecheck(decl@Block.LocalConstant) { if (! notNull(decl.left).used) --- 771,775 ---- } ! typecheck(Block.LocalConstant decl) { if (! notNull(decl.left).used) *************** *** 787,791 **** } ! typecheck(decl@Block.LocalFunction) { typecheck(decl.value); --- 787,791 ---- } ! typecheck(Block.LocalFunction decl) { typecheck(decl.value); *************** *** 801,805 **** } ! typecheck(s@ExpressionStmt) { s.exp = notNull(s.exp).noOverloading(); --- 801,805 ---- } ! typecheck(ExpressionStmt s) { s.exp = notNull(s.exp).noOverloading(); *************** *** 807,811 **** } ! typecheck(l@LoopStmt) { ?Expression whileExp = l.whileExp; --- 807,811 ---- } ! typecheck(LoopStmt l) { ?Expression whileExp = l.whileExp; *************** *** 848,861 **** } ! typecheck(b@BreakStmt) {} ! typecheck(b@BreakLabelStmt) {} ! typecheck(c@ContinueStmt) {} ! typecheck(s@LabeledStmt) { typecheck(s.getStatement()); } ! typecheck(r@ReturnStmt) { ?Function function = Node.currentFunction; --- 848,861 ---- } ! typecheck(BreakStmt b) {} ! typecheck(BreakLabelStmt b) {} ! typecheck(ContinueStmt c) {} ! typecheck(LabeledStmt s) { typecheck(s.getStatement()); } ! typecheck(ReturnStmt r) { ?Function function = Node.currentFunction; *************** *** 892,896 **** } ! typecheck(r@VoidReturnStmt) { ?Function function = Node.currentFunction; --- 892,896 ---- } ! typecheck(VoidReturnStmt r) { ?Function function = Node.currentFunction; *************** *** 914,918 **** ! typecheck(t@TryStmt) { typecheck(t.body); --- 914,918 ---- ! typecheck(TryStmt t) { typecheck(t.body); *************** *** 921,925 **** } ! typecheck(s@SynchronizedStmt) { s.object = notNull(s.object).noOverloading(); --- 921,925 ---- } ! typecheck(SynchronizedStmt s) { s.object = notNull(s.object).noOverloading(); *************** *** 967,973 **** } ! boolean isNullError(TypingEx ex); ! isNullError(@TypingEx) = false; ! isNullError(ex@MonotypeLeqEx) { /* --- 967,972 ---- } ! boolean isNullError(TypingEx ex) = false; ! isNullError(MonotypeLeqEx ex) { /* |
From: Arjan B. <ar...@us...> - 2004-07-29 12:11:52
|
Update of /cvsroot/nice/Nice/src/nice/tools/ast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23653/F:/nice/src/nice/tools/ast Modified Files: SymbolTable.nice Log Message: Removed usage of old pattern syntax. Index: SymbolTable.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/ast/SymbolTable.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SymbolTable.nice 4 May 2003 16:49:38 -0000 1.7 --- SymbolTable.nice 29 Jul 2004 12:11:40 -0000 1.8 *************** *** 48,52 **** symbolTable() = new SymbolTable(); ! <Sym> get(t@SymbolTable, name) { ?Binder<!Sym> binder = t.symbols.get(name); --- 48,52 ---- symbolTable() = new SymbolTable(); ! <Sym> get(SymbolTable t, name) { ?Binder<!Sym> binder = t.symbols.get(name); *************** *** 57,61 **** } ! <Sym> set(t@SymbolTable, name, sym) { Binder<Sym> binder = new Binder(value: sym, name: name, --- 57,61 ---- } ! <Sym> set(SymbolTable t, name, sym) { Binder<Sym> binder = new Binder(value: sym, name: name, *************** *** 66,70 **** } ! <Sym> begin(t@SymbolTable) { Binder<Sym> mark = new Binder(value: cast(null), name: null, nextBinder: t.topBinder, oldBinding: t.marks); --- 66,70 ---- } ! <Sym> begin(SymbolTable t) { Binder<Sym> mark = new Binder(value: cast(null), name: null, nextBinder: t.topBinder, oldBinding: t.marks); *************** *** 73,77 **** } ! <Sym> end(t@SymbolTable) { ?Binder<Sym> top = t.topBinder; --- 73,77 ---- } ! <Sym> end(SymbolTable t) { ?Binder<Sym> top = t.topBinder; |
From: Arjan B. <ar...@us...> - 2004-07-28 21:23:49
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31507/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Added warnings for using the old pattern syntax. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.249 retrieving revision 1.250 diff -C2 -d -r1.249 -r1.250 *** Parser.jj 28 Jul 2004 14:40:34 -0000 1.249 --- Parser.jj 28 Jul 2004 21:23:39 -0000 1.250 *************** *** 1291,1303 **** val=patternLiteral() { loc = val.location(); } | ! "@" tc=typeIdent() { loc = tc.location(); } | name=ident() ( ! "@" tc=typeIdent() [ ":" runtimeTC=typeConstructor() ] | ! "#" tc=typeIdent() { exactlyAt = true; } | ( ">" {kind = Pattern.GT;} --- 1291,1309 ---- val=patternLiteral() { loc = val.location(); } | ! "@" tc=typeIdent() ! { loc = tc.location(); ! User.warning(loc, "This syntax is deprecated, use 'Type paramName' instead."); ! } | name=ident() ( ! "@" { User.warning(name.location(), "This syntax is deprecated, use 'Type paramName' instead."); } tc=typeIdent() [ ":" runtimeTC=typeConstructor() ] | ! "#" tc=typeIdent() ! { exactlyAt = true; ! User.warning(name.location(), "This syntax is deprecated, use '#Type paramName' instead."); ! } | ( ">" {kind = Pattern.GT;} |
From: Arjan B. <ar...@us...> - 2004-07-28 20:48:39
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24781/F:/nice/src/bossa/syntax Modified Files: analyse.nice funexp.nice return.nice typecheck.nice Log Message: Split up of ReturnStmt in ReturnStmt and VoidReturnStmt. Index: return.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/return.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** return.nice 28 Jul 2004 14:40:33 -0000 1.1 --- return.nice 28 Jul 2004 20:48:28 -0000 1.2 *************** *** 21,51 **** public class ReturnStmt extends Statement { ! ?Expression value; boolean fake = false; mlsub.typing.Polytype returnType() { ! if (value == null) ! return notNull(PrimitiveType.voidPolytype); ! ! return notNull(value).getType(); } generateCode() { ! if (value == null) ! return notNull(nice.tools.code.Gen.returnVoid()); ! ! return nice.tools.code.Gen.returnValue(notNull(value).generateCode()); } toString() { ! return "return" + (value!=null ? " " + notNull(value) : "") + ";"; } } ! public Statement createReturnStmt(Expression value) { return createReturnStmt(value, false); --- 21,63 ---- public class ReturnStmt extends Statement { ! Expression value; boolean fake = false; mlsub.typing.Polytype returnType() { ! return value.getType(); } generateCode() { ! return nice.tools.code.Gen.returnValue(value.generateCode()); } toString() { ! return "return " + value + ";"; ! } ! } ! ! public class VoidReturnStmt extends Statement ! { ! ! mlsub.typing.Polytype returnType() ! { ! return notNull(PrimitiveType.voidPolytype); ! } ! ! generateCode() ! { ! return notNull(nice.tools.code.Gen.returnVoid()); } + toString() + { + return "return;"; + } } ! public Statement createReturnStmt(?Expression value) { return createReturnStmt(value, false); *************** *** 56,65 **** of syntactic sugar. */ ! public Statement createReturnStmt(Expression value, boolean fake) { ! let res = new ReturnStmt(value: value, fake: fake); ! if (value != null) ! res.setLocation(value.location()); return res; } --- 68,78 ---- 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; } Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** analyse.nice 28 Jul 2004 14:40:33 -0000 1.104 --- analyse.nice 28 Jul 2004 20:48:27 -0000 1.105 *************** *** 840,843 **** --- 840,848 ---- } + analyse(r@VoidReturnStmt, info) + { + info.setUnreachable(); + } + analyse(t@TryStmt, info) { Index: funexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/funexp.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** funexp.nice 28 Jul 2004 14:40:33 -0000 1.1 --- funexp.nice 28 Jul 2004 20:48:28 -0000 1.2 *************** *** 112,116 **** { let ReturnStmt rs = cast(body); ! bodyValue = notNull(rs.value).toString(); } else --- 112,116 ---- { let ReturnStmt rs = cast(body); ! bodyValue = rs.value.toString(); } else Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** typecheck.nice 28 Jul 2004 14:40:33 -0000 1.102 --- typecheck.nice 28 Jul 2004 20:48:28 -0000 1.103 *************** *** 864,883 **** ?mlsub.typing.Monotype expectedType = function.getExpectedType(); ! if (r.value != null) { ! if (expectedType == null) ! r.value = notNull(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 = notNull(r.value).resolveOverloading (new mlsub.typing.Polytype(expectedType)); - } - - try { typecheck(r.value); } - catch (bossa.util.UserError ex) { throw ensureLocated(ex, r); } } try{ --- 864,880 ---- ?mlsub.typing.Monotype expectedType = function.getExpectedType(); ! if (expectedType == null) ! r.value = notNull(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 = notNull(r.value).resolveOverloading (new mlsub.typing.Polytype(expectedType)); } + + try { typecheck(r.value); } + catch (bossa.util.UserError ex) { throw ensureLocated(ex, r); } try{ *************** *** 895,898 **** --- 892,917 ---- } + typecheck(r@VoidReturnStmt) + { + ?Function function = Node.currentFunction; + if (function == null) + throw bossa.util.User.error(r, "This return is not inside a function"); + + ?mlsub.typing.Monotype expectedType = function.getExpectedType(); + + try{ + if (! (expectedType != null && nice.tools.typing.Types.isVoid(expectedType))) + function.checkReturnedType(r.returnType()); + } + catch(Function.WrongReturnType e){ + wrongReturnType(r, notNull(r.returnType()).toString(), + valueOf(e.expectedReturnType), notNull(e.typingException)); + } + catch(Function.IncompatibleReturnType e){ + throw bossa.util.User.error(r, "The returned value is incompatible with the return type: " + e.previouslyInferredType); + } + } + + typecheck(t@TryStmt) { |
From: Daniel B. <bo...@us...> - 2004-07-28 15:58:34
|
Update of /cvsroot/nice/Nice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3233 Modified Files: Makefile Log Message: Explicitely build gnu.expr.LoopExp, to fix the build after the Nice migration. Index: Makefile =================================================================== RCS file: /cvsroot/nice/Nice/Makefile,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** Makefile 2 Jul 2004 19:31:03 -0000 1.148 --- Makefile 28 Jul 2004 15:58:25 -0000 1.149 *************** *** 164,167 **** --- 164,168 ---- ${JAVAC} \ src/bossa/syntax/dispatch.java \ + src/gnu/expr/LoopExp.java \ stdlib/nice/lang/{Native,rawArray}.java \ src/bossa/modules/{Package,CompilationListener}.java \ |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25490/F:/nice/src/bossa/syntax Removed Files: BreakLabelStmt.java BreakStmt.java ContinueStmt.java FunExp.java IfExp.java IncrementExp.java LabeledStmt.java LiteralArrayExp.java LoopStmt.java NewArrayExp.java OverloadedSymbolExp.java ReturnStmt.java StatementExp.java SynchronizedStmt.java TryStmt.java TupleExp.java Log Message: Conversion of some expression and statement classes in bossa.syntax to nice code. --- ReturnStmt.java DELETED --- --- SynchronizedStmt.java DELETED --- --- LiteralArrayExp.java DELETED --- --- BreakStmt.java DELETED --- --- TupleExp.java DELETED --- --- LoopStmt.java DELETED --- --- TryStmt.java DELETED --- --- StatementExp.java DELETED --- --- NewArrayExp.java DELETED --- --- OverloadedSymbolExp.java DELETED --- --- LabeledStmt.java DELETED --- --- ContinueStmt.java DELETED --- --- FunExp.java DELETED --- --- IncrementExp.java DELETED --- --- BreakLabelStmt.java DELETED --- --- IfExp.java DELETED --- |
From: Arjan B. <ar...@us...> - 2004-07-28 14:48:37
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24346/F:/nice/src/bossa/syntax Removed Files: AssignExp.java Log Message: Conversion of some expression and statement classes in bossa.syntax to nice code. --- AssignExp.java DELETED --- |
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22973/F:/nice/src/bossa/syntax Modified Files: analyse.nice rewrite.nice tools.nice typecheck.nice Block.java CallExp.java CustomConstructor.java EnumDefinition.java Expression.java MethodBodyDefinition.java NewExp.java dispatch.java.bootstrap Added Files: assign.nice break.nice funexp.nice if.nice increment.nice literalarray.nice loop.nice newarray.nice overloadedsymbol.nice return.nice statementexp.nice synchronized.nice try.nice tuple.nice NiceUtils.java Log Message: Conversion of some expression and statement classes in bossa.syntax to nice code. Index: CustomConstructor.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CustomConstructor.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CustomConstructor.java 30 Jun 2004 14:12:37 -0000 1.15 --- CustomConstructor.java 28 Jul 2004 14:40:33 -0000 1.16 *************** *** 175,179 **** Location loc = ident.location(); ! call.function = new OverloadedSymbolExp (classe.getConstructorCallSymbols(), FormalParameters.thisName); call.function.setLocation(loc); --- 175,179 ---- Location loc = ident.location(); ! call.function = bossa.syntax.dispatch.createOverloadedSymbolExp (classe.getConstructorCallSymbols(), FormalParameters.thisName); call.function.setLocation(loc); Index: NewExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NewExp.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** NewExp.java 21 Dec 2003 02:50:55 -0000 1.38 --- NewExp.java 28 Jul 2004 14:40:33 -0000 1.39 *************** *** 80,84 **** constructors = (LinkedList) constructors.clone(); ! function = new OverloadedSymbolExp (constructors, new LocatedString("new " + tc, location())); } --- 80,84 ---- constructors = (LinkedList) constructors.clone(); ! function = bossa.syntax.dispatch.createOverloadedSymbolExp (constructors, new LocatedString("new " + tc, location())); } --- NEW FILE: funexp.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** A functional abstraction expression. */ public class FunExp extends Expression implements Function { final MonoSymbol[] formals; ?bossa.syntax.Constraint constraint; final Statement body; ?mlsub.typing.Constraint cst = null; boolean mightEscape = true; private boolean alwaysReturns = false; private ?mlsub.typing.Polytype _inferredReturnType = null; getExpectedType() { return cast(null); } checkReturnedType(returned) { if (_inferredReturnType == null) _inferredReturnType = returned; else { mlsub.typing.Polytype old = notNull(_inferredReturnType); _inferredReturnType = mlsub.typing.Polytype.union(_inferredReturnType, returned); if (! notNull(_inferredReturnType).trySimplify()) throw new Function.IncompatibleReturnType(old); } /* This is disabled, since currently default values of class fields are typechecked twice. if (type != null) Internal.error("Return statement discovered after computation of the type"); */ } void setAlwaysReturns(boolean value) { alwaysReturns = value; } computeType() { if (_inferredReturnType == null) // There is not return statement in the function. { if (alwaysReturns) /* This function never returns normally since there was no inferredReturnType, so it always throws an exception. Therefore, it can be considered to return any type. */ _inferredReturnType = mlsub.typing.Polytype.bottom(); else _inferredReturnType = PrimitiveType.voidPolytype; } else if (! alwaysReturns && ! nice.tools.typing.Types.isVoid(_inferredReturnType)) throw User.error(this, "Missing return statement"); mlsub.typing.Monotype t = new mlsub.typing.FunType(MonoSymbol.getMonotype(formals), notNull(_inferredReturnType).getMonotype()); type = new mlsub.typing.Polytype (mlsub.typing.Constraint.and(cst, notNull(_inferredReturnType).getConstraint()), bossa.syntax.Monotype.sure(t)); } inferredReturnType() { this.getType(); return notNull(_inferredReturnType); } /**************************************************************** * Code generation ****************************************************************/ compile() { gnu.expr.LambdaExp res = nice.tools.code.Gen.createMethod (null, nice.tools.code.Types.javaType(MonoSymbol.getMonotype(formals)), nice.tools.code.Types.javaType(this.inferredReturnType()), formals, false); nice.tools.code.Gen.setMethodBody(res, body.generateCode()); return res; } toString() { String bodyValue; if (body instanceof ReturnStmt) { let ReturnStmt rs = cast(body); bodyValue = notNull(rs.value).toString(); } else bodyValue = body.toString(); return (constraint == null ? mlsub.typing.Constraint.toString(cst) : notNull(constraint).toString()) + "(" + Util.map("",", ","",formals) + ") => " + bodyValue ; } } public Expression createFunExp(bossa.syntax.Constraint cst, List<MonoSymbol> formals, Statement body) { return new FunExp(constraint: cst, formals: formals.toArray(), body: body); } override Expression createFunExp(bossa.syntax.Constraint cst, MonoSymbol[] formals, Statement body) { let res = new FunExp(constraint: cst, formals: formals, body: body); res.setLocation(body.location()); return res; } --- NEW FILE: return.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** <tt>return</tt> in a function or method. */ public class ReturnStmt extends Statement { ?Expression value; boolean fake = false; mlsub.typing.Polytype returnType() { if (value == null) return notNull(PrimitiveType.voidPolytype); return notNull(value).getType(); } generateCode() { if (value == null) return notNull(nice.tools.code.Gen.returnVoid()); return nice.tools.code.Gen.returnValue(notNull(value).generateCode()); } toString() { return "return" + (value!=null ? " " + notNull(value) : "") + ";"; } } 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) { let res = new ReturnStmt(value: value, fake: fake); if (value != null) res.setLocation(value.location()); return res; } --- NEW FILE: tuple.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** Creation of a tuple. */ public class TupleExp extends bossa.syntax.Expression { final bossa.syntax.Expression[] expressions; private mlsub.typing.Monotype[?] components = null; private mlsub.typing.Monotype[?] expectedComponents= null; /**************************************************************** * Typing ****************************************************************/ isAssignable() = expressions.all(Expression e => e.isAssignable()); /** Adjust the array type according to the context. This is usefull because arrays are non-variant. For instance, different code must be generated for [ 1, 2 ] in the contexts: int[] i = [ 1, 2 ] and byte[] b = [ 1, 2 ] */ resolveOverloading(mlsub.typing.Polytype expectedType) { // This can only help expectedType.simplify(); this.adjustToExpectedType(expectedType.getMonotype()); return this; } adjustToExpectedType(mlsub.typing.Monotype expectedType) { let m = nice.tools.typing.Types.equivalent(expectedType); // Get the expected component types if (m instanceof mlsub.typing.TupleType) { expectedComponents = (m).getComponents(); // Do the same for the elements of the tuple, since they might be // tuples themselves, literal arrays, ... bossa.syntax.Expression.adjustToExpectedType (expressions, expectedComponents); } } noOverloading() { for(int i = expressions.length; i-->0;) expressions[i] = expressions[i].noOverloading(); return this; } computeType() { let types = bossa.syntax.Expression.getType(expressions); // should create a new <tt>and</tt> method without the last dummy parameters let cst = mlsub.typing.Constraint.and(mlsub.typing.Polytype.getConstraint(types), null, null); components = mlsub.typing.Polytype.getMonotype(types); let tupleType = new mlsub.typing.TupleType(components); nice.tools.code.Types.setBytecodeType(components); if (expectedComponents == null) expectedComponents = components; type = new mlsub.typing.Polytype(cst, bossa.syntax.Monotype.sure(tupleType)); } /**************************************************************** * Code generation ****************************************************************/ compile() { // Force computation of the component types. this.getType(); /* We base the array type on the expected type, but we record the real type of the components. */ return nice.tools.code.TupleType.createExp (nice.tools.code.Types.lowestCommonSupertype(expectedComponents), nice.tools.code.Types.javaType(expectedComponents), bossa.syntax.Expression.compile(expressions)); } compileAssign(gnu.expr.Expression array) { ?gnu.expr.LetExp letExp = null; gnu.expr.Expression tupleExp; let arrayType = array.getType(); ?nice.tools.code.TupleType tupleType = null; if (arrayType instanceof nice.tools.code.TupleType) tupleType = arrayType; // if array is a complex expression, // we have to evaluate it and store the result // to avoid evaluating it several times. if (!(array instanceof gnu.expr.ReferenceExp)) { letExp = new gnu.expr.LetExp([array]); let tupleDecl = notNull(letExp).addDeclaration("tupleRef", arrayType); //FIXME: CanRead should be set automatically. tupleDecl.setCanRead(true); tupleExp = new gnu.expr.ReferenceExp(tupleDecl); } else tupleExp = array; let gnu.expr.Expression[] stmts = fill(new gnu.expr.Expression[expressions.length], int i => { gnu.expr.Expression value = new gnu.expr.ApplyExp(new nice.lang.inline.ArrayGetOp(null), [tupleExp, new gnu.expr.QuoteExp(new Integer(i))]); if (tupleType != null) value = nice.tools.code.EnsureTypeProc.ensure(value, notNull(tupleType.componentTypes)[i]); return expressions[i].compileAssign(value); }); if (letExp != null) { letExp.setBody(new gnu.expr.BeginExp(stmts)); return letExp; } else return new gnu.expr.BeginExp(stmts); } toString() = Util.map("(", ", ", ")", expressions); } public new TupleExp(List<bossa.syntax.Expression> expressions) { this(expressions: toArray(expressions)); } Index: Expression.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Expression.java,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** Expression.java 11 Feb 2004 12:46:39 -0000 1.54 --- Expression.java 28 Jul 2004 14:40:33 -0000 1.55 *************** *** 187,190 **** --- 187,196 ---- return res; } + + Polytype inferredReturnType() + { + Internal.error("inferredReturnType called in " + getClass()); + return null; + } void checkSpecialRequirements(Expression[] arguments) --- NEW FILE: loop.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** General loop statement (used for 'for', 'while do', 'do while' ...) */ public class LoopStmt extends Statement { ?Expression whileExp; final Statement loopBody; final ?Block iterationStatements = null; final boolean testFirst; ?gnu.expr.LoopExp code = null; private boolean mustCreateBlock = false; boolean isTestFirst() = testFirst; /**************************************************************** * Code generation ****************************************************************/ void createBlock() { mustCreateBlock = true; } /** 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() = mustCreateBlock; /** Returns true iff this loop never completes normally. */ boolean isInfinite() { return (whileExp == null || notNull(whileExp).isTrue()) && ! this.isBreakTarget(); } generateCode() { gnu.expr.Expression test, iteration, res; if (whileExp == null) test = notNull(gnu.expr.QuoteExp.trueExp); else test = notNull(whileExp).generateCode(); if (iterationStatements == null) iteration = notNull(gnu.expr.QuoteExp.voidExp); else iteration = notNull(iterationStatements).generateCode(); code = new gnu.expr.LoopExp(test, iteration, testFirst); let savedBlock = currentLoopBlock; if (mustCreateBlock) res = currentLoopBlock = new gnu.expr.BlockExp(code); else res = notNull(code); notNull(code).setBody(loopBody != null ? notNull(loopBody).generateCode() : null); code = null; currentLoopBlock = savedBlock; return res; } /**************************************************************** * Printing ****************************************************************/ toString() { if (!testFirst) return "do {\n" + (loopBody == null ? " " : loopBody.toString()) + "}\n while (" + whileExp + ");"; if (iterationStatements == null) return "while (" + whileExp + ")" + (loopBody == null ? ";" : loopBody.toString()); Statement[] itStatements = cast(notNull(iterationStatements).statements); String itStats = ""; for(int i = 0; i<itStatements.length; i++) { String tmp = itStatements[i].toString(); itStats += tmp.substring(0, tmp.lastIndexOf(';')); if (i<itStatements.length-1) itStats += ", "; } return "for(; " + whileExp + " ;" + itStats + ")\n " + (loopBody == null ? "" : loopBody.toString()); } } public LoopStmt createForLoop (Expression test, Block update, Statement body) { return new LoopStmt(whileExp:test, loopBody: body, iterationStatements: update, testFirst: true); } public LoopStmt createWhileLoop(Expression test, Statement body) { return new LoopStmt(whileExp:test, loopBody: body, testFirst: true); } public LoopStmt createDoLoop(Expression test, Statement body) { return new LoopStmt(whileExp: test, loopBody: body, testFirst: false); } public Statement createForInLoop(?Monotype vartype, LocatedString varName, Location loc, Expression container, Statement body) { ?Monotype itertype = null; if (vartype != null) { List<Monotype> tparams = new ArrayList(1); tparams.add(vartype); itertype = new MonotypeConstructor(new TypeIdent(new LocatedString("Iterator", loc)), new TypeParameters(tparams), loc); notNull(itertype).nullness = Monotype.sure; } let getiter = CallExp.create(new IdentExp(new LocatedString("forIterator", loc)), container); let iter = new LocatedString(loc.uniqueIdentifier("for_in_iter_"), loc); let init = new Block.LocalVariable(iter, itertype, true, getiter); let iterexp = new IdentExp(iter); let cond = CallExp.create(new IdentExp(new LocatedString("hasNext", loc)), iterexp); let getvar = CallExp.create(new IdentExp(new LocatedString("next", loc)), iterexp); let assign = new Block.LocalVariable(varName, vartype, true, getvar); let loop = createWhileLoop(cond, new Block(new LinkedList([assign, body]))); return new Block(new LinkedList([init, loop])); } var ?gnu.expr.BlockExp currentLoopBlock = null; Index: typecheck.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** typecheck.nice 20 Jul 2004 22:37:49 -0000 1.101 --- typecheck.nice 28 Jul 2004 14:40:33 -0000 1.102 *************** *** 614,627 **** typecheck(e@LiteralArrayExp) { ! typecheckExps(notNull(e.elements)); } typecheck(e@NewArrayExp) { ! ?Expression[] knownDimensions = notNull(e.knownDimensions); ! typecheckExps(knownDimensions); for (int i=0; i<knownDimensions.length; i++) { ! Expression dim = notNull(knownDimensions[i]); try{ Typing.leq(dim.getType(), PrimitiveType.intPolytype); --- 614,627 ---- typecheck(e@LiteralArrayExp) { ! typecheckExps(cast(e.elements)); } typecheck(e@NewArrayExp) { ! Expression[] knownDimensions = notNull(e.knownDimensions); ! typecheckExps(cast(knownDimensions)); for (int i=0; i<knownDimensions.length; i++) { ! Expression dim = knownDimensions[i]; try{ Typing.leq(dim.getType(), PrimitiveType.intPolytype); *************** *** 651,655 **** typecheck(e@TupleExp) { ! typecheckExps(notNull(e.expressions)); } --- 651,655 ---- typecheck(e@TupleExp) { ! typecheckExps(cast(notNull(e.expressions))); } *************** *** 898,902 **** { typecheck(t.body); ! t.catches.foreach(TryStmt.Catch c => typecheck(c.body)); typecheck(t.finallyBody); } --- 898,902 ---- { typecheck(t.body); ! t.catches.foreach(ACatch c => typecheck(c.body)); typecheck(t.finallyBody); } --- NEW FILE: statementexp.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** A statement made by the evaluation of an expression. */ public class StatementExp extends Expression { Statement statement; toString() = statement.toString(); compile() { if (statement == null) return notNull(gnu.expr.QuoteExp.voidExp); return new gnu.expr.BeginExp(statement.generateCode(), gnu.expr.QuoteExp.voidExp); } computeType() { type = PrimitiveType.voidPolytype; } } --- NEW FILE: if.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** Conditional expression (used in statements too). */ public class IfExp extends Expression { Expression condition; Expression thenExp; Expression elseExp; /** set to true if the execution of the branch never completes. */ boolean thenUnreachable = false; boolean elseUnreachable = false; computeType() { this.type = mlsub.typing.Polytype.union(thenExp.getType(), elseExp.getType()); } compile() { gnu.expr.Expression thenCode, elseCode; thenCode = thenExp.generateCode(); elseCode = elseExp.generateCode(); if (elseCode.getType() == nice.tools.code.SpecialTypes.voidType) thenCode = voidify(thenCode); else if (thenCode.getType() == nice.tools.code.SpecialTypes.voidType) elseCode = voidify(elseCode); return new gnu.expr.SimpleIfExp(condition.generateCode(), thenCode, elseCode); } toString() { return "if(" + String.valueOf(condition) + ")\n" + String.valueOf(thenExp) + "\nelse\n" + String.valueOf(elseExp) + "\n" ; } } private gnu.expr.Expression voidify(gnu.expr.Expression e) { if (e.getType().isVoid()) return e; return new gnu.expr.BeginExp(e, gnu.expr.QuoteExp.voidExp); } public Statement createIfStmt(Expression cond, Statement thenStmt, ?Statement elseStmt, Location loc) { let ifExp = new IfExp(condition: cond, thenExp: new StatementExp(statement: thenStmt), elseExp: (elseStmt == null ? new VoidConstantExp() : new StatementExp(statement: elseStmt))); ifExp.setLocation(loc); return new ExpressionStmt(ifExp); } --- NEW FILE: literalarray.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** Creates an array containing the given elements. The array type is infered as the minimal possible type. */ public class LiteralArrayExp extends Expression { Expression[] elements; private boolean wrapAsCollection = false; computeType() { let elementType = mlsub.typing.Polytype.union(Expression.getType(elements)); type = this.array(elementType); // If the type cannot be simplified, it must be because elements // have incomparable types. In this case, we give the array the type // Object[]. if (! notNull(type).trySimplify()) type = this.array(PrimitiveType.objectPolytype()); } private mlsub.typing.Polytype array(mlsub.typing.Polytype elementType) { let res = new mlsub.typing.Polytype (elementType.getConstraint(), bossa.syntax.Monotype.sure(new mlsub.typing.MonotypeConstructor (PrimitiveType.arrayTC, [elementType.getMonotype()]))); res.setNotSimplified(); return res; } /** Adjust the array type according to the context. This is usefull because arrays are non-variant. For instance, different code must be generated for [ 1, 2 ] in the contexts: List<int[]> i = [[ 1, 2 ]] and List<List<byte[]>> b = [[ 1, 2 ]] */ resolveOverloading(mlsub.typing.Polytype expectedType) { let elementType = nice.tools.typing.Types.getTypeParameter(expectedType, 0); if (elementType != null) for (elem : elements) elem.adjustToExpectedType(elementType); return this; } adjustToExpectedType(mlsub.typing.Monotype expectedType) { let tc = nice.tools.typing.Types.equivalent(expectedType).head(); // Remember that we will need to wrap the array to make it a collection. // This cannot be found easily during code generation for nested arrays // since the bytecode type of both List<List<T>> and List<T[]> is // simply List. if (tc != PrimitiveType.arrayTC && tc != null && tc.isRigid() && mlsub.typing.Typing.testRigidLeq(tc, PrimitiveType.collectionTC)) { wrapAsCollection = true; } // Adjust nested elements. let elementType = nice.tools.typing.Types.getTypeParameter(expectedType, 0); if (elementType != null) for (elem : elements) elem.adjustToExpectedType(elementType); } compile() { gnu.expr.Expression[] args = Expression.compile(elements); gnu.bytecode.ArrayType t = nice.tools.code.SpecialTypes.array (nice.tools.code.Types.lowestUpperBound(args)); return new gnu.expr.ApplyExp (new nice.tools.code.LiteralArrayProc (t, elements.length, wrapAsCollection), args); } toString() = "[" + Util.map("", ", ", "", elements) + "]"; } public Expression createLiteralArrayExp(?List<Expression> elements) { if (elements == null) return new LiteralArrayExp(elements: new Expression[0]); return new LiteralArrayExp(elements: toArray(elements)); } Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -d -r1.149 -r1.150 *** MethodBodyDefinition.java 28 Feb 2004 14:23:43 -0000 1.149 --- MethodBodyDefinition.java 28 Jul 2004 14:40:33 -0000 1.150 *************** *** 243,247 **** } ! OverloadedSymbolExp.removeNonMinimal(symbols); if(symbols.size() == 1) --- 243,247 ---- } ! bossa.syntax.dispatch.removeNonMinimal(symbols); if(symbols.size() == 1) --- NEW FILE: try.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** A try/catch/finally statement */ public class TryStmt extends Statement { final Statement body; ?Statement finallyBody = null; List<ACatch> catches = new LinkedList(); public void setFinally(Statement body) { finallyBody = body; } public void addCatch(TypeIdent tc, LocatedString varName, Statement body) { this.catches.add(new ACatch(tc, varName, body)); } generateCode() { let res = new gnu.expr.TryExp(body.generateCode(), (finallyBody==null ? null : notNull(finallyBody).generateCode())); ?gnu.expr.CatchClause oldc = null; for (c: this.catches) { gnu.expr.CatchClause newc = c.clause(); if (oldc!=null) oldc.setNext(newc); else res.setCatchClauses(newc); oldc = newc; } return res; } toString() { String res = "try\n" + body; for (c : this.catches) res += "catch (" + c.t + " " + c.varName + ")\n" + c.body; if (finallyBody != null) res += "finally " + finallyBody; return res; } } public class ACatch { final MonoSymbol exnVar; ?TypeIdent tc; ?mlsub.typing.TypeConstructor t = null; private final LocatedString varName; final Statement body; private final Location typeLocation; gnu.expr.CatchClause clause() { try { mlsub.typing.Typing.leq(t, PrimitiveType.throwableTC); } catch (mlsub.typing.TypingEx e) { User.error(typeLocation, notNull(t) + " is not catchable"); } let res = new gnu.expr.CatchClause(varName.toString(), cast(nice.tools.code.Types.javaType(t))); exnVar.setDeclaration(res.getDeclaration()); res.setBody(body.generateCode()); return res; } } public new ACatch(TypeIdent tc, LocatedString varName, Statement body) { Monotype type = new MonotypeConstructor(tc, null, tc.location()); type.nullness = Monotype.sure; this(exnVar: new MonoSymbol(varName, type), tc: tc, typeLocation: tc.location, varName: varName, body: body); } Index: CallExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CallExp.java,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** CallExp.java 23 Jun 2004 19:38:09 -0000 1.94 --- CallExp.java 28 Jul 2004 14:40:33 -0000 1.95 *************** *** 96,100 **** public void addBlockArgument(Statement block, LocatedString name) { ! arguments.add(new FunExp(bossa.syntax.Constraint.True, new LinkedList(), block), name); } --- 96,100 ---- public void addBlockArgument(Statement block, LocatedString name) { ! arguments.add(bossa.syntax.dispatch.createFunExp(bossa.syntax.Constraint.True, new LinkedList(), block), name); } Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** analyse.nice 22 Jul 2004 12:42:54 -0000 1.103 --- analyse.nice 28 Jul 2004 14:40:33 -0000 1.104 *************** *** 259,263 **** analyseAssigned(e@TupleExp, info) { ! Array<?Expression> es = notNull(e.expressions); for (int i = 0; i < es.length; i++) es[i] = es[i].analyseAssigned(info); --- 259,263 ---- analyseAssigned(e@TupleExp, info) { ! Expression[] es = notNull(e.expressions); for (int i = 0; i < es.length; i++) es[i] = es[i].analyseAssigned(info); *************** *** 393,401 **** if (possibilities.has(VarSymbol s => s.isFieldAccess())) { ! e.function = newOverloadedSymbolExp(possibilities, funName); return e; } else ! return newOverloadedSymbolExp(possibilities, funName); } --- 393,401 ---- if (possibilities.has(VarSymbol s => s.isFieldAccess())) { ! e.function = createOverloadedSymbolExp(possibilities, funName); return e; } else ! return createOverloadedSymbolExp(possibilities, funName); } *************** *** 410,414 **** funName); ! e.function = newOverloadedSymbolExp(possibilities, funName); return e; --- 410,414 ---- funName); ! e.function = createOverloadedSymbolExp(possibilities, funName); return e; *************** *** 440,444 **** if (e.formals != null) ! addVars(info, elementsNotNull(notNull(e.formals))); analyse(e.body, info); --- 440,444 ---- if (e.formals != null) ! addVars(info, e.formals); analyse(e.body, info); *************** *** 481,485 **** if (e.alwaysOverloadedSymbol) ! return new OverloadedSymbolExp(sym, e.ident); else return new SymbolExp(sym, e.location()); --- 481,485 ---- if (e.alwaysOverloadedSymbol) ! return createOverloadedSymbolExp(sym, notNull(e.ident)); else return new SymbolExp(sym, e.location()); *************** *** 513,517 **** { CallExp res = new CallExp ! (newOverloadedSymbolExp(symbols, e.ident), new Arguments([new Arguments.Argument(Node.thisExp)])); res.setLocation(e.location()); --- 513,517 ---- { CallExp res = new CallExp ! (createOverloadedSymbolExp(symbols, notNull(e.ident)), new Arguments([new Arguments.Argument(Node.thisExp)])); res.setLocation(e.location()); *************** *** 523,527 **** // Make an implicit call to fetch the static field's value. CallExp res = new CallExp ! (newOverloadedSymbolExp(symbols, e.ident), Arguments.noArguments()); res.setLocation(e.location()); --- 523,527 ---- // Make an implicit call to fetch the static field's value. CallExp res = new CallExp ! (createOverloadedSymbolExp(symbols, notNull(e.ident)), Arguments.noArguments()); res.setLocation(e.location()); *************** *** 532,536 **** } else ! return newOverloadedSymbolExp(symbols, e.ident); } --- 532,536 ---- } else ! return createOverloadedSymbolExp(symbols, notNull(e.ident)); } *************** *** 566,570 **** analyse(e@LiteralArrayExp, info) { ! analyseExps(notNull(e.elements), info); return e; } --- 566,570 ---- analyse(e@LiteralArrayExp, info) { ! analyseExps(cast(e.elements), info); return e; } *************** *** 573,577 **** { e.resolveTC(info.typeMap); ! analyseExps(notNull(e.knownDimensions), info); return e; } --- 573,577 ---- { e.resolveTC(info.typeMap); ! analyseExps(cast(notNull(e.knownDimensions)), info); return e; } *************** *** 636,640 **** analyse(e@TupleExp, info) { ! analyseExps(notNull(e.expressions), info); return e; } --- 636,640 ---- analyse(e@TupleExp, info) { ! analyseExps(cast(notNull(e.expressions)), info); return e; } *************** *** 845,849 **** analyse(t.body, info); ! t.catches.foreach(TryStmt.Catch c =>{ info.otherCase(); info.begin(); --- 845,849 ---- analyse(t.body, info); ! t.catches.foreach(ACatch c =>{ info.otherCase(); info.begin(); Index: dispatch.java.bootstrap =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dispatch.java.bootstrap 18 Feb 2004 11:50:54 -0000 1.12 --- dispatch.java.bootstrap 28 Jul 2004 14:40:33 -0000 1.13 *************** *** 2,5 **** --- 2,6 ---- package bossa.syntax; + import java.util.List; /* This file is only useful to bootstrap the compiler, *************** *** 12,15 **** --- 13,34 ---- public class dispatch { + public static Statement createReturnStmt(Expression value, boolean fake) + { return null; } + + public static Expression createFunExp(bossa.syntax.Constraint cst, List formals, Statement body) + { return null; } + + static Expression createFunExp(bossa.syntax.Constraint cst, MonoSymbol[] formals, Statement body) + { return null; } + + public static Expression createLiteralArrayExp(List exps) + { return null; } + + static Expression createOverloadedSymbolExp(List l, LocatedString s) + { return null; } + + static List removeNonMinimal(List l) + { return null; } + static Statement analyse(Statement s, VarScope v, TypeScope t, boolean r) { return null; } --- NEW FILE: break.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; public class BreakStmt extends Statement { generateCode() = new gnu.expr.ExitExp(currentLoopBlock); toString() = "break;"; } public class BreakLabelStmt extends Statement { final LocatedString label; ?LabeledStmt statement = null; generateCode() = new gnu.expr.ExitExp(notNull(statement).block); toString() = "break " + label + ";"; } public class ContinueStmt extends Statement { final ?LocatedString label; ?LoopStmt loop = null; generateCode() = new gnu.expr.LoopExp.ContinueExp(notNull(loop).code); toString() = "continue " + (label != null ? notNull(label).toString() : "") + ";"; } public Statement createBreakStmt(?LocatedString label) { if (label == null) return new BreakStmt(); else return new BreakLabelStmt(label: label); } public Statement createContinueStmt(LocatedString label) { return new ContinueStmt(label: label); } /** A statement anotated by a label (used by break and continue). */ public class LabeledStmt extends Statement { private final LocatedString label; private final Statement statement; private final ?LoopStmt loop = null; public String name() = label.toString(); public LocatedString getLabel() = label; public Statement getStatement() = statement; /** @return the loop targeted by this label, or null. */ ?LoopStmt getLoop() { if (loop != null) return loop; if (statement instanceof LoopStmt) return cast(statement); return null; } /**************************************************************** * Code generation ****************************************************************/ ?gnu.expr.BlockExp block = null; generateCode() { // if (statement == null) // return notNull(gnu.expr.QuoteExp.voidExp); let res = block = new gnu.expr.BlockExp(); notNull(block).setBody(statement.generateCode()); block = null; return res; } } public new LabeledStmt(LocatedString label, Statement statement, LoopStmt loop) { this(label:label, statement:statement, loop: loop, block: null); } Index: Block.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Block.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** Block.java 25 Feb 2004 11:23:29 -0000 1.66 --- Block.java 28 Jul 2004 14:40:33 -0000 1.67 *************** *** 252,256 **** { Expression value; ! value = new FunExp(Constraint.True, parameters.getMonoSymbols(), body); FunSymbol symbol = new FunSymbol(name, --- 252,256 ---- { Expression value; ! value = bossa.syntax.dispatch.createFunExp(Constraint.True, parameters.getMonoSymbols(), body); FunSymbol symbol = new FunSymbol(name, *************** *** 276,280 **** mlsub.typing.Polytype inferredReturnType() { ! return ((FunExp) value).inferredReturnType(); } --- 276,280 ---- mlsub.typing.Polytype inferredReturnType() { ! return value.inferredReturnType(); } Index: rewrite.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/rewrite.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** rewrite.nice 25 Sep 2002 16:40:25 -0000 1.3 --- rewrite.nice 28 Jul 2004 14:40:33 -0000 1.4 *************** *** 50,54 **** { ifExp.elseExp = new StatementExp ! (rewrite(makeBlock(notNull(ifExp.elseExp), statements.slice(from: i+1)))); return statements.slice(to: i); --- 50,54 ---- { ifExp.elseExp = new StatementExp ! (statement: rewrite(makeBlock(notNull(ifExp.elseExp), statements.slice(from: i+1)))); return statements.slice(to: i); *************** *** 57,61 **** { ifExp.thenExp = new StatementExp ! (rewrite(makeBlock(notNull(ifExp.thenExp), statements.slice(from: i+1)))); return statements.slice(to: i); --- 57,61 ---- { ifExp.thenExp = new StatementExp ! (statement: rewrite(makeBlock(notNull(ifExp.thenExp), statements.slice(from: i+1)))); return statements.slice(to: i); --- NEW FILE: overloadedsymbol.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* 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; import bossa.util.*; /** A symbol, for which overloading resolution has yet to be done. */ public class OverloadedSymbolExp extends Expression { List<VarSymbol> symbols; final LocatedString ident; /** Do not try to add an implicit 'this' access. */ private final boolean noImplicitThis = false; isAssignable() { Internal.error("Overloading resolution should be done before this."); return false; } private Expression uniqueExpression() { return new SymbolExp(symbols.get(0), this.location()); } private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { SymbolExp res = new SymbolExp(sym, this.location()); res.type = t; return res; } resolveOverloading(CallExp callExp) { Arguments arguments = callExp.arguments; // It's better to do this know. OR is oriented, arguments first. arguments.computeTypes(); if (bossa.util.Debug.overloading) bossa.util.Debug.println("Overloading resolution for " + this + "\nwith parameters " + arguments); // FIRST PASS: only checks the number of parameters // remembers removed symbols, // to list possibilities if none matches LinkedList<VarSymbol> removed = new LinkedList(); // Useful in case of failure, to try adding an implicit 'this'. let fieldAccesses = this.filterFieldAccesses(); for(let i = symbols.iterator(); i.hasNext();) { let s = i.next(); if (s.isIgnored()) { removed.add(s); i.remove(); continue; } let case = s.match(arguments); if (case == 0) // Doesn't match { removed.add(s); i.remove(); } else if (case == 1) // Wasn't even a function or method { i.remove(); } else if (case == 2) // Matches { /* do nothing*/ } else // Should not happen { Internal.warning("Unknown O.R. case: " + s.getClass()); i.remove(); } } if (symbols.size() == 0) { if (! noImplicitThis) { let res = this.givePriorityToFields(fieldAccesses); if (res != null) return res; } User.error(this, this.noMatchError(removed, arguments)); } // SECOND PASS: check argument types removed.clear(); for (let i = symbols.iterator(); i.hasNext(); ) { let s = i.next(); if(bossa.util.Debug.overloading) bossa.util.Debug.println("Overloading: Trying with "+s); // we clone the type to avoid clashes with another use // of the same symbol // the cloned type is stored in the VarSymbol // and we check that cloneType() is not called twice // before the clone type is released s.makeClonedType(); mlsub.typing.Polytype[] argsType = this.computeArgsType(arguments.getExpressions(s), s.getClonedType(), arguments.getUsedArguments(s)); ?mlsub.typing.Polytype t = CallExp.wellTyped(s.getClonedType(), argsType); if (t == null) { removed.add(s); i.remove(); s.releaseClonedType(); } else arguments.types.put(s, t); } if (symbols.size() == 0) { if (! noImplicitThis) { let res = this.givePriorityToFields(fieldAccesses); if (res != null) return res; } if (removed.size() == 1) User.error(this, "Arguments " + arguments.printTypes() + " do not fit:\n" + removed[0]); else User.error(this, "No possible call for " + ident + ".\nArguments: " + arguments.printTypes() + "\nPossibilities:\n" + Util.map("", "\n", "", removed.toArray())); } removeNonMinimal(symbols, arguments); removeOverlappingJavaMethods(symbols); if (symbols.size() == 1) { let res = symbols[0]; // store the formal argument types for later use together with the type callExp.setComputedType(arguments.types.get(res), nice.tools.typing.Types.parameters(res.getClonedType())); res.releaseClonedType(); // store the expression (including default arguments) callExp.arguments.computedExpressions = cast(arguments.getExpressions(res)); //callExp.arguments = null; // free memory return this.uniqueExpression(); } this.releaseAllClonedTypes(); throw new AmbiguityError(this); } private mlsub.typing.Polytype[] computeArgsType(Expression[] args, mlsub.typing.Polytype functionType, int[?] usedArguments) { mlsub.typing.Monotype[?] domain = null; /* Where a default value was used, use the declared argument type instead of the value's type. This is more robust, as the application type will not depend on the default value. Furthermore, this avoids running into problems when the default value refers to type parameters (in anonymous functions, by refering to previous arguments, ...) which would not be in sync with the cloned ones. This is only needed when the type is polymorphic. */ mlsub.typing.Polytype[] res = fill(new mlsub.typing.Polytype[args.length], int i => { if (usedArguments != null && usedArguments[i] == 0) { if (domain == null) { mlsub.typing.FunType func = cast(nice.tools.typing.Types.rawType(functionType.getMonotype())); domain = func.domain(); } return new mlsub.typing.Polytype(notNull(domain)[i]); } return args[i].getType(); }); return res; } resolveOverloading(mlsub.typing.Polytype expectedType) { if(bossa.util.Debug.overloading) bossa.util.Debug.println("Overloading resolution (expected type " + expectedType + ") for " + this); // remembers removed symbols, // to list possibilities if none matches LinkedList<VarSymbol> removed = new LinkedList(); // Useful in case of failure. let fieldAccesses = this.filterFieldAccesses(); for (let i = symbols.iterator(); i.hasNext();) { let s = i.next(); s.makeClonedType(); try{ Typing.leq(s.getClonedType(), expectedType); if(bossa.util.Debug.overloading) bossa.util.Debug.println(s + "(" + s.location() + ") of type " + s.getClonedType() + " matches"); } catch(TypingEx e){ removed.add(s); i.remove(); s.releaseClonedType(); if(bossa.util.Debug.overloading) bossa.util.Debug.println("Not "+s+" of type\n" + s.getClonedType() + "\nbecause "+e); } } if (symbols.size() == 1) { let s = symbols[0]; let symType = s.getClonedType(); s.releaseClonedType(); return this.uniqueExpression(s, symType); } try { let res = this.givePriorityToFields(fieldAccesses); if (res != null) return res; if (nice.tools.typing.Types.parameters(expectedType) != null) { // in case of function objects symbols find the most precise match let nonMin = removeNonMinimal(symbols); if (symbols.size() == 1) { let s = symbols[0]; let symType = s.getClonedType(); s.releaseClonedType(); symbols = nonMin; return this.uniqueExpression(s, symType); } else symbols.addAll(nonMin); } if (symbols.size() != 0) throw new AmbiguityError(this); throw User.error(this, this.noMatchError(removed, expectedType)); } finally { this.releaseAllClonedTypes(); } } private void releaseAllClonedTypes() { for (s : symbols) s.releaseClonedType(); } noOverloading() { if(bossa.util.Debug.overloading) bossa.util.Debug.println("(no)Overloading resolution for "+this); if(symbols.size()==1) return this.uniqueExpression(); let res = this.givePriorityToFields(this.filterFieldAccesses()); if (res != null) return res; List<VarSymbol> globalvars = symbols.filter(VarSymbol sym => sym instanceof GlobalVarDeclaration.GlobalVarSymbol); // If there are global variables, give them the priority // (but not when there are *only* global variables, or it would loop). if (globalvars.size() > 0 && globalvars.size() < symbols.size()) return createOverloadedSymbolExp(globalvars, ident).noOverloading(); if (symbols.size() != 0) throw new AmbiguityError(this); throw User.error(this, "No variable or field in this class has name " + ident); } /** @return null if there is no solution. */ private ?Expression givePriorityToFields (List<VarSymbol> fieldAccesses) { if (fieldAccesses.size() != 0) { if (Node.thisExp != null) try { let res = new CallExp (createOverloadedSymbolExp(fieldAccesses, ident, true), //Arguments.noArguments()); new Arguments([new Arguments.Argument(Node.thisExp)])); res.setLocation(ident.location()); res.resolveOverloading(); return res; } catch (UserError e) {} symbols.removeAll(this.filterFieldAccesses()); if (symbols.size() == 1) return this.uniqueExpression(); } // There is no solution. return null; } private List<VarSymbol> filterFieldAccesses() { return symbols.filter(VarSymbol sym => sym.isFieldAccess()); } computeType() { Internal.error(this,ident+" has not been resolved yet.\n"+ "Possibilities are :"+this); } compile() { Internal.error("compile in "+this.getClass()+" "+this); return cast(null); } toString() { if (symbols.size() <= 1) return "[" + Util.map("", "\n|", "", symbols.toArray()) + "]"; return "\n[" + Util.map("", "\n|", "", symbols.toArray()) + "]"; } /**************************************************************** * Error messages ****************************************************************/ /** No method in removed matched these arguments. */ private String noMatchError(List<VarSymbol> removed, Arguments arguments) { if (removed.size() == 0) return "No method has name " + ident; if (removed.size() == 1) { let sym = removed[0]; if (sym.isIgnored()) return sym.getName() + " cannot be used because it has been ignored.\n" + "See above for the reason why it has been ignored"; return sym.explainWhyMatchFails(arguments); } return "No method with name " + ident + arguments.explainNoMatch(removed); } /** No symbol in removed had the expected type. */ private String noMatchError(List<VarSymbol> removed, mlsub.typing.Polytype expectedType) { if (removed.size() == 0) return "No method has name " + ident; if (removed.size() == 1) return ident + " has type " + removed[0].getType(); return "No symbol with name " + ident + " has type " + expectedType + ":\n" + Util.map("", "\n", "", removed.toArray()); } } /** @param symbols All the possible VarSymbols @param ident the original identifier */ Expression createOverloadedSymbolExp(List<VarSymbol> symbols, LocatedString ident) { if(symbols == null) Internal.error("No symbols"); let res = new OverloadedSymbolExp(symbols: symbols, ident: ident); res.setLocation(ident.location()); return res; } private Expression createOverloadedSymbolExp(List<VarSymbol> symbols, LocatedString ident, boolean noImplicitThis) { if(symbols == null) Internal.error("No symbols"); let res = new OverloadedSymbolExp(symbols: symbols, ident: ident, noImplicitThis: noImplicitThis); res.setLocation(ident.location()); return res; } Expression createOverloadedSymbolExp(VarSymbol symbol, LocatedString ident) { let List<VarSymbol> list = new LinkedList(); list.add(symbol); return createOverloadedSymbolExp(list, ident); } class AmbiguityError extends UserError {} new AmbiguityError(OverloadedSymbolExp sym) { this(sym, "Ambiguity for symbol " + sym.ident + ". Possibilities are :\n" + Util.map("", "\n", "", toArray(sym.symbols))); } List<VarSymbol> removeNonMinimal(List<VarSymbol> symbols) { List<VarSymbol> removed = new ArrayList(); // optimization if(symbols.size()<2) return removed; int len = symbols.size(); VarSymbol[] syms = new VarSymbol[len].fillWith(symbols); boolean[] remove = new boolean[len]; for(int s1 = 0; s1<len; s1++) { Domain d1 = nice.tools.typing.Types.domain(syms[s1].getType()); for(int s2 = 0; s2<len; s2++) /* Look for symbols s1 and s2 such that d2 <: d1 and not d1 <: d2 In that case s1 can be removed, since it is less specific than s2. Optimizations: Skip the diagonal. If s2 was removed, then there is s3 below s2. Therefore s1 will be removed anyway. */ if (s1 != s2 && !remove[s2]) { Domain d2 = nice.tools.typing.Types.domain(syms[s2].getType()); try { Typing.leq(d2, d1); try { Typing.leq(d1, d2); } catch (TypingEx e) { remove[s1] = true; break; } } catch(TypingEx e){ } } } for(int i = 0; i<len; i++) if(remove[i]) { if (bossa.util.Debug.overloading) bossa.util.Debug.println("Removing " + syms[i] + " since it is not minimal"); removed.add(syms[i]); symbols.remove(syms[i]); } return removed; } /** * Removes the symbols that do not have minimal domain types. * * For instance, if the set of symbols is {s1, s2} * with s1:A->C and s2:B->D with B<:A, * removoNonMinimal will remove s1. * * This allows for java-style overloading, * where the most precise method is choosen at compile-time. */ private void removeNonMinimal(List<VarSymbol> symbols, Arguments arguments) { // optimization if(symbols.size()<2) return; int len = symbols.size(); VarSymbol[] syms = new VarSymbol[len].fillWith(symbols); boolean[] remove = new boolean[len]; for(int s1 = 0; s1<len; s1++) { Domain d1 = domain(syms[s1].getClonedType(), arguments.getUsedArguments(syms[s1])); for(int s2 = 0; s2<len; s2++) /* Look for symbols s1 and s2 such that d2 <: d1 and not d1 <: d2 In that case s1 can be removed, since it is less specific than s2. Optimizations: Skip the diagonal. If s2 was removed, then there is s3 below s2. Therefore s1 will be removed anyway. */ if (s1 != s2 && !remove[s2]) { Domain d2 = domain(syms[s2].getClonedType(), arguments.getUsedArguments(syms[s2])); try { Typing.leq(d2, d1); try { Typing.leq(d1, d2); } catch (TypingEx e) { remove[s1] = true; break; } } catch(TypingEx e){ } } } for(int i = 0; i<len; i++) if(remove[i]) { if (bossa.util.Debug.overloading) bossa.util.Debug.println("Removing " + syms[i] + " since it is not minimal"); syms[i].releaseClonedType(); symbols.remove(syms[i]); } } private Domain domain(mlsub.typing.Polytype t, int[] usedArguments) { // remove nullness marker mlsub.typing.Monotype[] m = nice.tools.typing.Types.parameters(t.getMonotype()); ?mlsub.typing.Monotype[] dom; if (usedArguments == null) dom = cast(m);... [truncated message content] |
From: Arjan B. <ar...@us...> - 2004-07-28 14:40:43
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22973/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Conversion of some expression and statement classes in bossa.syntax to nice code. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.248 retrieving revision 1.249 diff -C2 -d -r1.248 -r1.249 *** Parser.jj 16 Jul 2004 10:01:33 -0000 1.248 --- Parser.jj 28 Jul 2004 14:40:34 -0000 1.249 *************** *** 877,881 **** makeLocation(first, last)); } else { ident = id; } ! Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(ident)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); --- 877,881 ---- makeLocation(first, last)); } else { ident = id; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),new IdentExp(ident)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); *************** *** 1340,1344 **** ( ".." "." { return null; } // toplevel function in interface file | ! exp=Expression() ";" { code = new ReturnStmt(exp, /* fake */ true); } | {Statement res;} --- 1340,1344 ---- ( ".." "." { return null; } // toplevel function in interface file | ! exp=Expression() ";" { code = bossa.syntax.dispatch.createReturnStmt(exp, /* fake */ true); } | {Statement res;} *************** *** 1751,1755 **** makeLocation(first, last)); } else { name = ident; } ! Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(name)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); --- 1751,1755 ---- makeLocation(first, last)); } else { name = ident; } ! Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts),new IdentExp(name)); exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); *************** *** 1761,1765 **** } ! FunExp funExp(): { List formals = new LinkedList(); --- 1761,1765 ---- } ! Expression funExp(): { List formals = new LinkedList(); *************** *** 1786,1793 **** body=RootShortStatement() | ! exp=Expression() { body = new ReturnStmt(exp); } ) { statements.add(body); ! return new FunExp(cst, formals, new Block(statements)); } } --- 1786,1793 ---- body=RootShortStatement() | ! exp=Expression() { body = bossa.syntax.dispatch.createReturnStmt(exp); } ) { statements.add(body); ! return bossa.syntax.dispatch.createFunExp(cst, formals, new Block(statements)); } } *************** *** 1846,1850 **** } { ! "[]" { return new LiteralArrayExp(null); } | "[" { exps = new LinkedList(); } --- 1846,1850 ---- } { ! "[]" { return bossa.syntax.dispatch.createLiteralArrayExp(null); } | "[" { exps = new LinkedList(); } *************** *** 1856,1860 **** ] "]" ! { return new LiteralArrayExp(exps); } } --- 1856,1860 ---- ] "]" ! { return bossa.syntax.dispatch.createLiteralArrayExp(exps); } } *************** *** 1938,1942 **** e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=AssignExp.create(e1,e2); } ] --- 1938,1942 ---- e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=bossa.syntax.dispatch.createAssignExp(e1,e2); } ] *************** *** 2169,2173 **** { ( t="++" {inc = true;} | t="--" ) res=PrimaryExpression() ! { return new IncrementExp(res, true, inc); } } --- 2169,2173 ---- { ( t="++" {inc = true;} | t="--" ) res=PrimaryExpression() ! { return bossa.syntax.dispatch.createIncrementExp(res, true, inc); } } *************** *** 2176,2181 **** { res=PrimaryExpression() ! [ "++" { res=new IncrementExp(res, false, true); } ! | "--" { res=new IncrementExp(res, false, false); } ] { return res; } --- 2176,2181 ---- { res=PrimaryExpression() ! [ "++" { res=bossa.syntax.dispatch.createIncrementExp(res, false, true); } ! | "--" { res=bossa.syntax.dispatch.createIncrementExp(res, false, false); } ] { return res; } *************** *** 2397,2401 **** } ! Statement Block() : { Token first, last; Statement s; List statements; } { --- 2397,2401 ---- } ! Block Block() : { Token first, last; Statement s; List statements; } { *************** *** 2407,2411 **** { last = getToken(0); ! Statement res = new Block(statements); res.setLocation(makeLocation(first, last)); return res; --- 2407,2411 ---- { last = getToken(0); ! Block res = new Block(statements); res.setLocation(makeLocation(first, last)); return res; *************** *** 2491,2495 **** last=")" "=" e=Expression() ";" ! { Expression exp = AssignExp.create(new TupleExp(parts), e); exp.setLocation(makeLocation(first,last)); return new ExpressionStmt(exp); } --- 2491,2495 ---- last=")" "=" e=Expression() ";" ! { Expression exp = bossa.syntax.dispatch.createAssignExp(new TupleExp(parts), e); exp.setLocation(makeLocation(first,last)); return new ExpressionStmt(exp); } *************** *** 2640,2646 **** { ( ! "++" { e1=new IncrementExp(e1, false, true); } | ! "--" { e1=new IncrementExp(e1, false, false); } | { Token op; Expression e2; --- 2640,2646 ---- { ( ! "++" { e1=bossa.syntax.dispatch.createIncrementExp(e1, false, true); } | ! "--" { e1=bossa.syntax.dispatch.createIncrementExp(e1, false, false); } | { Token op; Expression e2; *************** *** 2653,2657 **** e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=AssignExp.create(e1,e2); } ) --- 2653,2657 ---- e2=CallExp.create(symb(op.image.substring(0, 1),op),e1,e2); ! e1=bossa.syntax.dispatch.createAssignExp(e1,e2); } ) *************** *** 2670,2677 **** s1=Statement() [ LOOKAHEAD(1) "else" s2=Statement() ] { ! ifExp = new IfExp(cond, new StatementExp(s1), ! (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(makeLocation(first, getToken(0))); ! return new ExpressionStmt(ifExp); } } --- 2670,2675 ---- s1=Statement() [ LOOKAHEAD(1) "else" s2=Statement() ] { ! return bossa.syntax.dispatch.createIfStmt(cond, s1, s2, ! makeLocation(first, getToken(0))); } } *************** *** 2688,2695 **** s1=ShortStatement() [ LOOKAHEAD(1) "else" s2=ShortStatement() ] { ! ifExp = new IfExp(cond, new StatementExp(s1), ! (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(makeLocation(first, getToken(0))); ! return new ExpressionStmt(ifExp); } } --- 2686,2691 ---- s1=ShortStatement() [ LOOKAHEAD(1) "else" s2=ShortStatement() ] { ! return bossa.syntax.dispatch.createIfStmt(cond, s1, s2, ! makeLocation(first, getToken(0))); } } *************** *** 2699,2703 **** { "while" "(" cond=Expression() ")" body=Statement() ! { return LoopStmt.whileLoop(cond,body); } } --- 2695,2699 ---- { "while" "(" cond=Expression() ")" body=Statement() ! { return bossa.syntax.dispatch.createWhileLoop(cond,body); } } *************** *** 2706,2714 **** { "do" body=Statement() "while" "(" cond=Expression() ")" ";" ! { return LoopStmt.doLoop(cond,body); } } Statement ForStatement() : ! { Statement update = null, loop = null, body, statexp; Expression cond = null; List init = new ArrayList(); --- 2702,2711 ---- { "do" body=Statement() "while" "(" cond=Expression() ")" ";" ! { return bossa.syntax.dispatch.createDoLoop(cond,body); } } Statement ForStatement() : ! { Block update = null; ! Statement loop = null, body, statexp; Expression cond = null; List init = new ArrayList(); *************** *** 2729,2733 **** body=Statement() { ! loop=LoopStmt.forLoop(cond,update,body); List l = new LinkedList(); l.addAll(init); --- 2726,2730 ---- body=Statement() { ! loop=bossa.syntax.dispatch.createForLoop(cond,update,body); List l = new LinkedList(); l.addAll(init); *************** *** 2749,2753 **** t=":" container=Expression() ")" body=Statement() ! { return LoopStmt.forInLoop(vartype,var,makeLocation(t),container,body); } } --- 2746,2750 ---- t=":" container=Expression() ")" body=Statement() ! { return bossa.syntax.dispatch.createForInLoop(vartype,var,makeLocation(t),container,body); } } *************** *** 2761,2765 **** } ! Statement StatementExpressionList() : { Statement s; List statements=new LinkedList(); } { --- 2758,2762 ---- } ! Block StatementExpressionList() : { Statement s; List statements=new LinkedList(); } { *************** *** 2774,2780 **** { "break" [ label=ident() ] ";" ! { if (label == null) return BreakStmt.instance; ! else return new BreakLabelStmt(label); ! } } --- 2771,2775 ---- { "break" [ label=ident() ] ";" ! { return bossa.syntax.dispatch.createBreakStmt(label); } } *************** *** 2783,2787 **** { "continue" [ label=ident() ] ";" ! { return ContinueStmt.make(label); } } --- 2778,2782 ---- { "continue" [ label=ident() ] ";" ! { return bossa.syntax.dispatch.createContinueStmt(label); } } *************** *** 2791,2795 **** t="return" [ val=Expression() ] ";" { ! Statement res = new ReturnStmt(val); res.setLocation(makeLocation(t)); return res; --- 2786,2790 ---- t="return" [ val=Expression() ] ";" { ! Statement res = bossa.syntax.dispatch.createReturnStmt(val); res.setLocation(makeLocation(t)); return res; |
From: Daniel B. <bo...@us...> - 2004-07-28 14:28:21
|
Update of /cvsroot/nice/Nice/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21076/bin Modified Files: nicec Log Message: Call 'dispatch' classes instead of 'fun', so that stack traces are printed correctly. Index: nicec =================================================================== RCS file: /cvsroot/nice/Nice/bin/nicec,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** nicec 2 Jul 2004 23:29:08 -0000 1.39 --- nicec 28 Jul 2004 14:28:09 -0000 1.40 *************** *** 71,76 **** case $progname in ! nicedoc) class=nice.tools.doc.fun ;; ! niceunit) class=nice.tools.unit.console.fun ;; nicec) class=nice.tools.compiler.console.fun --- 71,76 ---- case $progname in ! nicedoc) class=nice.tools.doc.dispatch ;; ! niceunit) class=nice.tools.unit.console.dispatch ;; nicec) class=nice.tools.compiler.console.fun |
From: Arjan B. <ar...@us...> - 2004-07-23 23:29:09
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18937/F:/nice/stdlib/nice/lang Modified Files: array.nice Log Message: Added method for filling arrays from a collection. Index: array.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/array.nice,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** array.nice 25 Mar 2004 00:02:03 -0000 1.35 --- array.nice 23 Jul 2004 23:29:00 -0000 1.36 *************** *** 149,152 **** --- 149,165 ---- } + /** + Fills a newly created array from a collection. + The size of the collection needs to be equal to or larger than the size of the array. + */ + <T, U | U <: T> U[] fillWith(T[] array, Collection<U> collection) + { + let iter = collection.iterator(); + for (int i = 0; i < array.length; i++) + array[i] = iter.next(); + + return cast(array); + } + /** Returns an array containing, in order, the elements of both arguments. |
From: Daniel B. <bo...@us...> - 2004-07-23 21:56:02
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1064/src/bossa/modules Modified Files: JarCompiledContent.java Log Message: Take into account the date of the jar file itself, to be sure to recompile importing packages when the jar was created after compilation. Index: JarCompiledContent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/JarCompiledContent.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** JarCompiledContent.java 3 May 2002 10:05:53 -0000 1.6 --- JarCompiledContent.java 23 Jul 2004 21:55:51 -0000 1.7 *************** *** 47,52 **** (pkg, jar, itfEntry, bytecodeEntry, dispatchEntry); } ! ! JarCompiledContent(Package pkg, JarFile jar, JarEntry itfEntry, JarEntry bytecodeEntry, JarEntry dispatchEntry) { --- 47,52 ---- (pkg, jar, itfEntry, bytecodeEntry, dispatchEntry); } ! ! JarCompiledContent(Package pkg, JarFile jar, JarEntry itfEntry, JarEntry bytecodeEntry, JarEntry dispatchEntry) { *************** *** 58,64 **** this.dispatchEntry = dispatchEntry; ! this.lastCompilation = Math.min(itfEntry.getTime(), ! Math.min(bytecodeEntry.getTime(), dispatchEntry.getTime())); } --- 58,73 ---- this.dispatchEntry = dispatchEntry; ! this.lastCompilation = Math.min(itfEntry.getTime(), ! Math.min(bytecodeEntry.getTime(), ! dispatchEntry.getTime())); ! ! /* Use the date of creation of the jar file if it is later. ! The package might have been compiled earlier, but we probably did ! not get to see it before it was put into this jar. ! This is in particular the case if the jar is an upgraded library. ! */ ! this.lastCompilation = ! Math.max(new File(jar.getName()).lastModified(), this.lastCompilation); } |
From: Daniel B. <bo...@us...> - 2004-07-23 21:52:49
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv390/src/bossa/modules Modified Files: Content.java Log Message: When source code is not available, use the last compilation time to determine if importing packages should be recompiled. Index: Content.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Content.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Content.java 30 Jun 2004 14:12:37 -0000 1.15 --- Content.java 23 Jul 2004 21:52:40 -0000 1.16 *************** *** 40,46 **** "\nThe source path is: " + str(pkg.compilation.sourcePath) + "\nThe package path is: " + str(pkg.compilation.packagePath)); ! if (compiled != null) ! lastCompilation = compiled.lastCompilation; if (source != null) lastModification = source.lastModification; --- 40,49 ---- "\nThe source path is: " + str(pkg.compilation.sourcePath) + "\nThe package path is: " + str(pkg.compilation.packagePath)); ! ! // By default, use the last compilation time also as last modification time ! // This is a safe bet, and will be overwritten if source is also available. if (compiled != null) ! lastModification = lastCompilation = compiled.lastCompilation; ! if (source != null) lastModification = source.lastModification; |
From: Arjan B. <ar...@us...> - 2004-07-22 18:27:48
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv515/F:/nice/src/bossa/syntax Modified Files: OverloadedSymbolExp.java Log Message: Make sure not to loose the location of fieldaccesses. Index: OverloadedSymbolExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** OverloadedSymbolExp.java 22 Jul 2004 13:52:41 -0000 1.72 --- OverloadedSymbolExp.java 22 Jul 2004 18:27:39 -0000 1.73 *************** *** 379,382 **** --- 379,383 ---- new Arguments(new Arguments.Argument[]{new Arguments.Argument(Node.thisExp)})); + res.setLocation(ident.location()); res.resolveOverloading(); return res; |
From: Daniel B. <bo...@us...> - 2004-07-22 16:15:05
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6072/src/gnu/expr Modified Files: ClassExp.java CheckContract.java Log Message: Fix importing of class methods with contracts. Index: ClassExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/ClassExp.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ClassExp.java 17 Jun 2004 11:48:17 -0000 1.20 --- ClassExp.java 22 Jul 2004 16:14:54 -0000 1.21 *************** *** 61,64 **** --- 61,65 ---- this(); this.type = this.instanceType = type; + setName(type.getName()); } *************** *** 681,686 **** if (assertionEnabledField == null) { ! assertionEnabledField = ((ClassType) getType()).addField ! ("$assertionsEnabled", Type.boolean_type, Access.STATIC | Access.FINAL); --- 682,695 ---- if (assertionEnabledField == null) { ! ClassType classe = (ClassType) getType(); ! ! // Get the field if it already exists. ! // This is the case for already compiled classes. ! assertionEnabledField = classe.getField("$assertionsEnabled"); ! if (assertionEnabledField != null) ! return assertionEnabledField; ! ! assertionEnabledField = classe.addField ! ("$assertionsEnabled", Type.boolean_type, Access.STATIC | Access.FINAL); Index: CheckContract.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/CheckContract.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CheckContract.java 19 Mar 2003 00:45:16 -0000 1.3 --- CheckContract.java 22 Jul 2004 16:14:54 -0000 1.4 *************** *** 40,46 **** { CodeAttr code = comp.getCode(); ! ClassExp currentClass = (ClassExp)comp.topLambda; code.preparePostcondition(currentClass.getAssertionEnabledField(), post.length>0); ! if (pre.length > 0) { code.startPrecondition(); --- 40,46 ---- { CodeAttr code = comp.getCode(); ! ClassExp currentClass = comp.curLambda.outerClass(); code.preparePostcondition(currentClass.getAssertionEnabledField(), post.length>0); ! if (pre.length > 0) { code.startPrecondition(); *************** *** 58,66 **** for (int i = 0; i < post.length; i++) post[i].compileWithPosition(comp, Target.Ignore); ! code.endPostcondition(); } else ! code.pushRetType(); } --- 58,66 ---- for (int i = 0; i < post.length; i++) post[i].compileWithPosition(comp, Target.Ignore); ! code.endPostcondition(); } else ! code.pushRetType(); } |
From: Daniel B. <bo...@us...> - 2004-07-22 16:15:05
|
Update of /cvsroot/nice/Nice/testsuite/compiler/designByContract In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6072/testsuite/compiler/designByContract Modified Files: methods.testsuite Log Message: Fix importing of class methods with contracts. Index: methods.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/designByContract/methods.testsuite,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** methods.testsuite 30 Jun 2004 09:42:33 -0000 1.7 --- methods.testsuite 22 Jul 2004 16:14:54 -0000 1.8 *************** *** 94,95 **** --- 94,112 ---- class A { ?int foo; } void bar(A a) requires a.foo == null || notNull(a.foo) >= 0 {} + + /// PASS + /// package a + /// Toplevel + // Compilation of contracts in class methods with multiple packages + public class Index + { + final boolean relativeToEnd; + + public void `-`() + requires this.relativeToEnd + { + } + } + + /// package b import a + {} |
From: Arjan B. <ar...@us...> - 2004-07-22 15:19:35
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29225/F:/nice/src/bossa/syntax Modified Files: TryStmt.java PrimitiveType.java Log Message: Removed the method version of throwableTC. Index: PrimitiveType.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/PrimitiveType.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PrimitiveType.java 11 Feb 2004 12:46:39 -0000 1.10 --- PrimitiveType.java 22 Jul 2004 15:19:19 -0000 1.11 *************** *** 190,197 **** static TypeConstructor collectionTC; static TypeConstructor throwableTC; - static TypeConstructor throwableTC() - { - return throwableTC; - } private static Polytype throwableType; --- 190,193 ---- *************** *** 202,206 **** throwableType = new Polytype (Constraint.True, ! Monotype.sure(new MonotypeConstructor(throwableTC(), null))); } return throwableType; --- 198,202 ---- throwableType = new Polytype (Constraint.True, ! Monotype.sure(new MonotypeConstructor(throwableTC, null))); } return throwableType; Index: TryStmt.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TryStmt.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TryStmt.java 19 Oct 2003 00:16:29 -0000 1.14 --- TryStmt.java 22 Jul 2004 15:19:19 -0000 1.15 *************** *** 89,93 **** Statement finallyBody; List catches = new LinkedList(); ! public class Catch { --- 89,93 ---- Statement finallyBody; List catches = new LinkedList(); ! public class Catch { *************** *** 107,111 **** { try{ ! Typing.leq(t, PrimitiveType.throwableTC()); } catch(TypingEx e){ --- 107,111 ---- { try{ ! Typing.leq(t, PrimitiveType.throwableTC); } catch(TypingEx e){ |